4 Copyright (C) 1996 Free Software Foundation, Inc.
6 Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
9 This file is part of the GNUstep Database Library.
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
16 This library 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 GNU
19 Library General Public License for more details.
21 You should have received a copy of the GNU Library General Public
22 License along with this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include <sys/types.h>
42 #import <Foundation/NSZone.h>
43 #import <Foundation/Foundation.h>
44 #import <Foundation/NSUtilities.h>
45 #import <Foundation/NSObjCRuntime.h>
47 #if NeXT_RUNTIME || APPLE_RUNTIME
48 # define sel_eq(sela,selb) (sela==selb?YES:NO)
51 #if LIB_FOUNDATION_LIBRARY
52 # import <extensions/objc-runtime.h>
54 # include <NGExtensions/NGObjectMacros.h>
55 # include <NGExtensions/NSString+Ext.h>
59 // ******************** common functions ********************
61 static inline void *Malloc(int) __attribute__((unused));
62 static inline void *Calloc(int, int) __attribute__((unused));
63 static inline void *Realloc(void*, int) __attribute__((unused));
64 static inline void Free(void*) __attribute__((unused));
66 static inline int Strlen(const char*) __attribute__((unused));
67 static inline char* Strdup(const char*) __attribute__((unused));
68 static inline char* Strcpy (char*, const char*) __attribute__((unused));
69 static inline char* Strncpy (char*, const char*, unsigned)
70 __attribute__((unused));
71 static inline char* Strcat (char*, const char*) __attribute__((unused));
72 static inline char* Strncat (char*, const char*, unsigned)
73 __attribute__((unused));
74 static inline int Strcmp(const char*, const char*) __attribute__((unused));
75 static inline int Strncmp(const char*, const char*, unsigned)
76 __attribute__((unused));
77 static inline int Atoi(const char*) __attribute__((unused));
78 static inline long Atol(const char*) __attribute__((unused));
80 static inline void *Malloc(int size) {
84 static inline void *MallocAtomic(int size) {
88 static inline void Free(void* p) {
92 static inline void *Calloc(int elem, int size) {
93 return calloc(elem, size);
96 static inline void *CallocAtomic(int elem, int size) {
97 return calloc(elem, size);
100 static inline void *Realloc(void* p, int size) {
101 return realloc(p, size);
104 static inline int Strlen(const char* s) {
105 return s ? strlen(s) : 0;
108 static inline char* Strdup(const char* s) {
109 return s ? strcpy(Malloc(strlen(s) + 1), s) : NULL;
112 static inline char* Strcpy (char* d, const char* s) {
113 return s && d ? strcpy(d, s) : d;
116 static inline char* Strncpy (char* d, const char* s, unsigned size) {
117 return s && d ? strncpy(d, s, size) : d;
120 static inline char* Strcat (char* d, const char* s) {
121 return s && d ? strcat(d, s) : d;
124 static inline char* Strncat (char* d, const char* s , unsigned size) {
125 return s && d ? strncat(d, s , size) : d;
128 static inline int Strcmp(const char* p, const char* q) {
137 else return strcmp(p, q);
141 static inline int Strncmp(const char* p, const char* q, unsigned size) {
150 else return strncmp(p, q, size);
154 static inline int Atoi(const char* str)
156 return str ? atoi(str) : 0;
159 static inline long Atol(const char *str)
161 return str ? atol(str) : 0;
166 ({typedef _ta = (a), _tb = (b); \
167 _ta _a = (a); _tb _b = (b); \
168 _a > _b ? _a : _b; })
173 ({typedef _ta = (a), _tb = (b); \
174 _ta _a = (a); _tb _b = (b); \
175 _a < _b ? _a : _b; })
178 #if !LIB_FOUNDATION_LIBRARY
180 #ifndef CREATE_AUTORELEASE_POOL
181 #define CREATE_AUTORELEASE_POOL(pool) \
182 id pool = [[NSAutoreleasePool alloc] init]
185 #endif /* ! LIB_FOUNDATION_LIBRARY */
188 #if !LIB_FOUNDATION_LIBRARY
190 static inline char *Ltoa(long nr, char *str, int base)
192 char buff[34], rest, is_negative;
218 Strcpy(str, &buff[ptr+1]);
224 #if !LIB_FOUNDATION_LIBRARY
226 @interface NSObject(FoundationExtGDLAccess)
227 - (void)subclassResponsibility:(SEL)sel;
228 - (void)notImplemented:(SEL)sel;
235 # define SEL_EQ(__A__,__B__) (__A__==__B__ ? YES : NO)
239 # include <objc/objc.h>
240 # define SEL_EQ(__A__,__B__) sel_eq(__A__,__B__)
244 #endif /* __common_h__ */