aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-07-10 20:58:33 +0000
committerChristopher Faylor <me@cgf.cx>2013-07-10 20:58:33 +0000
commit41f9a410cc30786e7787553113610ed4c898f5c4 (patch)
tree2778f9bf1cf1d5484fd639acdc49db6aefe8516b
parentb5c0f49c1393ac336cd9f0724449f28ebb0564df (diff)
downloadnewlib-41f9a410cc30786e7787553113610ed4c898f5c4.zip
newlib-41f9a410cc30786e7787553113610ed4c898f5c4.tar.gz
newlib-41f9a410cc30786e7787553113610ed4c898f5c4.tar.bz2
* 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.
-rw-r--r--winsup/cygwin/ChangeLog8
-rwxr-xr-xwinsup/cygwin/gentls_offsets20
-rw-r--r--winsup/cygwin/thread.cc10
3 files changed, 24 insertions, 14 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 0aa3455..7eb8f07 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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.
diff --git a/winsup/cygwin/gentls_offsets b/winsup/cygwin/gentls_offsets
index d2400bb..e4543f5 100755
--- a/winsup/cygwin/gentls_offsets
+++ b/winsup/cygwin/gentls_offsets
@@ -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;
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 0d5ded6..450888d 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -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)
{