| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ssp.h,v 1.5 2011/01/19 19:21:29 christos Exp $ */ | | 1 | /* $NetBSD: ssp.h,v 1.6 2011/01/20 02:58:17 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Christos Zoulas. | | 8 | * by Christos Zoulas. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -33,27 +33,32 @@ | | | @@ -33,27 +33,32 @@ |
33 | | | 33 | |
34 | #include <sys/cdefs.h> | | 34 | #include <sys/cdefs.h> |
35 | | | 35 | |
36 | #if !defined(__cplusplus) | | 36 | #if !defined(__cplusplus) |
37 | # if _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 && __GNUC_PREREQ__(4, 1) | | 37 | # if _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 && __GNUC_PREREQ__(4, 1) |
38 | # if _FORTIFY_SOURCE > 1 | | 38 | # if _FORTIFY_SOURCE > 1 |
39 | # define __SSP_FORTIFY_LEVEL 2 | | 39 | # define __SSP_FORTIFY_LEVEL 2 |
40 | # else | | 40 | # else |
41 | # define __SSP_FORTIFY_LEVEL 1 | | 41 | # define __SSP_FORTIFY_LEVEL 1 |
42 | # endif | | 42 | # endif |
43 | # endif | | 43 | # endif |
44 | #endif | | 44 | #endif |
45 | | | 45 | |
46 | #define __ssp_weak_name(fun) _ ## fun | | 46 | #ifdef _NAMESPACE_H_ |
| | | 47 | #define __ssp_weak_name(fun) _sys ## fun |
| | | 48 | #else |
| | | 49 | #define __ssp_weak_name(fun) _sys_ ## fun |
| | | 50 | #endif |
| | | 51 | |
47 | #define __ssp_inline static __inline __attribute__((__always_inline__)) | | 52 | #define __ssp_inline static __inline __attribute__((__always_inline__)) |
48 | | | 53 | |
49 | #define __ssp_bos(ptr) __builtin_object_size(ptr, __SSP_FORTIFY_LEVEL > 1) | | 54 | #define __ssp_bos(ptr) __builtin_object_size(ptr, __SSP_FORTIFY_LEVEL > 1) |
50 | #define __ssp_bos0(ptr) __builtin_object_size(ptr, 0) | | 55 | #define __ssp_bos0(ptr) __builtin_object_size(ptr, 0) |
51 | | | 56 | |
52 | #define __ssp_redirect_raw(rtype, fun, args, call, bos) \ | | 57 | #define __ssp_redirect_raw(rtype, fun, args, call, bos) \ |
53 | rtype __ssp_weak_name(fun) args; \ | | 58 | rtype __ssp_weak_name(fun) args; \ |
54 | __ssp_inline rtype fun args; \ | | 59 | __ssp_inline rtype fun args; \ |
55 | __ssp_inline rtype fun args { \ | | 60 | __ssp_inline rtype fun args { \ |
56 | if (bos(__buf) != (size_t)-1 && __len > bos(__buf)) \ | | 61 | if (bos(__buf) != (size_t)-1 && __len > bos(__buf)) \ |
57 | __chk_fail(); \ | | 62 | __chk_fail(); \ |
58 | return __ssp_weak_name(fun) call; \ | | 63 | return __ssp_weak_name(fun) call; \ |
59 | } | | 64 | } |