source: trunk/kLdr/kLdrHlp.h@ 2824

Last change on this file since 2824 was 2824, checked in by bird, 19 years ago

...

File size: 2.3 KB
Line 
1/* $Id: $ */
2/** @file
3 *
4 * kLdr - The Dynamic Loader, Helper Functions.
5 *
6 * Copyright (c) 2006 knut st. osmundsen <bird@anduin.net>
7 *
8 *
9 * This file is part of kLdr.
10 *
11 * kLdr is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * kLdr is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with kLdr; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27
28#ifndef __kLdrHlp_h__
29#define __kLdrHlp_h__
30
31/** Get the minimum of two values. */
32#define KLDR_MIN(a, b) ((a) <= (b) ? (a) : (b))
33
34#ifdef __OS2__
35
36int kldrSemInit(void);
37int kldrSemTerm(void);
38int kldrSemRequest(void);
39int kldrSemRelease(void);
40int kldrSemGlobalRequest(void);
41int kldrSemGlobalRelease(void);
42
43/** Loader file handle. */
44typedef unsigned long KLDRFILE;
45/** Pointer to a loader file handle. */
46typedef KLDRFILE *PKLDRFILE;
47
48int kldrFileOpen(const char *pszFilename, PKLDRFILE pFile);
49int kldrFileClose(KLDRFILE File);
50int kldrFileRead(KLDRFILE File, off_t off, void *pv, size_t cb);
51
52int kldrGetEnv(const char *pszVar, char *pszVar, size_t *pcchVar)
53
54void *kldrAlloc(size_t cb);
55void kldrFree(void *pv);
56
57int kldrPrivateAlloc(void *pv, size_t cb, unsigned fFlags, void **ppv);
58int kldrPrivateFree(void *pv, size_t cb);
59int kldrSharedAlloc(void *pv, size_t cb, unsigned fFlags, const char *pszFilename, KLDRFILE File, void **ppv);
60int kldrSharedFree(void *pv, size_t cb);
61
62void kldrExit(int rc);
63
64/* #elif __WIN__ */
65
66#else
67
68
69
70#endif
71
72/*
73 * Compiler specific helpers.
74 * (I.e. operations that tend to have compiler intrinsic implementations).
75 */
76#ifdef __GNUC__
77/** memcpy */
78# define kLdrMemCopy(a,b,c) __builtin_memcpy(a,b,c)
79/** memset */
80# define kLdrMemSet(a,b,c) __builtin_memset(a,b,c)
81#endif
82
83#ifndef kLdrMemCopy
84# error "Needs porting to your compiler."
85#endif
86
87#endif /* __kLdrHlp_h__ */
Note: See TracBrowser for help on using the repository browser.