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>
45 #if !(COCOA_Foundation_LIBRARY || NeXT_Foundation_LIBRARY)
46 # import <Foundation/NSUtilities.h>
49 #import <Foundation/NSObjCRuntime.h>
51 #if NeXT_RUNTIME || APPLE_RUNTIME
52 # define sel_eq(sela,selb) (sela==selb?YES:NO)
55 #if LIB_FOUNDATION_LIBRARY
56 # import <extensions/objc-runtime.h>
58 # include <NGExtensions/NGObjectMacros.h>
59 # include <NGExtensions/NSString+Ext.h>
63 // ******************** common functions ********************
65 static inline void *Malloc(int) __attribute__((unused));
66 static inline void *Calloc(int, int) __attribute__((unused));
67 static inline void *Realloc(void*, int) __attribute__((unused));
68 static inline void Free(void*) __attribute__((unused));
70 static inline int Strlen(const char*) __attribute__((unused));
71 static inline char* Strdup(const char*) __attribute__((unused));
72 static inline char* Strcpy (char*, const char*) __attribute__((unused));
73 static inline char* Strncpy (char*, const char*, unsigned)
74 __attribute__((unused));
75 static inline char* Strcat (char*, const char*) __attribute__((unused));
76 static inline char* Strncat (char*, const char*, unsigned)
77 __attribute__((unused));
78 static inline int Strcmp(const char*, const char*) __attribute__((unused));
79 static inline int Strncmp(const char*, const char*, unsigned)
80 __attribute__((unused));
81 static inline int Atoi(const char*) __attribute__((unused));
82 static inline long Atol(const char*) __attribute__((unused));
84 static inline void *Malloc(int size) {
88 static inline void *MallocAtomic(int size) {
92 static inline void Free(void* p) {
96 static inline void *Calloc(int elem, int size) {
97 return calloc(elem, size);
100 static inline void *CallocAtomic(int elem, int size) {
101 return calloc(elem, size);
104 static inline void *Realloc(void* p, int size) {
105 return realloc(p, size);
108 static inline int Strlen(const char* s) {
109 return s ? strlen(s) : 0;
112 static inline char* Strdup(const char* s) {
113 return s ? strcpy(Malloc(strlen(s) + 1), s) : NULL;
116 static inline char* Strcpy (char* d, const char* s) {
117 return s && d ? strcpy(d, s) : d;
120 static inline char* Strncpy (char* d, const char* s, unsigned size) {
121 return s && d ? strncpy(d, s, size) : d;
124 static inline char* Strcat (char* d, const char* s) {
125 return s && d ? strcat(d, s) : d;
128 static inline char* Strncat (char* d, const char* s , unsigned size) {
129 return s && d ? strncat(d, s , size) : d;
132 static inline int Strcmp(const char* p, const char* q) {
141 else return strcmp(p, q);
145 static inline int Strncmp(const char* p, const char* q, unsigned size) {
154 else return strncmp(p, q, size);
158 static inline int Atoi(const char* str)
160 return str ? atoi(str) : 0;
163 static inline long Atol(const char *str)
165 return str ? atol(str) : 0;
170 ({typedef _ta = (a), _tb = (b); \
171 _ta _a = (a); _tb _b = (b); \
172 _a > _b ? _a : _b; })
177 ({typedef _ta = (a), _tb = (b); \
178 _ta _a = (a); _tb _b = (b); \
179 _a < _b ? _a : _b; })
182 #if !LIB_FOUNDATION_LIBRARY
184 #ifndef CREATE_AUTORELEASE_POOL
185 #define CREATE_AUTORELEASE_POOL(pool) \
186 id pool = [[NSAutoreleasePool alloc] init]
189 #endif /* ! LIB_FOUNDATION_LIBRARY */
192 #if !LIB_FOUNDATION_LIBRARY
194 static inline char *Ltoa(long nr, char *str, int base)
196 char buff[34], rest, is_negative;
222 Strcpy(str, &buff[ptr+1]);
228 #if !LIB_FOUNDATION_LIBRARY
230 @interface NSObject(FoundationExtGDLAccess)
231 - (void)subclassResponsibility:(SEL)sel;
232 - (void)notImplemented:(SEL)sel;
239 # define SEL_EQ(__A__,__B__) (__A__==__B__ ? YES : NO)
243 # include <objc/objc.h>
244 # define SEL_EQ(__A__,__B__) sel_eq(__A__,__B__)
248 #endif /* __common_h__ */