debuggers.hg
changeset 20945:3c3759296796
libxc: Reorder functions in xc_misc.c to avoid weak symbol problem
Using a function, and then declaring it weak later, has undefined
behaviour:
cc1: warnings being treated as errors
xc_misc.c:388: error: weak declaration of 'xc_map_foreign_bulk'
after first use results in unspecified behavior
So swap the functions xc_map_foreign_pages and xc_map_foreign_bulk.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Using a function, and then declaring it weak later, has undefined
behaviour:
cc1: warnings being treated as errors
xc_misc.c:388: error: weak declaration of 'xc_map_foreign_bulk'
after first use results in unspecified behavior
So swap the functions xc_map_foreign_pages and xc_map_foreign_bulk.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Thu Feb 04 13:16:39 2010 +0000 (2010-02-04) |
parents | 8c1889297084 |
children | 7b751b0e6f1b |
files | tools/libxc/xc_misc.c |
line diff
1.1 --- a/tools/libxc/xc_misc.c Thu Feb 04 13:16:03 2010 +0000 1.2 +++ b/tools/libxc/xc_misc.c Thu Feb 04 13:16:39 2010 +0000 1.3 @@ -370,37 +370,6 @@ int xc_hvm_set_mem_type( 1.4 } 1.5 1.6 1.7 -void *xc_map_foreign_pages(int xc_handle, uint32_t dom, int prot, 1.8 - const xen_pfn_t *arr, int num) 1.9 -{ 1.10 - void *res; 1.11 - int i, *err; 1.12 - 1.13 - if (num < 0) { 1.14 - errno = -EINVAL; 1.15 - return NULL; 1.16 - } 1.17 - 1.18 - err = malloc(num * sizeof(*err)); 1.19 - if (!err) 1.20 - return NULL; 1.21 - 1.22 - res = xc_map_foreign_bulk(xc_handle, dom, prot, arr, err, num); 1.23 - if (res) { 1.24 - for (i = 0; i < num; i++) { 1.25 - if (err[i]) { 1.26 - errno = -err[i]; 1.27 - munmap(res, num * PAGE_SIZE); 1.28 - res = NULL; 1.29 - break; 1.30 - } 1.31 - } 1.32 - } 1.33 - 1.34 - free(err); 1.35 - return res; 1.36 -} 1.37 - 1.38 /* stub for all not yet converted OSes */ 1.39 void * 1.40 #ifdef __GNUC__ 1.41 @@ -445,6 +414,37 @@ xc_map_foreign_bulk(int xc_handle, uint3 1.42 return ret; 1.43 } 1.44 1.45 +void *xc_map_foreign_pages(int xc_handle, uint32_t dom, int prot, 1.46 + const xen_pfn_t *arr, int num) 1.47 +{ 1.48 + void *res; 1.49 + int i, *err; 1.50 + 1.51 + if (num < 0) { 1.52 + errno = -EINVAL; 1.53 + return NULL; 1.54 + } 1.55 + 1.56 + err = malloc(num * sizeof(*err)); 1.57 + if (!err) 1.58 + return NULL; 1.59 + 1.60 + res = xc_map_foreign_bulk(xc_handle, dom, prot, arr, err, num); 1.61 + if (res) { 1.62 + for (i = 0; i < num; i++) { 1.63 + if (err[i]) { 1.64 + errno = -err[i]; 1.65 + munmap(res, num * PAGE_SIZE); 1.66 + res = NULL; 1.67 + break; 1.68 + } 1.69 + } 1.70 + } 1.71 + 1.72 + free(err); 1.73 + return res; 1.74 +} 1.75 + 1.76 /* 1.77 * Local variables: 1.78 * mode: C