/* $Id: $ */ /** @file * * kLdr - The Dynamic Loader, Helper Functions. * * Copyright (c) 2006 knut st. osmundsen * * * This file is part of kLdr. * * kLdr is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * kLdr is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with kLdr; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef __kLdrHlp_h__ #define __kLdrHlp_h__ /** Get the minimum of two values. */ #define KLDR_MIN(a, b) ((a) <= (b) ? (a) : (b)) #ifdef __OS2__ int kldrSemInit(void); int kldrSemTerm(void); int kldrSemRequest(void); int kldrSemRelease(void); int kldrSemGlobalRequest(void); int kldrSemGlobalRelease(void); /** Loader file handle. */ typedef unsigned long KLDRFILE; /** Pointer to a loader file handle. */ typedef KLDRFILE *PKLDRFILE; int kldrFileOpen(const char *pszFilename, PKLDRFILE pFile); int kldrFileClose(KLDRFILE File); int kldrFileRead(KLDRFILE File, off_t off, void *pv, size_t cb); int kldrGetEnv(const char *pszVar, char *pszVar, size_t *pcchVar) void *kldrAlloc(size_t cb); void kldrFree(void *pv); int kldrPrivateAlloc(void *pv, size_t cb, unsigned fFlags, void **ppv); int kldrPrivateFree(void *pv, size_t cb); int kldrSharedAlloc(void *pv, size_t cb, unsigned fFlags, const char *pszFilename, KLDRFILE File, void **ppv); int kldrSharedFree(void *pv, size_t cb); void kldrExit(int rc); /* #elif __WIN__ */ #else #endif /* * Compiler specific helpers. * (I.e. operations that tend to have compiler intrinsic implementations). */ #ifdef __GNUC__ /** memcpy */ # define kLdrMemCopy(a,b,c) __builtin_memcpy(a,b,c) /** memset */ # define kLdrMemSet(a,b,c) __builtin_memset(a,b,c) #endif #ifndef kLdrMemCopy # error "Needs porting to your compiler." #endif #endif /* __kLdrHlp_h__ */