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 |
|
---|
36 | int kldrSemInit(void);
|
---|
37 | int kldrSemTerm(void);
|
---|
38 | int kldrSemRequest(void);
|
---|
39 | int kldrSemRelease(void);
|
---|
40 | int kldrSemGlobalRequest(void);
|
---|
41 | int kldrSemGlobalRelease(void);
|
---|
42 |
|
---|
43 | /** Loader file handle. */
|
---|
44 | typedef unsigned long KLDRFILE;
|
---|
45 | /** Pointer to a loader file handle. */
|
---|
46 | typedef KLDRFILE *PKLDRFILE;
|
---|
47 |
|
---|
48 | int kldrFileOpen(const char *pszFilename, PKLDRFILE pFile);
|
---|
49 | int kldrFileClose(KLDRFILE File);
|
---|
50 | int kldrFileRead(KLDRFILE File, off_t off, void *pv, size_t cb);
|
---|
51 |
|
---|
52 | int kldrGetEnv(const char *pszVar, char *pszVar, size_t *pcchVar)
|
---|
53 |
|
---|
54 | void *kldrAlloc(size_t cb);
|
---|
55 | void kldrFree(void *pv);
|
---|
56 |
|
---|
57 | int kldrPrivateAlloc(void *pv, size_t cb, unsigned fFlags, void **ppv);
|
---|
58 | int kldrPrivateFree(void *pv, size_t cb);
|
---|
59 | int kldrSharedAlloc(void *pv, size_t cb, unsigned fFlags, const char *pszFilename, KLDRFILE File, void **ppv);
|
---|
60 | int kldrSharedFree(void *pv, size_t cb);
|
---|
61 |
|
---|
62 | void 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__ */
|
---|