Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Multidevice ASIO output plugin for WinAMP

, 13 Feb 2009 CDDL
A tiny WinAMP output DLL that uses a C++ replacement of the official ASIO SDK that supports multiple ASIO devices.
// memory.cpp

// based on:
// LIBCTINY - Matt Pietrek 2001
// MSDN Magazine, January 2001

// 08/13/06 (mv)
#include <windows.h>
#include <string.h>
#include "libct.h"

#include <cassert>

BEGIN_EXTERN_C

int _resetstkoflw()
{
    HMODULE const hMSVCRT( ::LoadLibrary( "msvcrt.dll" ) );
    assert( hMSVCRT );
    typedef int ( __cdecl * Resetstkoflw )();
    Resetstkoflw pResetstkoflw( reinterpret_cast<Resetstkoflw>( ::GetProcAddress( hMSVCRT, "_resetstkofl" ) ) );
    assert( pResetstkoflw );
    int const result( pResetstkoflw ? pResetstkoflw() : false );
    ::FreeLibrary( hMSVCRT );
    return result;
}


__declspec(selectany) extern DWORD const __sse2_available
(
    ( _M_IX86_FP >= 2 )
        ? true
        : ::IsProcessorFeaturePresent( PF_XMMI64_INSTRUCTIONS_AVAILABLE )
);


#if 0 // Disabled for MSVC asm implementations.
#pragma function(memcmp)
int memcmp(const void *b1, const void *b2, size_t n)
{
	const unsigned char *p1 = (const unsigned char*)b1;
	const unsigned char *p2 = (const unsigned char*)b2;

	if (!n)
		return 0;
	for (size_t i = 0; i < n; i++)
	{
		if (p1[i] != p2[i])
			return p1[i]-p2[i];
	}
	return 0;
}

#pragma function(memset)
void * __cdecl memset(void *dst, int val, size_t size)
{
	char *realdst = (char*)dst;
	for (size_t i = 0; i < size; i++)
		realdst[i] = (char)val;
	return dst;
}

#pragma function(memcpy)
void * __cdecl memcpy(void *dst, const void *src, size_t size)
{
	char *_dst = (char*)dst;
	const char *_src = (char*)src;
	for (size_t i = 0; i < size; i++)
		_dst[i] = _src[i];
	return dst;
}

void *memmove(void *dst, const void *src, size_t count)
{
	void *ret = dst;
	if (dst <= src || (char *)dst >= ((char *)src + count))
	{
		// Non-Overlapping Buffers
		// copy from lower addresses to higher addresses
		while (count--)
		{
			*(char*)dst = *(char*)src;
			dst = (char*)dst + 1;
			src = (char*)src + 1;
		}
	}
	else
	{
		// Overlapping Buffers
		// copy from higher addresses to lower addresses
		dst = (char*)dst + count - 1;
		src = (char*)src + count - 1;

		while (count--)
		{
			*(char*)dst = *(char*)src;
			dst = (char*)dst - 1;
			src = (char*)src - 1;
		}
	}

	return ret;
}
#endif // Disabled for MSVC asm implementations.


END_EXTERN_C

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

Share

About the Author

Domagoj Šarić
Software Developer Little Endian Ltd.
Croatia Croatia
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150327.1 | Last Updated 13 Feb 2009
Article Copyright 2009 by Domagoj Šarić
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid