浏览代码

Merge branch 'master' of git://git.etherboot.org/scm/gpxe

tags/v0.9.3
Holger Lubitz 17 年前
父节点
当前提交
376bacab67

+ 5
- 0
src/Makefile.housekeeping 查看文件

@@ -403,6 +403,11 @@ include $(MEDIA_DEPS)
403 403
 allroms allzroms : all%s : $(foreach ROM,$(ROMS),$(BIN)/$(ROM).%)
404 404
 all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%)
405 405
 
406
+# Alias for gpxe.%
407
+#
408
+$(BIN)/etherboot.% : $(BIN)/gpxe.%
409
+	ln -sf $(notdir $<) $@
410
+
406 411
 # The compression utilities
407 412
 #
408 413
 $(NRV2B) : util/nrv2b.c $(MAKEDEPS)

+ 3
- 2
src/arch/i386/interface/pcbios/int13.c 查看文件

@@ -543,8 +543,9 @@ void register_int13_drive ( struct int13_drive *drive ) {
543 543
 
544 544
 	/* Assign drive number if none specified, update BIOS drive count */
545 545
 	get_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
546
-	if ( ! drive->drive )
547
-		drive->drive = ( num_drives | 0x80 );
546
+	if ( ( drive->drive & 0xff ) == 0xff )
547
+		drive->drive = num_drives;
548
+	drive->drive |= 0x80;
548 549
 	num_drives++;
549 550
 	if ( num_drives <= ( drive->drive & 0x7f ) )
550 551
 		num_drives = ( ( drive->drive & 0x7f ) + 1 );

+ 11
- 252
src/core/string.c 查看文件

@@ -28,41 +28,6 @@
28 28
 
29 29
 /* *** FROM string.c *** */
30 30
 
31
-#ifndef __HAVE_ARCH_STRNICMP
32
-/**
33
- * strnicmp - Case insensitive, length-limited string comparison
34
- * @s1: One string
35
- * @s2: The other string
36
- * @len: the maximum number of characters to compare
37
- */
38
-int strnicmp(const char *s1, const char *s2, size_t len)
39
-{
40
-	/* Yes, Virginia, it had better be unsigned */
41
-	unsigned char c1, c2;
42
-
43
-	c1 = 0;	c2 = 0;
44
-	if (len) {
45
-		do {
46
-			c1 = *s1; c2 = *s2;
47
-			s1++; s2++;
48
-			if (!c1)
49
-				break;
50
-			if (!c2)
51
-				break;
52
-			if (c1 == c2)
53
-				continue;
54
-			c1 = tolower(c1);
55
-			c2 = tolower(c2);
56
-			if (c1 != c2)
57
-				break;
58
-		} while (--len);
59
-	}
60
-	return (int)c1 - (int)c2;
61
-}
62
-#endif
63
-
64
-char * ___strtok;
65
-
66 31
 #ifndef __HAVE_ARCH_STRCPY
67 32
 /**
68 33
  * strcpy - Copy a %NUL terminated string
@@ -120,35 +85,6 @@ char * strcat(char * dest, const char * src)
120 85
 }
121 86
 #endif
122 87
 
123
-#ifndef __HAVE_ARCH_STRNCAT
124
-/**
125
- * strncat - Append a length-limited, %NUL-terminated string to another
126
- * @dest: The string to be appended to
127
- * @src: The string to append to it
128
- * @count: The maximum numbers of bytes to copy
129
- *
130
- * Note that in contrast to strncpy, strncat ensures the result is
131
- * terminated.
132
- */
133
-char * strncat(char *dest, const char *src, size_t count)
134
-{
135
-	char *tmp = dest;
136
-
137
-	if (count) {
138
-		while (*dest)
139
-			dest++;
140
-		while ((*dest++ = *src++)) {
141
-			if (--count == 0) {
142
-				*dest = '\0';
143
-				break;
144
-			}
145
-		}
146
-	}
147
-
148
-	return tmp;
149
-}
150
-#endif
151
-
152 88
 #ifndef __HAVE_ARCH_STRCMP
153 89
 /**
154 90
  * strcmp - Compare two strings
@@ -260,135 +196,6 @@ size_t strnlen(const char * s, size_t count)
260 196
 }
261 197
 #endif
262 198
 
263
-#ifndef __HAVE_ARCH_STRSPN
264
-/**
265
- * strspn - Calculate the length of the initial substring of @s which only
266
- * 	contain letters in @accept
267
- * @s: The string to be searched
268
- * @accept: The string to search for
269
- */
270
-size_t strspn(const char *s, const char *accept)
271
-{
272
-	const char *p;
273
-	const char *a;
274
-	size_t count = 0;
275
-
276
-	for (p = s; *p != '\0'; ++p) {
277
-		for (a = accept; *a != '\0'; ++a) {
278
-			if (*p == *a)
279
-				break;
280
-		}
281
-		if (*a == '\0')
282
-			return count;
283
-		++count;
284
-	}
285
-
286
-	return count;
287
-}
288
-#endif
289
-
290
-#ifndef __HAVE_ARCH_STRCSPN
291
-/**
292
- * strcspn - Calculate the length of the initial substring of @s which only
293
- * 	contain letters not in @reject
294
- * @s: The string to be searched
295
- * @accept: The string to search for
296
- */
297
-size_t strcspn(const char *s, const char *reject)
298
-{
299
-	const char *p;
300
-	const char *r;
301
-	size_t count = 0;
302
-
303
-	for (p = s; *p != '\0'; ++p) {
304
-		for (r = reject; *r != '\0'; ++r) {
305
-			if (*p == *r)
306
-				return count;
307
-		}
308
-		++count;
309
-	}
310
-
311
-	return count;
312
-}
313
-#endif
314
-
315
-#ifndef __HAVE_ARCH_STRPBRK
316
-/**
317
- * strpbrk - Find the first occurrence of a set of characters
318
- * @cs: The string to be searched
319
- * @ct: The characters to search for
320
- */
321
-char * strpbrk(const char * cs,const char * ct)
322
-{
323
-	const char *sc1,*sc2;
324
-
325
-	for( sc1 = cs; *sc1 != '\0'; ++sc1) {
326
-		for( sc2 = ct; *sc2 != '\0'; ++sc2) {
327
-			if (*sc1 == *sc2)
328
-				return (char *) sc1;
329
-		}
330
-	}
331
-	return NULL;
332
-}
333
-#endif
334
-
335
-#ifndef __HAVE_ARCH_STRTOK
336
-/**
337
- * strtok - Split a string into tokens
338
- * @s: The string to be searched
339
- * @ct: The characters to search for
340
- *
341
- * WARNING: strtok is deprecated, use strsep instead.
342
- */
343
-char * strtok(char * s,const char * ct)
344
-{
345
-	char *sbegin, *send;
346
-
347
-	sbegin  = s ? s : ___strtok;
348
-	if (!sbegin) {
349
-		return NULL;
350
-	}
351
-	sbegin += strspn(sbegin,ct);
352
-	if (*sbegin == '\0') {
353
-		___strtok = NULL;
354
-		return( NULL );
355
-	}
356
-	send = strpbrk( sbegin, ct);
357
-	if (send && *send != '\0')
358
-		*send++ = '\0';
359
-	___strtok = send;
360
-	return (sbegin);
361
-}
362
-#endif
363
-
364
-#ifndef __HAVE_ARCH_STRSEP
365
-/**
366
- * strsep - Split a string into tokens
367
- * @s: The string to be searched
368
- * @ct: The characters to search for
369
- *
370
- * strsep() updates @s to point after the token, ready for the next call.
371
- *
372
- * It returns empty tokens, too, behaving exactly like the libc function
373
- * of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
374
- * Same semantics, slimmer shape. ;)
375
- */
376
-char * strsep(char **s, const char *ct)
377
-{
378
-	char *sbegin = *s, *end;
379
-
380
-	if (sbegin == NULL)
381
-		return NULL;
382
-
383
-	end = strpbrk(sbegin, ct);
384
-	if (end)
385
-		*end++ = '\0';
386
-	*s = end;
387
-
388
-	return sbegin;
389
-}
390
-#endif
391
-
392 199
 #ifndef __HAVE_ARCH_MEMSET
393 200
 /**
394 201
  * memset - Fill a region of memory with the given value
@@ -409,30 +216,6 @@ void * memset(void * s,int c,size_t count)
409 216
 }
410 217
 #endif
411 218
 
412
-#ifndef __HAVE_ARCH_BCOPY
413
-/**
414
- * bcopy - Copy one area of memory to another
415
- * @src: Where to copy from
416
- * @dest: Where to copy to
417
- * @count: The size of the area.
418
- *
419
- * Note that this is the same as memcpy(), with the arguments reversed.
420
- * memcpy() is the standard, bcopy() is a legacy BSD function.
421
- *
422
- * You should not use this function to access IO space, use memcpy_toio()
423
- * or memcpy_fromio() instead.
424
- */
425
-char * bcopy(const char * src, char * dest, int count)
426
-{
427
-	char *tmp = dest;
428
-
429
-	while (count--)
430
-		*tmp++ = *src++;
431
-
432
-	return dest;
433
-}
434
-#endif
435
-
436 219
 #ifndef __HAVE_ARCH_MEMCPY
437 220
 /**
438 221
  * memcpy - Copy one area of memory to another
@@ -503,30 +286,6 @@ int memcmp(const void * cs,const void * ct,size_t count)
503 286
 }
504 287
 #endif
505 288
 
506
-#ifndef __HAVE_ARCH_MEMSCAN
507
-/**
508
- * memscan - Find a character in an area of memory.
509
- * @addr: The memory area
510
- * @c: The byte to search for
511
- * @size: The size of the area.
512
- *
513
- * returns the address of the first occurrence of @c, or 1 byte past
514
- * the area if @c is not found
515
- */
516
-void * memscan(void * addr, int c, size_t size)
517
-{
518
-	unsigned char * p = (unsigned char *) addr;
519
-
520
-	while (size) {
521
-		if (*p == c)
522
-			return (void *) p;
523
-		p++;
524
-		size--;
525
-	}
526
-  	return (void *) p;
527
-}
528
-#endif
529
-
530 289
 #ifndef __HAVE_ARCH_STRSTR
531 290
 /**
532 291
  * strstr - Find the first substring in a %NUL terminated string
@@ -576,17 +335,17 @@ void * memchr(const void *s, int c, size_t n)
576 335
 
577 336
 char * strndup(const char *s, size_t n)
578 337
 {
579
-	size_t len = strlen(s);
580
-	char *new;
581
-
582
-	if (len>n)
583
-		len = n;
584
-	new = malloc(len+1);
585
-	if (new) {
586
-		new[len] = '\0';
587
-		memcpy(new,s,len);
588
-	}
589
-	return new;
338
+        size_t len = strlen(s);
339
+        char *new;
340
+
341
+        if (len>n)
342
+                len = n;
343
+        new = malloc(len+1);
344
+        if (new) {
345
+                new[len] = '\0';
346
+                memcpy(new,s,len);
347
+        }
348
+        return new;
590 349
 }
591 350
 
592 351
 char * strdup(const char *s) {

+ 273
- 0
src/core/stringextra.c 查看文件

@@ -0,0 +1,273 @@
1
+/*
2
+ *  Copyright (C) 1991, 1992  Linus Torvalds
3
+ *  Copyright (C) 2004 Tobias Lorenz
4
+ *
5
+ *  string handling functions
6
+ *  based on linux/lib/string.c
7
+ *
8
+ * This program is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License version 2 as
10
+ * published by the Free Software Foundation.
11
+ */
12
+
13
+/*
14
+ * stupid library routines.. The optimized versions should generally be found
15
+ * as inline code in <asm-xx/string.h>
16
+ *
17
+ * These are buggy as well..
18
+ *
19
+ * * Fri Jun 25 1999, Ingo Oeser <ioe@informatik.tu-chemnitz.de>
20
+ * -  Added strsep() which will replace strtok() soon (because strsep() is
21
+ *    reentrant and should be faster). Use only strsep() in new code, please.
22
+ */
23
+
24
+/*
25
+ * these are the standard string functions that are currently not used by
26
+ * any code in etherboot. put into a separate file to avoid linking them in
27
+ * with the rest of string.o
28
+ * if anything ever does want to use a function of these, consider moving
29
+ * the function in question back into string.c
30
+ */
31
+ 
32
+#include <stdint.h>
33
+#include <stdlib.h>
34
+#include <string.h>
35
+#include <ctype.h>
36
+
37
+/* *** FROM string.c *** */
38
+
39
+#ifndef __HAVE_ARCH_STRNICMP
40
+/**
41
+ * strnicmp - Case insensitive, length-limited string comparison
42
+ * @s1: One string
43
+ * @s2: The other string
44
+ * @len: the maximum number of characters to compare
45
+ */
46
+int strnicmp(const char *s1, const char *s2, size_t len)
47
+{
48
+	/* Yes, Virginia, it had better be unsigned */
49
+	unsigned char c1, c2;
50
+
51
+	c1 = 0;	c2 = 0;
52
+	if (len) {
53
+		do {
54
+			c1 = *s1; c2 = *s2;
55
+			s1++; s2++;
56
+			if (!c1)
57
+				break;
58
+			if (!c2)
59
+				break;
60
+			if (c1 == c2)
61
+				continue;
62
+			c1 = tolower(c1);
63
+			c2 = tolower(c2);
64
+			if (c1 != c2)
65
+				break;
66
+		} while (--len);
67
+	}
68
+	return (int)c1 - (int)c2;
69
+}
70
+#endif
71
+
72
+char * ___strtok;
73
+
74
+#ifndef __HAVE_ARCH_STRNCAT
75
+/**
76
+ * strncat - Append a length-limited, %NUL-terminated string to another
77
+ * @dest: The string to be appended to
78
+ * @src: The string to append to it
79
+ * @count: The maximum numbers of bytes to copy
80
+ *
81
+ * Note that in contrast to strncpy, strncat ensures the result is
82
+ * terminated.
83
+ */
84
+char * strncat(char *dest, const char *src, size_t count)
85
+{
86
+	char *tmp = dest;
87
+
88
+	if (count) {
89
+		while (*dest)
90
+			dest++;
91
+		while ((*dest++ = *src++)) {
92
+			if (--count == 0) {
93
+				*dest = '\0';
94
+				break;
95
+			}
96
+		}
97
+	}
98
+
99
+	return tmp;
100
+}
101
+#endif
102
+
103
+#ifndef __HAVE_ARCH_STRSPN
104
+/**
105
+ * strspn - Calculate the length of the initial substring of @s which only
106
+ * 	contain letters in @accept
107
+ * @s: The string to be searched
108
+ * @accept: The string to search for
109
+ */
110
+size_t strspn(const char *s, const char *accept)
111
+{
112
+	const char *p;
113
+	const char *a;
114
+	size_t count = 0;
115
+
116
+	for (p = s; *p != '\0'; ++p) {
117
+		for (a = accept; *a != '\0'; ++a) {
118
+			if (*p == *a)
119
+				break;
120
+		}
121
+		if (*a == '\0')
122
+			return count;
123
+		++count;
124
+	}
125
+
126
+	return count;
127
+}
128
+#endif
129
+
130
+#ifndef __HAVE_ARCH_STRCSPN
131
+/**
132
+ * strcspn - Calculate the length of the initial substring of @s which only
133
+ * 	contain letters not in @reject
134
+ * @s: The string to be searched
135
+ * @accept: The string to search for
136
+ */
137
+size_t strcspn(const char *s, const char *reject)
138
+{
139
+	const char *p;
140
+	const char *r;
141
+	size_t count = 0;
142
+
143
+	for (p = s; *p != '\0'; ++p) {
144
+		for (r = reject; *r != '\0'; ++r) {
145
+			if (*p == *r)
146
+				return count;
147
+		}
148
+		++count;
149
+	}
150
+
151
+	return count;
152
+}
153
+#endif
154
+
155
+#ifndef __HAVE_ARCH_STRPBRK
156
+/**
157
+ * strpbrk - Find the first occurrence of a set of characters
158
+ * @cs: The string to be searched
159
+ * @ct: The characters to search for
160
+ */
161
+char * strpbrk(const char * cs,const char * ct)
162
+{
163
+	const char *sc1,*sc2;
164
+
165
+	for( sc1 = cs; *sc1 != '\0'; ++sc1) {
166
+		for( sc2 = ct; *sc2 != '\0'; ++sc2) {
167
+			if (*sc1 == *sc2)
168
+				return (char *) sc1;
169
+		}
170
+	}
171
+	return NULL;
172
+}
173
+#endif
174
+
175
+#ifndef __HAVE_ARCH_STRTOK
176
+/**
177
+ * strtok - Split a string into tokens
178
+ * @s: The string to be searched
179
+ * @ct: The characters to search for
180
+ *
181
+ * WARNING: strtok is deprecated, use strsep instead.
182
+ */
183
+char * strtok(char * s,const char * ct)
184
+{
185
+	char *sbegin, *send;
186
+
187
+	sbegin  = s ? s : ___strtok;
188
+	if (!sbegin) {
189
+		return NULL;
190
+	}
191
+	sbegin += strspn(sbegin,ct);
192
+	if (*sbegin == '\0') {
193
+		___strtok = NULL;
194
+		return( NULL );
195
+	}
196
+	send = strpbrk( sbegin, ct);
197
+	if (send && *send != '\0')
198
+		*send++ = '\0';
199
+	___strtok = send;
200
+	return (sbegin);
201
+}
202
+#endif
203
+
204
+#ifndef __HAVE_ARCH_STRSEP
205
+/**
206
+ * strsep - Split a string into tokens
207
+ * @s: The string to be searched
208
+ * @ct: The characters to search for
209
+ *
210
+ * strsep() updates @s to point after the token, ready for the next call.
211
+ *
212
+ * It returns empty tokens, too, behaving exactly like the libc function
213
+ * of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
214
+ * Same semantics, slimmer shape. ;)
215
+ */
216
+char * strsep(char **s, const char *ct)
217
+{
218
+	char *sbegin = *s, *end;
219
+
220
+	if (sbegin == NULL)
221
+		return NULL;
222
+
223
+	end = strpbrk(sbegin, ct);
224
+	if (end)
225
+		*end++ = '\0';
226
+	*s = end;
227
+
228
+	return sbegin;
229
+}
230
+#endif
231
+
232
+#ifndef __HAVE_ARCH_BCOPY
233
+/**
234
+ * bcopy - Copy one area of memory to another
235
+ * @src: Where to copy from
236
+ * @dest: Where to copy to
237
+ * @count: The size of the area.
238
+ *
239
+ * Note that this is the same as memcpy(), with the arguments reversed.
240
+ * memcpy() is the standard, bcopy() is a legacy BSD function.
241
+ *
242
+ * You should not use this function to access IO space, use memcpy_toio()
243
+ * or memcpy_fromio() instead.
244
+ */
245
+char * bcopy(const char * src, char * dest, int count)
246
+{
247
+	return memmove(dest,src,count);
248
+}
249
+#endif
250
+
251
+#ifndef __HAVE_ARCH_MEMSCAN
252
+/**
253
+ * memscan - Find a character in an area of memory.
254
+ * @addr: The memory area
255
+ * @c: The byte to search for
256
+ * @size: The size of the area.
257
+ *
258
+ * returns the address of the first occurrence of @c, or 1 byte past
259
+ * the area if @c is not found
260
+ */
261
+void * memscan(const void * addr, int c, size_t size)
262
+{
263
+	unsigned char * p = (unsigned char *) addr;
264
+
265
+	while (size) {
266
+		if (*p == c)
267
+			return (void *) p;
268
+		p++;
269
+		size--;
270
+	}
271
+  	return (void *) p;
272
+}
273
+#endif

+ 1
- 1
src/crypto/axtls/bigint.c 查看文件

@@ -58,7 +58,7 @@
58 58
 
59 59
 static bigint *bi_int_multiply(BI_CTX *ctx, bigint *bi, comp i);
60 60
 static bigint *bi_int_divide(BI_CTX *ctx, bigint *biR, comp denom);
61
-static bigint *alloc(BI_CTX *ctx, int size);
61
+static bigint __malloc *alloc(BI_CTX *ctx, int size);
62 62
 static bigint *trim(bigint *bi);
63 63
 static void more_comps(bigint *bi, int n);
64 64
 #if defined(CONFIG_BIGINT_KARATSUBA) || defined(CONFIG_BIGINT_BARRETT) || \

+ 1
- 1
src/crypto/cryptoLayer.h 查看文件

@@ -31,7 +31,7 @@ typedef void psPool_t;
31 31
 
32 32
 #define sslAssert( ... ) assert ( __VA_ARGS__ )
33 33
 
34
-static inline __attribute__ (( always_inline )) void *
34
+static inline __attribute__ (( always_inline )) void * __malloc
35 35
 psMalloc ( psPool_t *pool __unused, size_t len ) {
36 36
 	return malloc ( len );
37 37
 }

+ 25
- 0
src/include/compiler.h 查看文件

@@ -279,6 +279,31 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr,
279 279
 /** Apply standard C calling conventions */
280 280
 #define __cdecl __attribute__ (( cdecl , regparm(0) ))
281 281
 
282
+/**
283
+ * Declare a function as pure - i.e. without side effects
284
+ */
285
+#define __pure __attribute__ (( pure ))
286
+
287
+/**
288
+ * Declare a function as const - i.e. it does not access global memory
289
+ * (including dereferencing pointers passed to it) at all.
290
+ * Must also not call any non-const functions.
291
+ */
292
+#define __const __attribute__ (( const ))
293
+
294
+/**
295
+ * Declare a function's pointer parameters as non-null - i.e. force
296
+ * compiler to check pointers at compile time and enable possible
297
+ * optimizations based on that fact
298
+ */
299
+#define __nonnull __attribute__ (( nonnull ))
300
+
301
+/**
302
+ * Declare a pointer returned by a function as a unique memory address
303
+ * as returned by malloc-type functions.
304
+ */
305
+#define __malloc __attribute__ (( malloc ))
306
+
282 307
 /**
283 308
  * Declare a function as used.
284 309
  *

+ 1
- 1
src/include/gpxe/dhcp.h 查看文件

@@ -507,7 +507,7 @@ extern void register_dhcp_options ( struct dhcp_option_block *options );
507 507
 extern void unregister_dhcp_options ( struct dhcp_option_block *options );
508 508
 extern void init_dhcp_options ( struct dhcp_option_block *options,
509 509
 				void *data, size_t max_len );
510
-extern struct dhcp_option_block * alloc_dhcp_options ( size_t max_len );
510
+extern struct dhcp_option_block * __malloc alloc_dhcp_options ( size_t max_len );
511 511
 extern struct dhcp_option *
512 512
 set_dhcp_option ( struct dhcp_option_block *options, unsigned int tag,
513 513
 		  const void *data, size_t len );

+ 1
- 1
src/include/gpxe/iobuf.h 查看文件

@@ -161,7 +161,7 @@ static inline size_t iob_tailroom ( struct io_buffer *iobuf ) {
161 161
 	return ( iobuf->end - iobuf->tail );
162 162
 }
163 163
 
164
-extern struct io_buffer * alloc_iob ( size_t len );
164
+extern struct io_buffer * __malloc alloc_iob ( size_t len );
165 165
 extern void free_iob ( struct io_buffer *iobuf );
166 166
 extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );
167 167
 extern int iob_ensure_headroom ( struct io_buffer *iobuf, size_t len );

+ 2
- 2
src/include/gpxe/malloc.h 查看文件

@@ -19,7 +19,7 @@
19 19
 
20 20
 extern size_t freemem;
21 21
 
22
-extern void * alloc_memblock ( size_t size, size_t align );
22
+extern void * __malloc alloc_memblock ( size_t size, size_t align );
23 23
 extern void free_memblock ( void *ptr, size_t size );
24 24
 extern void mpopulate ( void *start, size_t len );
25 25
 extern void mdumpfree ( void );
@@ -35,7 +35,7 @@ extern void mdumpfree ( void );
35 35
  *
36 36
  * @c align must be a power of two.  @c size may not be zero.
37 37
  */
38
-static inline void * malloc_dma ( size_t size, size_t phys_align ) {
38
+static inline void * __malloc malloc_dma ( size_t size, size_t phys_align ) {
39 39
 	return alloc_memblock ( size, phys_align );
40 40
 }
41 41
 

+ 1
- 1
src/include/readline/readline.h 查看文件

@@ -7,6 +7,6 @@
7 7
  *
8 8
  */
9 9
 
10
-extern char * readline ( const char *prompt );
10
+extern char * __malloc readline ( const char *prompt );
11 11
 
12 12
 #endif /* _READLINE_H */

+ 3
- 3
src/include/stdlib.h 查看文件

@@ -20,10 +20,10 @@ extern unsigned long strtoul ( const char *p, char **endp, int base );
20 20
  ****************************************************************************
21 21
  */
22 22
 
23
-extern void * malloc ( size_t size );
23
+extern void * __malloc malloc ( size_t size );
24 24
 extern void * realloc ( void *old_ptr, size_t new_size );
25 25
 extern void free ( void *ptr );
26
-extern void * zalloc ( size_t len );
26
+extern void * __malloc zalloc ( size_t len );
27 27
 
28 28
 /**
29 29
  * Allocate cleared memory
@@ -38,7 +38,7 @@ extern void * zalloc ( size_t len );
38 38
  * function in zalloc(), since in most cases @c nmemb will be 1 and
39 39
  * doing the multiply is just wasteful.
40 40
  */
41
-static inline void * calloc ( size_t nmemb, size_t size ) {
41
+static inline void * __malloc calloc ( size_t nmemb, size_t size ) {
42 42
 	return zalloc ( nmemb * size );
43 43
 }
44 44
 

+ 27
- 27
src/include/string.h 查看文件

@@ -17,33 +17,33 @@
17 17
 #include <stddef.h>
18 18
 #include <bits/string.h>
19 19
 
20
-int strnicmp(const char *s1, const char *s2, size_t len);
21
-char * strcpy(char * dest,const char *src);
22
-char * strncpy(char * dest,const char *src,size_t count);
23
-char * strcat(char * dest, const char * src);
24
-char * strncat(char *dest, const char *src, size_t count);
25
-int __attribute__ (( pure )) strcmp(const char * cs,const char * ct);
26
-int __attribute__ (( pure )) strncmp(const char * cs,const char * ct,
27
-				     size_t count);
28
-char * strchr(const char * s, int c);
29
-char * strrchr(const char * s, int c);
30
-size_t strlen(const char * s);
31
-size_t strnlen(const char * s, size_t count);
32
-size_t strspn(const char *s, const char *accept);
33
-size_t strcspn(const char *s, const char *reject);
34
-char * strpbrk(const char * cs,const char * ct);
35
-char * strtok(char * s,const char * ct);
36
-char * strsep(char **s, const char *ct);
37
-void * memset(void * s,int c,size_t count);
38
-void * memmove(void * dest,const void *src,size_t count);
39
-int __attribute__ (( pure )) memcmp(const void * cs,const void * ct,
40
-				    size_t count);
41
-void * memscan(void * addr, int c, size_t size);
42
-char * strstr(const char * s1,const char * s2);
43
-void * memchr(const void *s, int c, size_t n);
44
-char * strdup(const char *s);
45
-char * strndup(const char *s, size_t n);
20
+int __pure strnicmp(const char *s1, const char *s2, size_t len) __nonnull;
21
+char * strcpy(char * dest,const char *src) __nonnull;
22
+char * strncpy(char * dest,const char *src,size_t count) __nonnull;
23
+char * strcat(char * dest, const char * src) __nonnull;
24
+char * strncat(char *dest, const char *src, size_t count) __nonnull;
25
+int __pure strcmp(const char * cs,const char * ct) __nonnull;
26
+int __pure strncmp(const char * cs,const char * ct,
27
+				     size_t count) __nonnull;
28
+char * __pure strchr(const char * s, int c) __nonnull;
29
+char * __pure strrchr(const char * s, int c) __nonnull;
30
+size_t __pure strlen(const char * s) __nonnull;
31
+size_t __pure strnlen(const char * s, size_t count) __nonnull;
32
+size_t __pure strspn(const char *s, const char *accept) __nonnull;
33
+size_t __pure strcspn(const char *s, const char *reject) __nonnull;
34
+char * __pure strpbrk(const char * cs,const char * ct) __nonnull;
35
+char * strtok(char * s,const char * ct) __nonnull;
36
+char * strsep(char **s, const char *ct) __nonnull;
37
+void * memset(void * s,int c,size_t count) __nonnull;
38
+void * memmove(void * dest,const void *src,size_t count) __nonnull;
39
+int __pure memcmp(const void * cs,const void * ct,
40
+				    size_t count) __nonnull;
41
+void * __pure memscan(const void * addr, int c, size_t size) __nonnull;
42
+char * __pure strstr(const char * s1,const char * s2) __nonnull;
43
+void * __pure memchr(const void *s, int c, size_t n) __nonnull;
44
+char * __malloc strdup(const char *s) __nonnull;
45
+char * __malloc strndup(const char *s, size_t n) __nonnull;
46 46
 
47
-extern const char * strerror ( int errno );
47
+extern const char * __pure strerror ( int errno );
48 48
 
49 49
 #endif /* ETHERBOOT_STRING */

+ 3
- 4
src/net/ipv4.c 查看文件

@@ -39,10 +39,9 @@ static LIST_HEAD ( frag_buffers );
39 39
  * @v gateway		Gateway address (or @c INADDR_NONE for no gateway)
40 40
  * @ret miniroute	Routing table entry, or NULL
41 41
  */
42
-static struct ipv4_miniroute * add_ipv4_miniroute ( struct net_device *netdev,
43
-						    struct in_addr address,
44
-						    struct in_addr netmask,
45
-						    struct in_addr gateway ) {
42
+static struct ipv4_miniroute * __malloc
43
+add_ipv4_miniroute ( struct net_device *netdev, struct in_addr address,
44
+		     struct in_addr netmask, struct in_addr gateway ) {
46 45
 	struct ipv4_miniroute *miniroute;
47 46
 
48 47
 	DBG ( "IPv4 add %s", inet_ntoa ( address ) );

+ 4
- 5
src/net/ipv6.c 查看文件

@@ -52,11 +52,10 @@ static LIST_HEAD ( miniroutes );
52 52
  * @v gateway		Gateway address (or ::0 for no gateway)
53 53
  * @ret miniroute	Routing table entry, or NULL
54 54
  */
55
-static struct ipv6_miniroute * add_ipv6_miniroute ( struct net_device *netdev,
56
-						    struct in6_addr prefix,
57
-						    int prefix_len,
58
-						    struct in6_addr address,
59
-						    struct in6_addr gateway ) {
55
+static struct ipv6_miniroute * __malloc 
56
+add_ipv6_miniroute ( struct net_device *netdev, struct in6_addr prefix,
57
+		     int prefix_len, struct in6_addr address,
58
+		     struct in6_addr gateway ) {
60 59
 	struct ipv6_miniroute *miniroute;
61 60
 	
62 61
 	miniroute = malloc ( sizeof ( *miniroute ) );

+ 1
- 1
src/net/tls.c 查看文件

@@ -1044,7 +1044,7 @@ static void tls_hmac ( struct tls_session *tls __unused,
1044 1044
  * @ret plaintext_len	Length of plaintext record
1045 1045
  * @ret plaintext	Allocated plaintext record
1046 1046
  */
1047
-static void * tls_assemble_stream ( struct tls_session *tls,
1047
+static void * __malloc tls_assemble_stream ( struct tls_session *tls,
1048 1048
 				    const void *data, size_t len,
1049 1049
 				    void *digest, size_t *plaintext_len ) {
1050 1050
 	size_t mac_len = tls->tx_cipherspec.digest->digestsize;

正在加载...
取消
保存