~ubuntu-branches/ubuntu/wily/libtrio/wily-proposed

« back to all changes in this revision

Viewing changes to trionan.c

  • Committer: Package Import Robot
  • Author(s): Balint Reczey
  • Date: 2014-07-16 16:42:37 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140716164237-97kbsenzcbpn4nsg
Tags: 1.16+dfsg1-1
* New upstream release
  - Fixed accuracy problems on platforms with double-double support.
    (Closes: #747012)
* Exclude generated documentation from .orig tarball using debian/copyright
* Drop 0001-build-shared-lib.patch since it has been integrated upstream
* Update mangling in debian/watch
* Bump .so version and library package name
* Migrate to symbols file from shlibs file
* Bump standards version, no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*************************************************************************
2
2
 *
3
 
 * $Id: trionan.c,v 1.33 2005/05/29 11:57:25 breese Exp $
 
3
 * $Id$
4
4
 *
5
5
 * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
6
6
 *
227
227
 */
228
228
 
229
229
#if !defined(TRIO_EMBED_NAN)
230
 
static TRIO_CONST char rcsid[] = "@(#)$Id: trionan.c,v 1.33 2005/05/29 11:57:25 breese Exp $";
 
230
static TRIO_CONST char rcsid[] = "@(#)$Id$";
231
231
#endif
232
232
 
233
233
#if defined(TRIO_FUNC_INTERNAL_MAKE_DOUBLE) \
294
294
 */
295
295
 
296
296
/*
 
297
 *
 
298
 */
 
299
#if defined(TRIO_PLATFORM_UNIX) && defined(TRIO_INTERNAL_ISNAN_FALLBACK)
 
300
 
 
301
/* Assume that if SA_SIGINFO is defined, then sigaction() and
 
302
 * 'struct sigaction' are also properly defined on this platform.
 
303
 */
 
304
#ifndef TRIO_USE_SIGACTION
 
305
#  ifdef SA_SIGINFO
 
306
#    define TRIO_USE_SIGACTION 1
 
307
#  else
 
308
#    define TRIO_USE_SIGACTION 0
 
309
#  endif
 
310
#endif
 
311
 
 
312
#  if TRIO_USE_SIGACTION
 
313
typedef struct sigaction signal_handler_t;
 
314
#  else
 
315
typedef void (*signal_handler_t) TRIO_PROTO((int));
 
316
#  endif
 
317
 
 
318
/*
 
319
 * internal_ignore_signal_handler
 
320
 */
 
321
 
 
322
TRIO_PRIVATE_NAN signal_handler_t
 
323
internal_ignore_signal_handler
 
324
TRIO_ARGS1((signum),
 
325
           int signum)
 
326
{
 
327
#  if TRIO_USE_SIGACTION
 
328
  signal_handler_t old_handler, new_handler;
 
329
  memset(&new_handler, '\0', sizeof(new_handler));
 
330
  new_handler.sa_handler = SIG_IGN;
 
331
  new_handler.sa_flags = SA_RESTART;
 
332
  sigaction(signum, &new_handler, &old_handler);
 
333
  return old_handler;
 
334
#  else
 
335
  return signal(signum, SIG_IGN);
 
336
#  endif
 
337
}
 
338
 
 
339
/*
 
340
 * internal_restore_signal_handler
 
341
 */
 
342
TRIO_PRIVATE_NAN void
 
343
internal_restore_signal_handler
 
344
TRIO_ARGS2((signum, handler),
 
345
           int signum,
 
346
           signal_handler_t handler)
 
347
{
 
348
#  if TRIO_USE_SIGACTION
 
349
    sigaction(signum, &handler, NULL);
 
350
#  else
 
351
    signal(signum, handler);
 
352
#  endif
 
353
}
 
354
 
 
355
#endif
 
356
 
 
357
/*
297
358
 * internal_make_double
298
359
 */
299
360
#if defined(TRIO_FUNC_INTERNAL_MAKE_DOUBLE)
649
710
  double integral, fraction;
650
711
  
651
712
#  if defined(TRIO_PLATFORM_UNIX)
652
 
  void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
 
713
  signal_handler_t sigfpe_handler = internal_ignore_signal_handler(SIGFPE);
653
714
#  endif
654
715
  
655
716
  status = (/*
664
725
              integral == fraction)));
665
726
  
666
727
#  if defined(TRIO_PLATFORM_UNIX)
667
 
  signal(SIGFPE, signal_handler);
 
728
  internal_restore_signal_handler(SIGFPR, sigfpe_handler);
668
729
#  endif
669
730
  
670
731
  return status;
711
772
  int status;
712
773
  
713
774
#  if defined(TRIO_PLATFORM_UNIX)
714
 
  void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
 
775
  signal_handler_t sigfpe_handler = internal_ignore_signal_handler(SIGFPE);
715
776
#  endif
716
777
  
717
778
  double infinity = trio_pinf();
721
782
            : ((number == -infinity) ? -1 : 0));
722
783
  
723
784
#  if defined(TRIO_PLATFORM_UNIX)
724
 
  signal(SIGFPE, signal_handler);
 
785
  internal_restore_signal_handler(SIGFPE, sigfpe_handler);
725
786
#  endif
726
787
  
727
788
  return status;
997
1058
     * operation to generate infinity.
998
1059
     */
999
1060
#  if defined(TRIO_PLATFORM_UNIX)
1000
 
    void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
 
1061
    signal_handler_t sigfpe_handler = internal_ignore_signal_handler(SIGFPE);
1001
1062
#  endif
1002
1063
 
1003
1064
    pinf_value = HUGE_VAL;
1007
1068
    }
1008
1069
    
1009
1070
#  if defined(TRIO_PLATFORM_UNIX)
1010
 
    signal(SIGFPE, signal_handler);
 
1071
    internal_restore_signal_handler(SIGFPE, sigfpe_handler);
1011
1072
#  endif
1012
1073
 
1013
1074
# endif
1086
1147
     * the Invalid Operation floating-point exception is unmasked.
1087
1148
     */
1088
1149
#  if defined(TRIO_PLATFORM_UNIX)
1089
 
    void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
 
1150
    signal_handle_t sigfpe_handler = internal_ignore_signal_handler(SIGFPE);
1090
1151
#  endif
1091
1152
    
1092
1153
    nan_value = trio_pinf() / trio_pinf();
1093
1154
    
1094
1155
#  if defined(TRIO_PLATFORM_UNIX)
1095
 
    signal(SIGFPE, signal_handler);
 
1156
    internal_restore_signal_handler(SIGFPE, sigfpe_handler);
1096
1157
#  endif
1097
1158
 
1098
1159
# endif
1155
1216
  double my_pinf;
1156
1217
  double my_ninf;
1157
1218
# if defined(TRIO_PLATFORM_UNIX)
1158
 
  void (*signal_handler) TRIO_PROTO((int));
 
1219
  signal_handler_t signal_handler;
1159
1220
# endif
1160
1221
 
1161
1222
  my_nan = trio_nan();
1207
1268
         trio_isnan(my_ninf), trio_isinf(my_ninf), trio_isfinite(my_ninf));
1208
1269
  
1209
1270
# if defined(TRIO_PLATFORM_UNIX)
1210
 
  signal_handler = signal(SIGFPE, SIG_IGN);
 
1271
  signal_handler = internal_ignore_signal_handler(SIGFPE);
1211
1272
# endif
1212
1273
  
1213
1274
  my_pinf = DBL_MAX + DBL_MAX;
1215
1276
  my_nan = my_pinf / my_pinf;
1216
1277
 
1217
1278
# if defined(TRIO_PLATFORM_UNIX)
1218
 
  signal(SIGFPE, signal_handler);
 
1279
  internal_restore_signal_handler(SIGFPE, signal_handler);
1219
1280
# endif
1220
1281
  
1221
1282
  printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d, %2d)\n",