svn commit: trunk/uClibc/ldso/include

Peter Kjellerstedt peter.kjellerstedt at axis.com
Thu Feb 23 14:23:04 UTC 2006


The patch below breaks at least CRIS, and I suspect a couple 
of more architectures... The reason is that previously the 
code caused mmap() to be used whereas the never version uses
mmap2() (at least this is the case with CRIS). However, someone
made an assumption a long time ago that all architectures use
12 as page shift with mmap2() independent of the real value of 
PAGE_SHIFT. Unfortunately, this is not true...

I will commit a fix to make it possible to define MMAP2_PAGE_SHIFT 
in the architecture specific files, and do so for CRIS. However,
I cannot fix any other architectures, as I do not know which need
fixing (I suspect m68k might need it).

//Peter

> -----Original Message-----
> From: uclibc-cvs-bounces at uclibc.org 
> [mailto:uclibc-cvs-bounces at uclibc.org] On Behalf Of vapier at uclibc.org
> Sent: Wednesday, February 22, 2006 02:20
> To: uclibc-cvs at uclibc.org
> Subject: svn commit: trunk/uClibc/ldso/include
> 
> 
> Author: vapier
> Date: 2006-02-21 17:19:59 -0800 (Tue, 21 Feb 2006)
> New Revision: 14173
> 
> Log:
> Nicolas Bellido: switch up order of mmap preference to try 
> and fix arm eabi usage
> 
> Modified:
>    trunk/uClibc/ldso/include/dl-syscall.h
> 
> 
> Changeset:
> Modified: trunk/uClibc/ldso/include/dl-syscall.h
> ===================================================================
> --- trunk/uClibc/ldso/include/dl-syscall.h	2006-02-22 
> 01:03:55 UTC (rev 14172)
> +++ trunk/uClibc/ldso/include/dl-syscall.h	2006-02-22 
> 01:19:59 UTC (rev 14173)
> @@ -121,24 +121,49 @@
>  static inline _syscall2(int, _dl_gettimeofday, struct 
> timeval *, tv, struct timezone *, tz);
>  #endif
>  
> -#ifdef __NR_mmap
> -#ifndef _dl_MAX_ERRNO
> +
> +/* handle all the fun mmap intricacies */
> +#if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && 
> defined(__NR_mmap) || !defined(__NR_mmap2)
>  # define _dl_MAX_ERRNO 4096
> +# define _dl_mmap_check_error(__res) \
> +	(((long)__res) < 0 && ((long)__res) >= -_dl_MAX_ERRNO)
> +#else
> +# define MAP_FAILED ((void *) -1)
> +# define _dl_mmap_check_error(X) (((void *)X) == MAP_FAILED)
>  #endif
> -#define _dl_mmap_check_error(__res) \
> -	(((long)__res) < 0 && ((long)__res) >= -_dl_MAX_ERRNO)
>  
> -#ifdef __UCLIBC_MMAP_HAS_6_ARGS__
> -#define __NR__dl_mmap __NR_mmap
> +/* first try mmap(), syscall6() style */
> +#if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
> +
> +# define __NR__dl_mmap __NR_mmap
>  static inline _syscall6(void *, _dl_mmap, void *, start, 
> size_t, length,
>  		int, prot, int, flags, int, fd, off_t, offset);
> -#else
> -#define __NR__dl_mmap_real __NR_mmap
> -static inline _syscall1(void *, _dl_mmap_real, unsigned long 
> *, buffer);
>  
> +/* then try mmap2() */
> +#elif defined(__NR_mmap2)
> +
> +# define __NR___syscall_mmap2       __NR_mmap2
> +static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
> +		size_t, len, int, prot, int, flags, int, fd, 
> off_t, offset);
> +/* always 12, even on architectures where PAGE_SHIFT != 12 */
> +# define MMAP2_PAGE_SHIFT 12
>  static inline void * _dl_mmap(void * addr, unsigned long 
> size, int prot,
>  		int flags, int fd, unsigned long offset)
>  {
> +    if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
> +	return MAP_FAILED;
> +    return(__syscall_mmap2(addr, size, prot, flags,
> +		fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
> +}
> +
> +/* finally, fall back to mmap(), syscall1() style */
> +#elif defined(__NR_mmap)
> +
> +# define __NR__dl_mmap_real __NR_mmap
> +static inline _syscall1(void *, _dl_mmap_real, unsigned long 
> *, buffer);
> +static inline void * _dl_mmap(void * addr, unsigned long 
> size, int prot,
> +		int flags, int fd, unsigned long offset)
> +{
>  	unsigned long buffer[6];
>  
>  	buffer[0] = (unsigned long) addr;
> @@ -149,27 +174,9 @@
>  	buffer[5] = (unsigned long) offset;
>  	return (void *) _dl_mmap_real(buffer);
>  }
> -#endif
> -#elif defined __NR_mmap2
>  
> -#define MAP_FAILED	((void *) -1)
> -#define _dl_mmap_check_error(X) (((void *)X) == MAP_FAILED)
> -#define __NR___syscall_mmap2       __NR_mmap2
> -static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
> -		size_t, len, int, prot, int, flags, int, fd, 
> off_t, offset);
> -/*always 12, even on architectures where PAGE_SHIFT != 12 */
> -#define MMAP2_PAGE_SHIFT 12
> -static inline void * _dl_mmap(void * addr, unsigned long 
> size, int prot,
> -		int flags, int fd, unsigned long offset)
> -{
> -    if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
> -	return MAP_FAILED;
> -    return(__syscall_mmap2(addr, size, prot, flags,
> -		fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
> -}
>  #else
>  # error "Your architecture doesn't seem to provide mmap() !?"
>  #endif
>  
>  #endif /* _LD_SYSCALL_H_ */
> -
> 
> _______________________________________________
> uClibc-cvs mailing list
> uClibc-cvs at uclibc.org
> http://busybox.net/cgi-bin/mailman/listinfo/uclibc-cvs
> 



More information about the uClibc mailing list