* gentlsoffsets: Clean up a little.

* thread.cc (semaphore::_fixup_after_fork): Report on potential problem
parameter.  Make sure that currentvalue is never zero.
(semaphore::init): Make cosmetic change.
This commit is contained in:
Christopher Faylor 2013-07-10 20:58:33 +00:00
parent b5c0f49c13
commit 41f9a410cc
3 changed files with 24 additions and 14 deletions

View File

@ -1,3 +1,11 @@
2013-07-10 Christopher Faylor <me.cygwin2013@cgf.cx>
* gentlsoffsets: Clean up a little.
* thread.cc (semaphore::_fixup_after_fork): Report on potential problem
parameter. Make sure that currentvalue is never zero.
(semaphore::init): Make cosmetic change.
2013-07-10 Corinna Vinschen <corinna@vinschen.de>
* cygwin.sc.in (.text.*): Fold into .text on all platforms.

View File

@ -14,9 +14,8 @@ my $tgt = shift;
# Another method which doesn't requires to run an executable would be to
# generate assembler code accessing the various struct members and analyzing
# it, but that's arguably a lot more effort.
my $tgt_opt='-m64';
$tgt_opt='-m32' unless ($tgt eq 'x86_64');
open(TLS, $tls) or die "$0: couldn't open tls file \"$tls\" - $!\n";
my $tgt_opt = $tgt eq 'x86_64' ? '-m64' : '-m32';
open TLS, '<', $tls or die "$0: couldn't open tls file \"$tls\" - $!\n";
my $struct = '';
my @fields = ();
my $def = '';
@ -48,7 +47,7 @@ foreach ($tls =~ /^.*\n/mg) {
}
}
close TLS;
open(TMP, '>', "/tmp/$$.cc") or die "$0: couldn't open temporary index file \"/tmp/$$.c\" - $!\n";
open TMP, '>', "/tmp/$$.cc" or die "$0: couldn't open temporary index file \"/tmp/$$.c\" - $!\n";
print TMP <<EOF;
#define __INSIDE_CYGWIN__
#ifndef __x86_64__
@ -68,8 +67,8 @@ main(int argc, char **argv)
{
$struct *foo;
# define foo_beg ((char *) foo)
# define offset(f) ((int) (((char *) &(foo->f)) - foo_beg) - CYGTLS_PADSIZE)
# define poffset(f) (((char *) &(foo->f)) - ((char *) foo))
# define offset(f) ((unsigned)((int) (((char *) &(foo->f)) - foo_beg) - CYGTLS_PADSIZE))
# define poffset(f) ((unsigned)(((char *) &(foo->f)) - ((char *) foo)))
EOF
print TMP 'puts ("//;# autogenerated: Do not edit.\n");', "\n\n";
print TMP "printf (\"//; \$tls::start_offset = -%d;\\n\", CYGTLS_PADSIZE);\n";
@ -89,12 +88,15 @@ EOF
}
EOF
close TMP;
system @ARGV, '-o', "/tmp/$$-1.cc", '-E', "/tmp/$$.cc";
my @avoid_headers = qw'-D_XMMINTRIN_H_INCLUDED -D_ADXINTRIN_H_INCLUDED -D_EMMINTRIN_H_INCLUDED -D_X86INTRIN_H_INCLUDED';
my @cmd = (@ARGV, @avoid_headers, '-o', "/tmp/$$-1.cc", '-E', "/tmp/$$.cc");
$ENV{CCWRAP_VERBOSE}=1;
system @cmd;
system 'g++', "$tgt_opt", '-o', "/tmp/$$.a.out", "/tmp/$$-1.cc" and
($? == 127 && system 'c++', "$tgt_opt", '-o', "/tmp/$$.a.out", "/tmp/$$-1.cc") and
die "$0: couldn't generate executable for offset calculation \"/tmp/$$.a.out\" - $!\n";
open(TLS_OUT, '>', $tls_out) or die "$0: couldn't open tls index file \"$tls_out\" - $!\n";
open(OFFS, "/tmp/$$.a.out|") or die "$0: couldn't run \"/tmp/$$.a.out\" - $!\n";
open TLS_OUT, '>', $tls_out or die "$0: couldn't open tls index file \"$tls_out\" - $!\n";
open OFFS, '-|', "/tmp/$$.a.out" or die "$0: couldn't run \"/tmp/$$.a.out\" - $!\n";
print TLS_OUT <OFFS>;
close OFFS;
close TLS_OUT;

View File

@ -3529,11 +3529,13 @@ semaphore::_fixup_after_fork ()
if (shared == PTHREAD_PROCESS_PRIVATE)
{
pthread_printf ("sem %p", this);
if (!currentvalue)
currentvalue = 1;
/* FIXME: duplicate code here and in the constructor. */
this->win32_obj_id = ::CreateSemaphore (&sec_none_nih, currentvalue,
win32_obj_id = ::CreateSemaphore (&sec_none_nih, currentvalue,
INT32_MAX, NULL);
if (!win32_obj_id)
api_fatal ("failed to create new win32 semaphore, %E");
api_fatal ("failed to create new win32 semaphore, currentvalue %ld, %E", currentvalue);
}
}
@ -3557,9 +3559,7 @@ semaphore::init (sem_t *sem, int pshared, unsigned int value)
contents happen to be a valid pointer
*/
if (is_good_object (sem))
{
paranoid_printf ("potential attempt to reinitialise a semaphore");
}
paranoid_printf ("potential attempt to reinitialise a semaphore");
if (value > SEM_VALUE_MAX)
{