stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject [PATCH] errors passing void* to munmap, mprotect
Date Mon, 31 Jul 2006 22:09:03 GMT
I'm seeing the errors below when compiling alloc.cpp with Sun C++ 5.8
on Solaris.

By default Solaris declares munmap() et al to take caddr_t where POSIX
requires void* as the argument. There are two ways to deal with this:

1. Define the appropriate feature macro to enable POSIX conformance
(_POSIX_C_SOURCE).

2. Use the _RWSTD_MUNMAP_ARG1_T config macro.

Option (1) will work on all POSIX-compliant systems but may fail on
legacy (non-POSIX) platforms. Option (2) should work everywhere.
Attached is a patch that implements option (2). In addition, the
renames variables according to convention and silences some 64-bit
compatibility warnings. Tested with gcc and Sun C++ on Solaris and
XLC++ on Linux/PowerPC.

Unless someone (Farid?) sees a problem with the patch I will commit
it tomorrow.

Martin

Here's the ChangeLog:
2006-07-31  Martin Sebor  <sebor@roguewave.com>

	* alloc.cpp (CaddrT): New type.
	(munmap): Changed first argument from void* to CaddrT.
	(_rw_table, _rw_table_size, _rw_table_max_size): Renamed from
	table_, table_size_, and table_max_size_ according to the naming
	convention.
	(MemRWGuard::caddr_): Changed type to CaddrT and renamed from
	addr_.
	(_rw_table_free, _rw_table_grow, _rw_table_insert,
	_rw_table_remove, _rw_find_by_addr): Type and naming changes
	according to the above.
	(MAP_FAILED): Changed to a macro.
	(mmap, mprotect): Changed to return/take CaddrT rather than
	void*.
	Removed unnecessary casts.
	(_rw_table_remove): Silenced Sun C++ 5.8 Warning: Conversion
	of 64 bit type value to "char" causes truncation.


CC -c -D_RWSTDDEBUG    -D_RWSTD_USE_CONFIG 
-I/build2/batman/5.0.0/builds/32967674/source-buildspace/include 
-I/build2/batman/5.0.0/builds/32967674/source-buildspace/build/include 
-I/build2/batman/5.0.0/builds/32967674/source-buildspace/../rwtest 
-I/build2/batman/5.0.0/builds/32967674/source-buildspace/tests/include 
-library=%none -g  +w 
/build2/batman/5.0.0/builds/32967674/source-buildspace/tests/src/alloc.cpp
"/build2/batman/5.0.0/builds/32967674/source-buildspace/tests/src/alloc.cpp", 
line 254: Error: Formal argument 1 of type char* in call to 
mprotect(char*, unsigned, int) is being passed void*.
"/build2/batman/5.0.0/builds/32967674/source-buildspace/tests/src/alloc.cpp", 
line 261: Error: Formal argument 1 of type char* in call to 
mprotect(char*, unsigned, int) is being passed void*.
"/build2/batman/5.0.0/builds/32967674/source-buildspace/tests/src/alloc.cpp", 
line 280: Error: Formal argument 1 of type char* in call to 
munmap(char*, unsigned) is being passed Pair*.
"/build2/batman/5.0.0/builds/32967674/source-buildspace/tests/src/alloc.cpp", 
line 313: Error: Formal argument 1 of type char* in call to 
mprotect(char*, unsigned, int) is being passed void*.
"/build2/batman/5.0.0/builds/32967674/source-buildspace/tests/src/alloc.cpp", 
line 393: Error: Formal argument 1 of type char* in call to 
mprotect(char*, unsigned, int) is being passed void*.
"/build2/batman/5.0.0/builds/32967674/source-buildspace/tests/src/alloc.cpp", 
line 426: Error: Formal argument 1 of type char* in call to 
munmap(char*, unsigned) is being passed Blocks*.
"/build2/batman/5.0.0/builds/32967674/source-buildspace/tests/src/alloc.cpp", 
line 598: Error: Formal argument 1 of type char* in call to 
munmap(char*, unsigned) is being passed void*.
7 Error(s) detected.

Mime
View raw message