This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fifth draft of the Y2038 design document
- From: Zack Weinberg <zackw at panix dot com>
- To: Albert ARIBAUD <albert dot aribaud at 3adev dot fr>
- Cc: Joseph Myers <joseph at codesourcery dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 8 Mar 2017 08:35:30 -0500
- Subject: Re: Fifth draft of the Y2038 design document
- Authentication-results: sourceware.org; auth=none
- References: <20170222090511.48be22ed.albert.aribaud@3adev.fr> <alpine.DEB.2.20.1702221647560.8704@digraph.polyomino.org.uk> <20170222194855.7581deca.albert.aribaud@3adev.fr> <alpine.DEB.2.20.1702222055440.24643@digraph.polyomino.org.uk> <20170223131634.06fa476c.albert.aribaud@3adev.fr> <alpine.DEB.2.20.1702231418320.15395@digraph.polyomino.org.uk> <20170223165052.1b494e3a.albert.aribaud@3adev.fr> <20170308132732.11b1edbc.albert.aribaud@3adev.fr>
On Wed, Mar 8, 2017 at 7:27 AM, Albert ARIBAUD <albert.aribaud@3adev.fr> wrote:
>
> Assume one single source file (say, app.c) which includes <time.h> and
> refers to 'clock_gettime'. This source code is compiled into two object
> modules, one with -DTIME_BITS=64 (sayn app64.o) and one without (say,
> app32.o). Both object modules expect to be linked and run against the
> (same) GLIBC dynamic library. For the app32.o module, we expect its
> call to 'clock_gettime' to end up executing '__clock_gettime' while for
> the app64.o module, we expect its 'clock_gettime' call to end up
> executing '__clock_gettime64'.
>
> My question is, how exactly can the GLIBC API make app32.o use
> '__clock_gettime' and app64.o use '__clock_gettime64' when app.c refers
> to 'clock_gettime'?
This is what the __REDIRECT macros are for. Look at the existing
logic in the headers that handles __USE_FILE_OFFSET64: for instance,
in unistd.h
#ifndef __USE_FILE_OFFSET64
extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW;
#else
# ifdef __REDIRECT_NTH
extern __off64_t __REDIRECT_NTH (lseek,
(int __fd, __off64_t __offset, int __whence),
lseek64);
# else
# define lseek lseek64
# endif
#endif
(The fallback to #define hasn't been tested in at least a decade and
there's an argument for scrapping it.)
zw