/contrib/sdk/sources/newlib/pe_app.lds |
---|
File deleted |
/contrib/sdk/sources/newlib/libcdll.lds |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/setjmp.S |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/tls.S |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/crtdll.c |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/cpu_features.c |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/thread.S |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/i386mach.h |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/dllstart.c |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/exit.S |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/cpu_features.h |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/crtbegin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/pseudo-reloc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/chkstk.S |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/crt1.c |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/emutls.c |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/crt2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/opendial.S |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/crt3.c |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/start.S |
---|
File deleted |
/contrib/sdk/sources/newlib/crt/crt_amz.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_llround.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/k_sin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_j0.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_logb.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_cosh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_log.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_acosh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_log10.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_lrintl.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_exp2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_fmin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_atan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_sin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wrf_lgamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_j0.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_drem.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_trunc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_ilogb.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_atan2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_rem_pio2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_acos.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_signbit.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_sincos.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_llrint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_atanh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_sinh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_cosh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_pow10.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_acos.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_isinf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_pow.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_jn.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_isnand.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_atanh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_isnan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_cosh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_ldexp.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_signif.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_remainder.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_isinff.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_log.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wr_lgamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_expf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_remainder.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_sinh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_tanh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_nearbyint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_tanf.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_hypot.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_modf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/scalbnl.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/erf_gamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_frexpf.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_llrintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_powf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_jn.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_atanh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_exp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_cbrt.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_drem.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_fmax.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_scalbn.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/erf_lgamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_remainder.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_llrint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_lrint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_sinh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_ldexp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/local.h |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_atan2f.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_fdim.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/fdlibm.h |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_fabs.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_erf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_log1p.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_ceil.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_sinh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_infconst.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_j1.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_signif.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/er_gamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_floor.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_lrint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_pow.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_infinity.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_fmod.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_j1.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_round.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_expm1.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_exp10.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_fpclassify.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/k_rem_pio2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_rintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_nextafter.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_acosh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_remquo.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_atan2.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_scalbn.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_scalb.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_erf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_fmod.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_j0.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_atan2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_exp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_acosh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/kf_tan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/kf_cos.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_nan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_atan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_frexp.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_atan2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_llrint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_tan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_cos.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_log10f.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_log.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_asin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_fmod.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_copysign.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_j0.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_trunc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_acosh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_ilogb.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_matherr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_log.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_fmod.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_fpclassify.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_atan2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_log2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/k_tan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_isinfd.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/k_cos.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_nan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_pow10.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_hypot.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_finite.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_isinf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_remquo.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_pow.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_lrintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_tan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_asin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_scalbln.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_frexp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_cos.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_hypot.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_modf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_pow.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/k_standard.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_logf.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_cbrt.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_fmax.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_gamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_rint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_nearbyint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/er_lgamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_asinh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_asin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_exp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_hypot.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wr_gamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_lgamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_log.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_fma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_log10.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_fabs.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_ceil.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_asin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_j1.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_scalbln.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_exp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_tgamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_math.h |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_rint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_ldexp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_finite.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_tan.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_gamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_log1p.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_logb.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_sqrt.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_pow.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_lrint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_scalb.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_fmin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_j1.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_fma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_lround.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_llrintl.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_scalb.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_isnan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_sincos.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wrf_gamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_sqrt.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_jn.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_atanh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_exp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_isnanf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_scalb.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_jn.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_copysign.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_remainder.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_tanh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_sqrt.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_log2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/i386mach.h |
---|
File deleted |
/contrib/sdk/sources/newlib/math/scalblnl.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_lround.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_rintl.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_sqrt.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_floor.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_lib_ver.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_exp2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_log10.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_llround.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_fdim.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/f_ldexpf.S |
---|
File deleted |
/contrib/sdk/sources/newlib/math/kf_sin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_round.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_acos.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_frexp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_expm1.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/wf_log10.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_exp10.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_sin.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_infinity.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_cosh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_nextafter.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_lgamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_rem_pio2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/e_log10.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/sf_asinh.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/w_tgamma.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/kf_rem_pio2.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/s_rint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/math/ef_acos.c |
---|
File deleted |
/contrib/sdk/sources/newlib/newlib.sed |
---|
File deleted |
\ No newline at end of file |
/contrib/sdk/sources/newlib/cmd1.sed |
---|
File deleted |
\ No newline at end of file |
/contrib/sdk/sources/newlib/time/asctime.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/mktime.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/difftime.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/tzvars.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/lcltime.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/mktm_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/clock.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/strftime.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/time.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/local.h |
---|
File deleted |
/contrib/sdk/sources/newlib/time/ctime.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/gmtime_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/asctime_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/tzlock.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/gettzinfo.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/lcltime_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/ctime_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/time/gmtime.c |
---|
File deleted |
/contrib/sdk/sources/newlib/cmd2.sed |
---|
File deleted |
\ No newline at end of file |
/contrib/sdk/sources/newlib/locale/lmessages.h |
---|
File deleted |
/contrib/sdk/sources/newlib/locale/ldpart.h |
---|
File deleted |
/contrib/sdk/sources/newlib/locale/timelocal.h |
---|
File deleted |
/contrib/sdk/sources/newlib/locale/locale.c |
---|
File deleted |
/contrib/sdk/sources/newlib/locale/lmonetary.h |
---|
File deleted |
/contrib/sdk/sources/newlib/locale/setlocale.h |
---|
File deleted |
/contrib/sdk/sources/newlib/locale/lctype.c |
---|
File deleted |
/contrib/sdk/sources/newlib/locale/lnumeric.h |
---|
File deleted |
/contrib/sdk/sources/newlib/locale/lctype.h |
---|
File deleted |
/contrib/sdk/sources/newlib/tests/tst-calloc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/tests/pe_demo.asm |
---|
File deleted |
/contrib/sdk/sources/newlib/tests/error.c |
---|
File deleted |
/contrib/sdk/sources/newlib/tests/error.h |
---|
File deleted |
/contrib/sdk/sources/newlib/pe/crtloader.c |
---|
File deleted |
/contrib/sdk/sources/newlib/pe/list.h |
---|
File deleted |
/contrib/sdk/sources/newlib/pe/loader.c |
---|
File deleted |
/contrib/sdk/sources/newlib/pe/libc.asm |
---|
File deleted |
/contrib/sdk/sources/newlib/pe/pe.h |
---|
File deleted |
/contrib/sdk/sources/newlib/search/bsearch.c |
---|
File deleted |
/contrib/sdk/sources/newlib/search/qsort.c |
---|
File deleted |
/contrib/sdk/sources/newlib/libc.def |
---|
File deleted |
/contrib/sdk/sources/newlib/static.lds |
---|
File deleted |
/contrib/sdk/sources/newlib/Makefile |
---|
File deleted |
/contrib/sdk/sources/newlib/signal/signal.c |
---|
File deleted |
/contrib/sdk/sources/newlib/include/process.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/stdlib.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/_ansi.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/gthr.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/search.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/unistd.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/unctrl.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/pixlib2.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/_syslist.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/signal.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/malloc.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/fastmath.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/_default_types.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/ansi.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/setjmp-dj.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/ieeefp.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/time.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/endian.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/param.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/stdlib.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/setjmp.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/termios.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/_types.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/machine/types.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/envz.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/termios.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/glob.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/param.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/timeb.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/syslimits.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/_types.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/wait.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/types.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/config.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/string.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/unistd.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/fcntl.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/_default_fcntl.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/custom_file.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/stat.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/reent.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/signal.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/dir.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/features.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/file.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/times.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/stdio.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/utime.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/kos_io.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/queue.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/cdefs.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/errno.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/dirent.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/sched.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/resource.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/lock.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/iconvnls.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sys/time.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/pwd.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/alloca.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/regdef.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/rpc/xdr.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/rpc/types.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/fenv.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/kos32sys.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/limits.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/ar.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/fcntl.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/wctype.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/reent.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/iconv.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/paths.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/newlib.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/stdio.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/utime.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/utmp.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/dirent.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sched.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/pthread.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/grp.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/sound.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/math.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/strings.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/time.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/locale.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/libgen.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/assert.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/envlock.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/stdio_ext.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/setjmp.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/wchar.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/fastmath.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/regex.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/inttypes.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/fnmatch.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/ctype.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/errno.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/tar.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/wordexp.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/langinfo.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/ieeefp.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/getopt.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/argz.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/stdint.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/string.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/complex.h |
---|
File deleted |
/contrib/sdk/sources/newlib/include/malloc.h |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswcntrl.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswctype.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/isalnum.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/utf8print.h |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswxdigit.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswlower.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/wctype.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswpunct.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswspace.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswprint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/isalpha.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/isblank.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/isxdigit.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/isascii.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/towupper.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/isupper.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/jp2uc.h |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/toascii.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/isdigit.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/toupper.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswalnum.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/local.h |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/utf8alpha.h |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/ctype_iso.h |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswalpha.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswblank.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/ctype_cp.h |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iscntrl.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswupper.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/wctrans.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/towlower.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/ctype_.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswdigit.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/iswgraph.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/islower.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/towctrans.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/ispunct.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/isspace.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/isprint.c |
---|
File deleted |
/contrib/sdk/sources/newlib/ctype/tolower.c |
---|
File deleted |
/contrib/sdk/sources/newlib/errno/errno.c |
---|
File deleted |
/contrib/sdk/sources/newlib/dll.lds |
---|
File deleted |
/contrib/sdk/sources/newlib/app.lds |
---|
File deleted |
/contrib/sdk/sources/newlib/argz/buf_findstr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/argz/buf_findstr.h |
---|
File deleted |
/contrib/sdk/sources/newlib/argz/envz_get.c |
---|
File deleted |
/contrib/sdk/sources/newlib/libc.ver |
---|
File deleted |
/contrib/sdk/sources/newlib/libc.orig.def |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strtok.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strncmp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/memset.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strcspn.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strcasestr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strndup.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strcasecmp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strchr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/u_strerr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/memmove.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/memchr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/stpcpy.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strerror.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strncasecmp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strcpy.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strrchr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strpbrk.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strspn.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/memcpy.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strupr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/local.h |
---|
File deleted |
/contrib/sdk/sources/newlib/string/stpncpy.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strcat.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strstr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strncpy.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strdup_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strlen.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strtok_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strcmp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/vsprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/memcmp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strncat.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strsep.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strndup_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strdup.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/str-two-way.h |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strcoll.c |
---|
File deleted |
/contrib/sdk/sources/newlib/string/strnlen.c |
---|
File deleted |
/contrib/sdk/sources/newlib/Makefile.ebox |
---|
File deleted |
/contrib/sdk/sources/newlib/system.env |
---|
File deleted |
\ No newline at end of file |
/contrib/sdk/sources/newlib/reent/writer.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/readr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/getreent.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/isattyr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/init_reent.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/impure.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/mutex.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/openr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/gettimeofdayr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/hdlman.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/fstatr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/lseekr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/reent/closer.c |
---|
File deleted |
/contrib/sdk/sources/newlib/sys/read.c |
---|
File deleted |
/contrib/sdk/sources/newlib/sys/fsize.c |
---|
File deleted |
/contrib/sdk/sources/newlib/sys/finfo.c |
---|
File deleted |
/contrib/sdk/sources/newlib/sys/delete.c |
---|
File deleted |
/contrib/sdk/sources/newlib/sys/create.c |
---|
File deleted |
/contrib/sdk/sources/newlib/sys/fload.c |
---|
File deleted |
/contrib/sdk/sources/newlib/sys/write.c |
---|
File deleted |
/contrib/sdk/sources/newlib/unpack/unpacker.asm |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/hello.asm |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/proc32.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/libc.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/libfreetype.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/libpng.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/avdevice-54.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/import32.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/cairo2.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/swresample-0.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/app.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/struct.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/avutil-52.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/pixman-1.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/avcodec-54.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/zlib.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/libmpg123.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/swscale-2.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/include/avformat-54.inc |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/mpg123.asm |
---|
File deleted |
/contrib/sdk/sources/newlib/sdk/fasm/mpg123 |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Deleted: svn:mime-type |
-application/octet-stream |
\ No newline at end of property |
/contrib/sdk/sources/newlib/stdlib/malloc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/abort.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/exit.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/strtoull_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/gd_qnan.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/mbtowc_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/wctomb_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/mbrtowc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/gdtoa-gethex.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/realloc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/div.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/system.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/dtoastub.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/__call_atexit.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/dtoa.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/strtoull.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/mallocr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/mbtowc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/seed48.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/__atexit.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/rand48.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/assert.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/gdtoa.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/mlock.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/rand_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/rand48.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/abs.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/mprec.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/mbctype.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/mprec.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/strtoul.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/gdtoa-hexnan.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/wcrtomb.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/strtod.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/srand48.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/strtoll_r.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/rand.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/strtol.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/getenv.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/atof.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/strtold.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/atoi.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/calloc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/atexit.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/atol.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/std.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/local.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/atexit.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdlib/strtoll.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fgetc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/tmpnam.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/freopen.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/siprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/wbuf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vasniprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/snprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fwalk.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/findfp.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fgets.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/putc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fdopen.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fseeko.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fileno.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/sscanf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/diprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/ungetc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/wsetup.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/puts.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vfieeefp.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/local.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fwrite.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/tmpfile.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fscanf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fopen.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vscanf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fputc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/sccl.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/ftello.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vsnprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/flags.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/remove.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fputs.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/floatio.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/printf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vsscanf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vdiprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/makebuf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/sniprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/refill.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/setvbuf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fiprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/stdio.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vfscanf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fvwrite.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vasnprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fvwrite.h |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vdprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fseek.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vfprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/clearerr.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/rget.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/dprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/ftell.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/putchar.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/rename.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fputwc.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fiscanf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/vsprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fclose.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fread.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/sprintf.c |
---|
File deleted |
/contrib/sdk/sources/newlib/stdio/fflush.c |
---|
File deleted |
/contrib/sdk/sources/libc/Makefile |
---|
0,0 → 1,446 |
CC = kos32-gcc |
AR = kos32-ar |
LD = kos32-ld |
CFLAGS = -c -O2 -fomit-frame-pointer -DBUILD_DLL |
LDFLAGS = -shared -s -T libcdll.lds --out-implib libc.dll.a --image-base 0 |
#LDFLAGS+= --output-def libc.orig.def |
ARFLAGS = crs |
LIBC_TOPDIR = . |
LIBC_INCLUDES = $(LIBC_TOPDIR)/include |
NAME:= libc |
DEFINES:= -D_IEEE_LIBM |
INCLUDES:= -I $(LIBC_INCLUDES) |
LIBPATH:= -L../../lib -L/home/autobuild/tools/win32/mingw32/lib |
STATIC_SRCS:= \ |
crt/start.S \ |
crt/crt1.c \ |
crt/crt2.c \ |
crt/chkstk.S \ |
crt/exit.S \ |
pe/crtloader.c |
LIBDLL_SRCS:= \ |
crt/dllstart.c \ |
crt/chkstk.S \ |
crt/exit.S \ |
crt/pseudo-reloc.c \ |
crt/setjmp.S |
LIBCDLL_SRCS:= \ |
crt/crtdll.c \ |
crt/pseudo-reloc.c \ |
crt/chkstk.S \ |
crt/exit.S \ |
pe/loader.c |
LIBCRT_SRCS:= \ |
crt/start.S \ |
crt/chkstk.S \ |
crt/crt3.c \ |
crt/pseudo-reloc.c \ |
pe/crtloader.c |
CORE_SRCS:= \ |
argz/buf_findstr.c \ |
argz/envz_get.c \ |
crt/emutls.c \ |
crt/thread.S \ |
crt/tls.S \ |
crt/setjmp.S \ |
crt/cpu_features.c \ |
ctype/ctype_.c \ |
ctype/isascii.c \ |
ctype/isblank.c \ |
ctype/isalnum.c \ |
ctype/isalpha.c \ |
ctype/iscntrl.c \ |
ctype/isdigit.c \ |
ctype/islower.c \ |
ctype/isupper.c \ |
ctype/isprint.c \ |
ctype/ispunct.c \ |
ctype/isspace.c \ |
ctype/iswctype.c \ |
ctype/iswalnum.c \ |
ctype/iswalpha.c \ |
ctype/iswblank.c \ |
ctype/iswcntrl.c \ |
ctype/iswdigit.c \ |
ctype/iswgraph.c \ |
ctype/iswlower.c \ |
ctype/iswprint.c \ |
ctype/iswpunct.c \ |
ctype/iswspace.c \ |
ctype/iswupper.c \ |
ctype/iswxdigit.c \ |
ctype/isxdigit.c \ |
ctype/toascii.c \ |
ctype/tolower.c \ |
ctype/toupper.c \ |
ctype/towctrans.c \ |
ctype/towlower.c \ |
ctype/towupper.c \ |
ctype/wctrans.c \ |
ctype/wctype.c \ |
errno/errno.c \ |
locale/locale.c \ |
locale/lctype.c \ |
reent/impure.c \ |
reent/init_reent.c \ |
reent/getreent.c \ |
reent/mutex.c \ |
reent/gettimeofdayr.c \ |
reent/hdlman.c \ |
reent/isattyr.c \ |
reent/openr.c \ |
reent/closer.c \ |
reent/readr.c \ |
reent/lseekr.c \ |
reent/fstatr.c \ |
reent/writer.c \ |
search/qsort.c \ |
search/bsearch.c \ |
signal/signal.c \ |
sys/create.c \ |
sys/delete.c \ |
sys/finfo.c \ |
sys/read.c \ |
sys/write.c \ |
sys/fsize.c \ |
time/asctime.c \ |
time/asctime_r.c \ |
time/clock.c \ |
time/ctime.c \ |
time/ctime_r.c \ |
time/difftime.c \ |
time/gettzinfo.c \ |
time/gmtime.c \ |
time/gmtime_r.c \ |
time/mktime.c \ |
time/mktm_r.c \ |
time/lcltime.c \ |
time/lcltime_r.c \ |
time/strftime.c \ |
time/time.c \ |
time/tzlock.c \ |
time/tzvars.c |
STDLIB_SRCS= \ |
__atexit.c \ |
__call_atexit.c \ |
abort.c \ |
abs.c \ |
assert.c \ |
atexit.c \ |
atof.c \ |
atoi.c \ |
atol.c \ |
div.c \ |
dtoa.c \ |
dtoastub.c \ |
exit.c \ |
gdtoa-gethex.c \ |
gdtoa-hexnan.c \ |
getenv.c \ |
mprec.c \ |
mbtowc.c \ |
mbtowc_r.c \ |
mbrtowc.c \ |
mlock.c \ |
calloc.c \ |
malloc.c \ |
mallocr.c \ |
rand.c \ |
rand_r.c \ |
rand48.c \ |
realloc.c \ |
seed48.c \ |
srand48.c \ |
strtod.c \ |
strtol.c \ |
strtold.c \ |
strtoll.c \ |
strtoll_r.c \ |
strtoul.c \ |
strtoull.c \ |
strtoull_r.c \ |
system.c \ |
wcrtomb.c \ |
wctomb_r.c |
STRING_SRCS= memcpy.c \ |
memcmp.c \ |
memmove.c \ |
memset.c \ |
memchr.c \ |
stpcpy.c \ |
stpncpy.c \ |
strcat.c \ |
strchr.c \ |
strcmp.c \ |
strcoll.c \ |
strcasecmp.c \ |
strncasecmp.c \ |
strncat.c \ |
strncmp.c \ |
strncpy.c \ |
strndup.c \ |
strndup_r.c \ |
strnlen.c \ |
strcasestr.c \ |
strdup.c \ |
strdup_r.c \ |
strerror.c \ |
strlen.c \ |
strrchr.c \ |
strpbrk.c \ |
strsep.c \ |
strstr.c \ |
strtok.c \ |
strtok_r.c \ |
strupr.c \ |
strcspn.c \ |
strspn.c \ |
strcpy.c \ |
u_strerr.c |
STDIO_SRCS= \ |
clearerr.c \ |
diprintf.c \ |
dprintf.c \ |
printf.c \ |
putchar.c \ |
fgetc.c \ |
fgets.c \ |
fopen.c \ |
fclose.c \ |
fdopen.c \ |
fflush.c \ |
flags.c \ |
fileno.c \ |
findfp.c \ |
fiprintf.c \ |
fiscanf.c \ |
fprintf.c \ |
fputc.c \ |
fputs.c \ |
fputwc.c \ |
fread.c \ |
freopen.c \ |
fscanf.c \ |
fseek.c \ |
fseeko.c \ |
ftell.c \ |
ftello.c \ |
fwrite.c \ |
fvwrite.c \ |
fwalk.c \ |
putc.c \ |
puts.c \ |
refill.c \ |
rget.c \ |
remove.c \ |
rename.c \ |
setvbuf.c \ |
stdio.c \ |
tmpfile.c \ |
tmpnam.c \ |
ungetc.c \ |
vasniprintf.c \ |
vasnprintf.c \ |
vdprintf.c \ |
vdiprintf.c \ |
vscanf.c \ |
vsprintf.c \ |
vsnprintf.c \ |
vsscanf.c \ |
makebuf.c \ |
wsetup.c \ |
wbuf.c \ |
sccl.c \ |
siprintf.c \ |
sniprintf.c \ |
snprintf.c \ |
sprintf.c \ |
sscanf.c |
MATH_SRCS = e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c e_exp.c e_fmod.c \ |
e_hypot.c e_j0.c e_j1.c e_jn.c e_log.c e_log10.c e_pow.c e_rem_pio2.c \ |
e_remainder.c e_scalb.c e_sinh.c e_sqrt.c ef_acos.c ef_acosh.c ef_asin.c \ |
ef_atan2.c ef_atanh.c ef_cosh.c ef_exp.c ef_fmod.c ef_hypot.c ef_j0.c ef_j1.c \ |
ef_jn.c ef_log.c ef_log10.c ef_pow.c ef_rem_pio2.c ef_remainder.c ef_scalb.c \ |
ef_sinh.c ef_sqrt.c er_gamma.c er_lgamma.c erf_gamma.c erf_lgamma.c f_exp.c \ |
f_expf.c f_llrint.c f_llrintf.c f_llrintl.c f_lrint.c f_lrintf.c f_lrintl.c \ |
f_pow.c f_powf.c f_rint.c f_rintf.c f_rintl.c k_cos.c k_rem_pio2.c k_sin.c \ |
k_standard.c k_tan.c kf_cos.c kf_rem_pio2.c kf_sin.c kf_tan.c s_asinh.c \ |
s_atan.c s_cbrt.c s_ceil.c s_copysign.c s_cos.c s_erf.c s_exp10.c s_expm1.c \ |
s_fabs.c s_fdim.c s_finite.c s_floor.c s_fma.c s_fmax.c s_fmin.c s_fpclassify.c \ |
s_frexp.c s_ilogb.c s_infconst.c s_infinity.c s_isinf.c s_isinfd.c s_isnan.c \ |
s_isnand.c s_ldexp.c s_lib_ver.c s_llrint.c s_llround.c s_log1p.c s_log2.c \ |
s_logb.c s_lrint.c s_lround.c s_matherr.c s_modf.c s_nan.c s_nearbyint.c \ |
s_nextafter.c s_pow10.c s_remquo.c s_rint.c s_round.c s_scalbln.c s_scalbn.c \ |
s_signbit.c s_signif.c s_sin.c s_tan.c s_tanh.c s_trunc.c scalblnl.c scalbnl.c \ |
sf_asinh.c sf_atan.c sf_cbrt.c sf_ceil.c sf_copysign.c sf_cos.c sf_erf.c \ |
sf_exp10.c sf_expm1.c sf_fabs.c sf_fdim.c sf_finite.c sf_floor.c sf_fma.c \ |
sf_fmax.c sf_fmin.c sf_fpclassify.c sf_frexp.c sf_ilogb.c sf_infinity.c \ |
sf_isinf.c sf_isinff.c sf_isnan.c sf_isnanf.c sf_ldexp.c sf_llrint.c \ |
sf_llround.c sf_log1p.c sf_log2.c sf_logb.c sf_lrint.c sf_lround.c sf_modf.c \ |
sf_nan.c sf_nearbyint.c sf_nextafter.c sf_pow10.c sf_remquo.c sf_rint.c \ |
sf_round.c sf_scalbln.c sf_scalbn.c sf_signif.c sf_sin.c sf_tan.c sf_tanh.c \ |
sf_trunc.c w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c w_cosh.c w_drem.c \ |
w_exp.c w_exp2.c w_fmod.c w_gamma.c w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c \ |
w_log.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sincos.c w_sinh.c w_sqrt.c \ |
w_tgamma.c wf_acos.c wf_acosh.c wf_asin.c wf_atan2.c wf_atanh.c wf_cosh.c \ |
wf_drem.c wf_exp.c wf_exp2.c wf_fmod.c wf_gamma.c wf_hypot.c wf_j0.c wf_j1.c \ |
wf_jn.c wf_lgamma.c wf_log.c wf_log10.c wf_pow.c wf_remainder.c wf_scalb.c \ |
wf_sincos.c wf_sinh.c wf_sqrt.c wf_tgamma.c wr_gamma.c wr_lgamma.c wrf_gamma.c \ |
wrf_lgamma.c \ |
f_atan2.S f_atan2f.S f_frexp.S f_frexpf.S f_ldexp.S f_ldexpf.S f_log.S \ |
f_log10.S f_log10f.S f_logf.S f_tan.S f_tanf.S |
STATIC_OBJS = $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(STATIC_SRCS))) |
LIBCRT_OBJS = $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(LIBCRT_SRCS))) |
LIBDLL_OBJS = $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(LIBDLL_SRCS))) |
LIBCDLL_OBJS = $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(LIBCDLL_SRCS))) |
CORE_OBJS = $(patsubst %.S, %.o, $(patsubst %.asm, %.obj,\ |
$(patsubst %.c, %.o, $(CORE_SRCS)))) |
STDIO_OBJS = $(patsubst %.c, stdio/%.o,$(STDIO_SRCS)) |
STRING_OBJS = $(patsubst %.S, string/%.o, $(patsubst %.asm, string/%.o,\ |
$(patsubst %.c, string/%.o, $(STRING_SRCS)))) |
STDLIB_OBJS = $(patsubst %.S, stdlib/%.o, $(patsubst %.asm, stdlib/%.o,\ |
$(patsubst %.c, stdlib/%.o, $(STDLIB_SRCS)))) |
MATH_OBJS = $(patsubst %.S, math/%.o, $(patsubst %.asm, math/%.o,\ |
$(patsubst %.c, math/%.o, $(MATH_SRCS)))) |
PRINTF_OBJS= stdio/vfprintf.o \ |
stdio/vfiprintf.o \ |
stdio/svfprintf.o \ |
stdio/svfiprintf.o \ |
stdio/vfscanf.o \ |
stdio/vfiscanf.o \ |
stdio/svscanf.o \ |
stdio/svfiscanf.o |
ifeq ($(findstring static,$(MAKECMDGOALS)),static) |
LIB_SRCS:= $(STATIC_SRCS) |
LIB_OBJS:= $(STATIC_OBJS) |
else |
LIB_SRCS:= $(LIBCDLL_SRCS) |
LIB_OBJS:= $(LIBCDLL_OBJS) |
endif |
LIB_SRCS+= \ |
$(CORE_SRCS) \ |
$(STDIO_SRCS) \ |
$(STRING_SRCS) \ |
$(STDLIB_SRCS) |
LIB_OBJS+= \ |
$(CORE_OBJS) \ |
$(STRING_OBJS) \ |
$(STDLIB_OBJS) \ |
$(STDIO_OBJS) \ |
$(PRINTF_OBJS) \ |
$(MATH_OBJS) |
shared: $(NAME).dll libapp.a libdll.a |
$(NAME).dll: $(LIB_OBJS) $(SRC_DEP) Makefile |
$(LD) $(LDFLAGS) $(LIBPATH) -o $@ $(LIB_OBJS) -lgcc --version-script libc.ver |
#sed -e "s/ @[^ ]*//" libc.orig.def > libc.def |
#sed -f cmd2.sed libc.def > mem |
#sed -f newlib.sed mem > libc.inc |
install: libc.dll libc.dll.a libapp.a libdll.a |
mv -f libc.dll ../../bin |
mv -f libc.dll.a ../../lib |
mv -f libapp.a ../../lib |
mv -f libdll.a ../../lib |
libapp.a: $(LIBCRT_OBJS) Makefile |
$(AR) $(ARFLAGS) libapp.a $(LIBCRT_OBJS) |
libdll.a: $(LIBDLL_OBJS) Makefile |
$(AR) $(ARFLAGS) libdll.a $(LIBDLL_OBJS) |
static: $(NAME).a |
$(NAME).a: $(LIB_OBJS) $(SRC_DEP) Makefile |
$(AR) $(ARFLAGS) $(NAME).a $(LIB_OBJS) |
stdio/vfprintf.o: stdio/vfprintf.c |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DFLOATING_POINT -c stdio/vfprintf.c -o $@ |
stdio/vfiprintf.o: stdio/vfprintf.c |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DINTEGER_ONLY -c stdio/vfprintf.c -o $@ |
stdio/svfprintf.o: stdio/vfprintf.c |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DSTRING_ONLY -c stdio/vfprintf.c -o $@ |
stdio/svfiprintf.o: stdio/vfprintf.c |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DINTEGER_ONLY -DSTRING_ONLY -c stdio/vfprintf.c -o $@ |
stdio/vfscanf.o: stdio/vfscanf.c |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) stdio/vfscanf.c -o $@ |
stdio/vfiscanf.o: stdio/vfscanf.c |
$(CC) $(CFLAGS) $(DEFINES) -DINTEGER_ONLY $(INCLUDES) stdio/vfscanf.c -o $@ |
stdio/svscanf.o: stdio/vfscanf.c |
$(CC) $(CFLAGS) $(DEFINES) -DSTRING_ONLY $(INCLUDES) stdio/vfscanf.c -o $@ |
stdio/svfiscanf.o: stdio/vfscanf.c |
$(CC) $(CFLAGS) $(DEFINES) -DINTEGER_ONLY -DSTRING_ONLY $(INCLUDES) stdio/vfscanf.c -o $@ |
%.obj : %.asm Makefile |
fasm $< $ |
%.o : %.c Makefile |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< |
clean: |
-rm -f */*.o |
/contrib/sdk/sources/libc/Makefile.ebox |
---|
0,0 → 1,442 |
CC = gcc |
AR = ar rc |
LD = ld |
CFLAGS = -c -O2 -march=pentium-mmx -fomit-frame-pointer -DBUILD_DLL |
LDFLAGS = -nostdlib -shared -s -T libcdll.lds --output-def libc.orig.def --out-implib libc.dll.a --image-base 0 |
LIBC_TOPDIR = . |
LIBC_INCLUDES = $(LIBC_TOPDIR)/include |
NAME:= libc |
DEFINES:= -D_IEEE_LIBM |
INCLUDES:= -I $(LIBC_INCLUDES) |
LIBPATH:= -L ../../lib |
STATIC_SRCS:= \ |
crt/start.S \ |
crt/crt1.c \ |
crt/crt2.c \ |
crt/chkstk.S \ |
crt/exit.S \ |
pe/crtloader.c |
LIBDLL_SRCS:= \ |
crt/dllstart.c \ |
crt/chkstk.S \ |
crt/exit.S \ |
crt/pseudo-reloc.c \ |
crt/setjmp.S |
LIBCDLL_SRCS:= \ |
crt/crtdll.c \ |
crt/pseudo-reloc.c \ |
crt/chkstk.S \ |
crt/exit.S \ |
pe/loader.c |
LIBCRT_SRCS:= \ |
crt/start.S \ |
crt/chkstk.S \ |
crt/crt3.c \ |
crt/pseudo-reloc.c \ |
pe/crtloader.c |
CORE_SRCS:= \ |
argz/buf_findstr.c \ |
argz/envz_get.c \ |
crt/emutls.c \ |
crt/thread.S \ |
crt/tls.S \ |
crt/setjmp.S \ |
crt/assert.c \ |
crt/cpu_features.c \ |
ctype/ctype_.c \ |
ctype/isascii.c \ |
ctype/isblank.c \ |
ctype/isalnum.c \ |
ctype/isalpha.c \ |
ctype/iscntrl.c \ |
ctype/isdigit.c \ |
ctype/islower.c \ |
ctype/isupper.c \ |
ctype/isprint.c \ |
ctype/ispunct.c \ |
ctype/isspace.c \ |
ctype/iswctype.c \ |
ctype/iswalnum.c \ |
ctype/iswalpha.c \ |
ctype/iswblank.c \ |
ctype/iswcntrl.c \ |
ctype/iswdigit.c \ |
ctype/iswgraph.c \ |
ctype/iswlower.c \ |
ctype/iswprint.c \ |
ctype/iswpunct.c \ |
ctype/iswspace.c \ |
ctype/iswupper.c \ |
ctype/iswxdigit.c \ |
ctype/isxdigit.c \ |
ctype/toascii.c \ |
ctype/tolower.c \ |
ctype/toupper.c \ |
ctype/towctrans.c \ |
ctype/towlower.c \ |
ctype/towupper.c \ |
ctype/wctrans.c \ |
ctype/wctype.c \ |
errno/errno.c \ |
locale/locale.c \ |
locale/lctype.c \ |
reent/impure.c \ |
reent/init_reent.c \ |
reent/getreent.c \ |
reent/mutex.c \ |
reent/gettimeofdayr.c \ |
reent/hdlman.c \ |
reent/isattyr.c \ |
reent/openr.c \ |
reent/closer.c \ |
reent/readr.c \ |
reent/lseekr.c \ |
reent/fstatr.c \ |
reent/writer.c \ |
search/qsort.c \ |
search/bsearch.c \ |
signal/signal.c \ |
sys/create.c \ |
sys/delete.c \ |
sys/finfo.c \ |
sys/read.c \ |
sys/write.c \ |
sys/fsize.c \ |
time/asctime.c \ |
time/asctime_r.c \ |
time/clock.c \ |
time/ctime.c \ |
time/ctime_r.c \ |
time/difftime.c \ |
time/gettzinfo.c \ |
time/gmtime.c \ |
time/gmtime_r.c \ |
time/mktime.c \ |
time/mktm_r.c \ |
time/lcltime.c \ |
time/lcltime_r.c \ |
time/strftime.c \ |
time/time.c \ |
time/tzlock.c \ |
time/tzvars.c |
STDLIB_SRCS= \ |
__atexit.c \ |
__call_atexit.c \ |
abort.c \ |
abs.c \ |
atof.c \ |
atoi.c \ |
atol.c \ |
div.c \ |
dtoa.c \ |
dtoastub.c \ |
exit.c \ |
gdtoa-gethex.c \ |
gdtoa-hexnan.c \ |
getenv.c \ |
mprec.c \ |
mbtowc.c \ |
mbtowc_r.c \ |
mbrtowc.c \ |
mlock.c \ |
calloc.c \ |
malloc.c \ |
mallocr.c \ |
rand.c \ |
rand_r.c \ |
rand48.c \ |
realloc.c \ |
seed48.c \ |
srand48.c \ |
strtod.c \ |
strtol.c \ |
strtold.c \ |
strtoll.c \ |
strtoll_r.c \ |
strtoul.c \ |
strtoull.c \ |
strtoull_r.c \ |
system.c \ |
wcrtomb.c \ |
wctomb_r.c |
STRING_SRCS= memcpy.c \ |
memcmp.c \ |
memmove.c \ |
memset.c \ |
memchr.c \ |
stpcpy.c \ |
stpncpy.c \ |
strcat.c \ |
strchr.c \ |
strcmp.c \ |
strcoll.c \ |
strcasecmp.c \ |
strncasecmp.c \ |
strncat.c \ |
strncmp.c \ |
strncpy.c \ |
strndup.c \ |
strndup_r.c \ |
strnlen.c \ |
strcasestr.c \ |
strdup.c \ |
strdup_r.c \ |
strerror.c \ |
strlen.c \ |
strrchr.c \ |
strpbrk.c \ |
strsep.c \ |
strstr.c \ |
strtok.c \ |
strtok_r.c \ |
strupr.c \ |
strcspn.c \ |
strspn.c \ |
strcpy.c \ |
u_strerr.c |
STDIO_SRCS= \ |
clearerr.c \ |
diprintf.c \ |
dprintf.c \ |
printf.c \ |
putchar.c \ |
fgetc.c \ |
fgets.c \ |
fopen.c \ |
fclose.c \ |
fdopen.c \ |
fflush.c \ |
flags.c \ |
fileno.c \ |
findfp.c \ |
fiprintf.c \ |
fiscanf.c \ |
fprintf.c \ |
fputc.c \ |
fputs.c \ |
fputwc.c \ |
fread.c \ |
freopen.c \ |
fscanf.c \ |
fseek.c \ |
fseeko.c \ |
ftell.c \ |
ftello.c \ |
fwrite.c \ |
fvwrite.c \ |
fwalk.c \ |
putc.c \ |
puts.c \ |
refill.c \ |
rget.c \ |
remove.c \ |
rename.c \ |
setvbuf.c \ |
stdio.c \ |
tmpfile.c \ |
tmpnam.c \ |
ungetc.c \ |
vasniprintf.c \ |
vasnprintf.c \ |
vdprintf.c \ |
vdiprintf.c \ |
vscanf.c \ |
vsprintf.c \ |
vsnprintf.c \ |
vsscanf.c \ |
makebuf.c \ |
wsetup.c \ |
wbuf.c \ |
sccl.c \ |
siprintf.c \ |
sniprintf.c \ |
snprintf.c \ |
sprintf.c \ |
sscanf.c |
MATH_SRCS = e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c e_exp.c e_fmod.c \ |
e_hypot.c e_j0.c e_j1.c e_jn.c e_log.c e_log10.c e_pow.c e_rem_pio2.c \ |
e_remainder.c e_scalb.c e_sinh.c e_sqrt.c ef_acos.c ef_acosh.c ef_asin.c \ |
ef_atan2.c ef_atanh.c ef_cosh.c ef_exp.c ef_fmod.c ef_hypot.c ef_j0.c ef_j1.c \ |
ef_jn.c ef_log.c ef_log10.c ef_pow.c ef_rem_pio2.c ef_remainder.c ef_scalb.c \ |
ef_sinh.c ef_sqrt.c er_gamma.c er_lgamma.c erf_gamma.c erf_lgamma.c f_exp.c \ |
f_expf.c f_llrint.c f_llrintf.c f_llrintl.c f_lrint.c f_lrintf.c f_lrintl.c \ |
f_pow.c f_powf.c f_rint.c f_rintf.c f_rintl.c k_cos.c k_rem_pio2.c k_sin.c \ |
k_standard.c k_tan.c kf_cos.c kf_rem_pio2.c kf_sin.c kf_tan.c s_asinh.c \ |
s_atan.c s_cbrt.c s_ceil.c s_copysign.c s_cos.c s_erf.c s_exp10.c s_expm1.c \ |
s_fabs.c s_fdim.c s_finite.c s_floor.c s_fma.c s_fmax.c s_fmin.c s_fpclassify.c \ |
s_frexp.c s_ilogb.c s_infconst.c s_infinity.c s_isinf.c s_isinfd.c s_isnan.c \ |
s_isnand.c s_ldexp.c s_lib_ver.c s_llrint.c s_llround.c s_log1p.c s_log2.c \ |
s_logb.c s_lrint.c s_lround.c s_matherr.c s_modf.c s_nan.c s_nearbyint.c \ |
s_nextafter.c s_pow10.c s_remquo.c s_rint.c s_round.c s_scalbln.c s_scalbn.c \ |
s_signbit.c s_signif.c s_sin.c s_tan.c s_tanh.c s_trunc.c scalblnl.c scalbnl.c \ |
sf_asinh.c sf_atan.c sf_cbrt.c sf_ceil.c sf_copysign.c sf_cos.c sf_erf.c \ |
sf_exp10.c sf_expm1.c sf_fabs.c sf_fdim.c sf_finite.c sf_floor.c sf_fma.c \ |
sf_fmax.c sf_fmin.c sf_fpclassify.c sf_frexp.c sf_ilogb.c sf_infinity.c \ |
sf_isinf.c sf_isinff.c sf_isnan.c sf_isnanf.c sf_ldexp.c sf_llrint.c \ |
sf_llround.c sf_log1p.c sf_log2.c sf_logb.c sf_lrint.c sf_lround.c sf_modf.c \ |
sf_nan.c sf_nearbyint.c sf_nextafter.c sf_pow10.c sf_remquo.c sf_rint.c \ |
sf_round.c sf_scalbln.c sf_scalbn.c sf_signif.c sf_sin.c sf_tan.c sf_tanh.c \ |
sf_trunc.c w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c w_cosh.c w_drem.c \ |
w_exp.c w_exp2.c w_fmod.c w_gamma.c w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c \ |
w_log.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sincos.c w_sinh.c w_sqrt.c \ |
w_tgamma.c wf_acos.c wf_acosh.c wf_asin.c wf_atan2.c wf_atanh.c wf_cosh.c \ |
wf_drem.c wf_exp.c wf_exp2.c wf_fmod.c wf_gamma.c wf_hypot.c wf_j0.c wf_j1.c \ |
wf_jn.c wf_lgamma.c wf_log.c wf_log10.c wf_pow.c wf_remainder.c wf_scalb.c \ |
wf_sincos.c wf_sinh.c wf_sqrt.c wf_tgamma.c wr_gamma.c wr_lgamma.c wrf_gamma.c \ |
wrf_lgamma.c \ |
f_atan2.S f_atan2f.S f_frexp.S f_frexpf.S f_ldexp.S f_ldexpf.S f_log.S \ |
f_log10.S f_log10f.S f_logf.S f_tan.S f_tanf.S |
STATIC_OBJS = $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(STATIC_SRCS))) |
LIBCRT_OBJS = $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(LIBCRT_SRCS))) |
LIBDLL_OBJS = $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(LIBDLL_SRCS))) |
LIBCDLL_OBJS = $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(LIBCDLL_SRCS))) |
CORE_OBJS = $(patsubst %.S, %.o, $(patsubst %.asm, %.obj,\ |
$(patsubst %.c, %.o, $(CORE_SRCS)))) |
STDIO_OBJS = $(patsubst %.c, stdio/%.o,$(STDIO_SRCS)) |
STRING_OBJS = $(patsubst %.S, string/%.o, $(patsubst %.asm, string/%.o,\ |
$(patsubst %.c, string/%.o, $(STRING_SRCS)))) |
STDLIB_OBJS = $(patsubst %.S, stdlib/%.o, $(patsubst %.asm, stdlib/%.o,\ |
$(patsubst %.c, stdlib/%.o, $(STDLIB_SRCS)))) |
MATH_OBJS = $(patsubst %.S, math/%.o, $(patsubst %.asm, math/%.o,\ |
$(patsubst %.c, math/%.o, $(MATH_SRCS)))) |
PRINTF_OBJS= stdio/vfprintf.o \ |
stdio/vfiprintf.o \ |
stdio/svfprintf.o \ |
stdio/svfiprintf.o \ |
stdio/vfscanf.o \ |
stdio/vfiscanf.o \ |
stdio/svscanf.o \ |
stdio/svfiscanf.o |
ifeq ($(findstring static,$(MAKECMDGOALS)),static) |
LIB_SRCS:= $(STATIC_SRCS) |
LIB_OBJS:= $(STATIC_OBJS) |
else |
LIB_SRCS:= $(LIBCDLL_SRCS) |
LIB_OBJS:= $(LIBCDLL_OBJS) |
endif |
LIB_SRCS+= \ |
$(CORE_SRCS) \ |
$(STDIO_SRCS) \ |
$(STRING_SRCS) \ |
$(STDLIB_SRCS) |
LIB_OBJS+= \ |
$(CORE_OBJS) \ |
$(STRING_OBJS) \ |
$(STDLIB_OBJS) \ |
$(STDIO_OBJS) \ |
$(PRINTF_OBJS) \ |
$(MATH_OBJS) |
shared: $(NAME).dll libapp.a libdll.a |
$(NAME).dll: $(LIB_OBJS) $(SRC_DEP) Makefile |
$(LD) $(LDFLAGS) $(LIBPATH) -o $@ $(LIB_OBJS) --version-script libc.ver |
sed -e "s/ @[^ ]*//" libc.orig.def > libc.def |
sed -f cmd2.sed libc.def > mem |
sed -f newlib.sed mem > libc.inc |
install: libc.dll libc.dll.a libapp.a libdll.a |
mv -f libc.dll ../../bin |
mv -f libc.dll.a ../../lib |
mv -f libapp.a ../../lib |
mv -f libdll.a ../../lib |
libapp.a: $(LIBCRT_OBJS) Makefile |
$(AR) libapp.a $(LIBCRT_OBJS) |
libdll.a: $(LIBDLL_OBJS) Makefile |
$(AR) libdll.a $(LIBDLL_OBJS) |
static: $(NAME).a |
$(NAME).a: $(LIB_OBJS) $(SRC_DEP) Makefile |
$(AR) $(NAME).a $(LIB_OBJS) |
stdio/vfprintf.o: stdio/vfprintf.c |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DFLOATING_POINT -c stdio/vfprintf.c -o $@ |
stdio/vfiprintf.o: stdio/vfprintf.c |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DINTEGER_ONLY -c stdio/vfprintf.c -o $@ |
stdio/svfprintf.o: stdio/vfprintf.c |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DSTRING_ONLY -c stdio/vfprintf.c -o $@ |
stdio/svfiprintf.o: stdio/vfprintf.c |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DINTEGER_ONLY -DSTRING_ONLY -c stdio/vfprintf.c -o $@ |
stdio/vfscanf.o: stdio/vfscanf.c |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) stdio/vfscanf.c -o $@ |
stdio/vfiscanf.o: stdio/vfscanf.c |
$(CC) $(CFLAGS) $(DEFINES) -DINTEGER_ONLY $(INCLUDES) stdio/vfscanf.c -o $@ |
stdio/svscanf.o: stdio/vfscanf.c |
$(CC) $(CFLAGS) $(DEFINES) -DSTRING_ONLY $(INCLUDES) stdio/vfscanf.c -o $@ |
stdio/svfiscanf.o: stdio/vfscanf.c |
$(CC) $(CFLAGS) $(DEFINES) -DINTEGER_ONLY -DSTRING_ONLY $(INCLUDES) stdio/vfscanf.c -o $@ |
%.obj : %.asm Makefile |
fasm $< $ |
%.o : %.c Makefile |
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< |
clean: |
-rm -f */*.o |
/contrib/sdk/sources/libc/crt/crt3.c |
---|
0,0 → 1,65 |
/* |
* crt1.c |
* This file has no copyright assigned and is placed in the Public Domain. |
* This file is a part of the mingw-runtime package. |
* No warranty is given; refer to the file DISCLAIMER within the package. |
* |
* Source code for the startup proceedures used by all programs. This code |
* is compiled to make crt1.o, which should be located in the library path. |
* |
*/ |
/* Hide the declaration of _fmode with dllimport attribute in stdlib.h to |
avoid problems with older GCC. */ |
#include <newlib.h> |
#include <stdint.h> |
#include <stdlib.h> |
#include <string.h> |
#include <stdio.h> |
/* |
typedef void (*ctp)(); |
static void __do_global_ctors () |
{ |
extern int __CTOR_LIST__; |
int *c = &__CTOR_LIST__; |
c++; |
while (*c) |
{ |
ctp d = (ctp)*c; |
(d)(); |
c++; |
} |
} |
*/ |
void *load_libc(); |
//void __main (){}; |
void* get_entry_point(void *raw); |
void _pei386_runtime_relocator (void){}; |
void __attribute__((noreturn)) |
__crt_startup (void) |
{ |
struct app_hdr *header; |
void *img; |
void __attribute__((noreturn)) (*entry)(void *img); |
// _pei386_runtime_relocator(); |
img = load_libc(); |
if(img == NULL) |
{ |
asm ("int $0x40" ::"a"(-1)); |
}; |
entry = get_entry_point(img); |
entry(img); |
} |
/contrib/sdk/sources/libc/crt/emutls.c |
---|
0,0 → 1,217 |
/* TLS emulation. |
Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc. |
Contributed by Jakub Jelinek <jakub@redhat.com>. |
This file is part of GCC. |
GCC is free software; you can redistribute it and/or modify it under |
the terms of the GNU General Public License as published by the Free |
Software Foundation; either version 3, or (at your option) any later |
version. |
GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
for more details. |
Under Section 7 of GPL version 3, you are granted additional |
permissions described in the GCC Runtime Library Exception, version |
3.1, as published by the Free Software Foundation. |
You should have received a copy of the GNU General Public License and |
a copy of the GCC Runtime Library Exception along with this program; |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
<http://www.gnu.org/licenses/>. */ |
#include <stdlib.h> |
#include <malloc.h> |
#include <errno.h> |
#include <gthr.h> |
void *tls_alloc(void); |
void __mutex_lock(volatile int *val); |
static inline void yield(void) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(68), "b"(1)); |
}; |
int __gthread_once (__gthread_once_t *once, void (*func) (void)) |
{ |
if (once == NULL || func == NULL) |
return EINVAL; |
if (! once->done) |
{ |
if(++once->started == 0) |
{ |
(*func) (); |
once->done = 1; |
} |
else |
{ |
/* Another thread is currently executing the code, so wait for it |
to finish; yield the CPU in the meantime. If performance |
does become an issue, the solution is to use an Event that |
we wait on here (and set above), but that implies a place to |
create the event before this routine is called. */ |
while (! once->done) |
yield(); |
} |
} |
return 0; |
} |
#define __GTHREAD_ONCE_INIT {0, -1} |
typedef unsigned int word __attribute__((mode(word))); |
typedef unsigned int pointer __attribute__((mode(pointer))); |
struct __emutls_object |
{ |
word size; |
word align; |
union { |
pointer offset; |
void *ptr; |
} loc; |
void *templ; |
}; |
struct __emutls_array |
{ |
pointer size; |
void **data[]; |
}; |
void *__emutls_get_address (struct __emutls_object *); |
void __emutls_register_common (struct __emutls_object *, word, word, void *); |
static __gthread_mutex_t emutls_mutex; |
static __gthread_key_t emutls_key; |
static pointer emutls_size; |
static void emutls_destroy (void *ptr) |
{ |
struct __emutls_array *arr = ptr; |
pointer size = arr->size; |
pointer i; |
for (i = 0; i < size; ++i) |
{ |
if (arr->data[i]) |
free (arr->data[i][-1]); |
} |
free (ptr); |
}; |
static void emutls_init (void) |
{ |
if (__gthread_key_create (&emutls_key, emutls_destroy) != 0) |
abort (); |
} |
static void *emutls_alloc (struct __emutls_object *obj) |
{ |
void *ptr; |
void *ret; |
/* We could use here posix_memalign if available and adjust |
emutls_destroy accordingly. */ |
if (obj->align <= sizeof (void *)) |
{ |
ptr = malloc (obj->size + sizeof (void *)); |
if (ptr == NULL) |
abort (); |
((void **) ptr)[0] = ptr; |
ret = ptr + sizeof (void *); |
} |
else |
{ |
ptr = malloc (obj->size + sizeof (void *) + obj->align - 1); |
if (ptr == NULL) |
abort (); |
ret = (void *) (((pointer) (ptr + sizeof (void *) + obj->align - 1)) |
& ~(pointer)(obj->align - 1)); |
((void **) ret)[-1] = ptr; |
} |
if (obj->templ) |
memcpy (ret, obj->templ, obj->size); |
else |
memset (ret, 0, obj->size); |
return ret; |
} |
void * __emutls_get_address (struct __emutls_object *obj) |
{ |
pointer offset = obj->loc.offset; |
if (__builtin_expect (offset == 0, 0)) |
{ |
static __gthread_once_t once = __GTHREAD_ONCE_INIT; |
__gthread_once (&once, emutls_init); |
__gthread_mutex_lock (&emutls_mutex); |
offset = obj->loc.offset; |
if (offset == 0) |
{ |
offset = ++emutls_size; |
obj->loc.offset = offset; |
} |
__gthread_mutex_unlock (&emutls_mutex); |
} |
struct __emutls_array *arr = __gthread_getspecific (emutls_key); |
if (__builtin_expect (arr == NULL, 0)) |
{ |
pointer size = offset + 32; |
arr = calloc (size + 1, sizeof (void *)); |
if (arr == NULL) |
abort (); |
arr->size = size; |
__gthread_setspecific (emutls_key, (void *) arr); |
} |
else if (__builtin_expect (offset > arr->size, 0)) |
{ |
pointer orig_size = arr->size; |
pointer size = orig_size * 2; |
if (offset > size) |
size = offset + 32; |
arr = realloc (arr, (size + 1) * sizeof (void *)); |
if (arr == NULL) |
abort (); |
arr->size = size; |
memset (arr->data + orig_size, 0, |
(size - orig_size) * sizeof (void *)); |
__gthread_setspecific (emutls_key, (void *) arr); |
} |
void *ret = arr->data[offset - 1]; |
if (__builtin_expect (ret == NULL, 0)) |
{ |
ret = emutls_alloc (obj); |
arr->data[offset - 1] = ret; |
} |
return ret; |
} |
void __emutls_register_common (struct __emutls_object *obj, |
word size, word align, void *templ) |
{ |
if (obj->size < size) |
{ |
obj->size = size; |
obj->templ = NULL; |
} |
if (obj->align < align) |
obj->align = align; |
if (templ && size == obj->size) |
obj->templ = templ; |
} |
/contrib/sdk/sources/libc/crt/pseudo-reloc.c |
---|
0,0 → 1,213 |
/* pseudo-reloc.c |
Contributed by Egor Duda <deo@logos-m.ru> |
Modified by addition of runtime_pseudo_reloc version 2 |
by Kai Tietz <kai.tietz@onevision.com> |
THIS SOFTWARE IS NOT COPYRIGHTED |
This source code is offered for use in the public domain. You may |
use, modify or distribute it freely. |
This code is distributed in the hope that it will be useful but |
WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY |
DISCLAMED. This includes but is not limited to warrenties of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
#include <stdint.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdarg.h> |
extern char __RUNTIME_PSEUDO_RELOC_LIST__; |
extern char __RUNTIME_PSEUDO_RELOC_LIST_END__; |
extern char _image_base__; |
void _pei386_runtime_relocator (void); |
/* v1 relocation is basically: |
* *(base + .target) += .addend |
* where (base + .target) is always assumed to point |
* to a DWORD (4 bytes). |
*/ |
typedef struct { |
uint32_t addend; |
uint32_t target; |
} runtime_pseudo_reloc_item_v1; |
/* v2 relocation is more complex. In effect, it is |
* *(base + .target) += *(base + .sym) - (base + .sym) |
* with care taken in both reading, sign extension, and writing |
* because .flags may indicate that (base + .target) may point |
* to a BYTE, WORD, DWORD, or QWORD (w64). |
*/ |
typedef struct { |
uint32_t sym; |
uint32_t target; |
uint32_t flags; |
} runtime_pseudo_reloc_item_v2; |
typedef struct { |
uint32_t magic1; |
uint32_t magic2; |
uint32_t version; |
} runtime_pseudo_reloc_v2; |
#define RP_VERSION_V1 0 |
#define RP_VERSION_V2 1 |
static void |
do_pseudo_reloc (void * start, void * end, void * base) |
{ |
ptrdiff_t addr_imp, reldata; |
ptrdiff_t reloc_target = (ptrdiff_t) ((char *)end - (char*)start); |
runtime_pseudo_reloc_v2 *v2_hdr = (runtime_pseudo_reloc_v2 *) start; |
runtime_pseudo_reloc_item_v2 *r; |
/* A valid relocation list will contain at least one entry, and |
* one v1 data structure (the smallest one) requires two DWORDs. |
* So, if the relocation list is smaller than 8 bytes, bail. |
*/ |
if (reloc_target < 8) |
return; |
/* Check if this is the old pseudo relocation version. */ |
/* There are two kinds of v1 relocation lists: |
* 1) With a (v2-style) version header. In this case, the |
* first entry in the list is a 3-DWORD structure, with |
* value: |
* { 0, 0, RP_VERSION_V1 } |
* In this case, we skip to the next entry in the list, |
* knowing that all elements after the head item can |
* be cast to runtime_pseudo_reloc_item_v1. |
* 2) Without a (v2-style) version header. In this case, the |
* first element in the list IS an actual v1 relocation |
* record, which is two DWORDs. Because there will never |
* be a case where a v1 relocation record has both |
* addend == 0 and target == 0, this case will not be |
* confused with the prior one. |
* All current binutils, when generating a v1 relocation list, |
* use the second (e.g. original) form -- that is, without the |
* v2-style version header. |
*/ |
if (reloc_target >= 12 |
&& v2_hdr->magic1 == 0 && v2_hdr->magic2 == 0 |
&& v2_hdr->version == RP_VERSION_V1) |
{ |
/* We have a list header item indicating that the rest |
* of the list contains v1 entries. Move the pointer to |
* the first true v1 relocation record. By definition, |
* that v1 element will not have both addend == 0 and |
* target == 0 (and thus, when interpreted as a |
* runtime_pseudo_reloc_v2, it will not have both |
* magic1 == 0 and magic2 == 0). |
*/ |
v2_hdr++; |
} |
if (v2_hdr->magic1 != 0 || v2_hdr->magic2 != 0) |
{ |
/************************* |
* Handle v1 relocations * |
*************************/ |
runtime_pseudo_reloc_item_v1 * o; |
for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr; |
o < (runtime_pseudo_reloc_item_v1 *)end; |
o++) |
{ |
uint32_t newval; |
reloc_target = (ptrdiff_t) base + o->target; |
newval = (*((uint32_t*) reloc_target)) + o->addend; |
*(uint32_t*)reloc_target = newval; |
} |
return; |
} |
/* If we got this far, then we have relocations of version 2 or newer */ |
/* Check if this is a known version. */ |
if (v2_hdr->version != RP_VERSION_V2) |
{ |
// printf(" Unknown pseudo relocation protocol version %d.\n", |
// (int) v2_hdr->version); |
return; |
} |
/************************* |
* Handle v2 relocations * |
*************************/ |
/* Walk over header. */ |
r = (runtime_pseudo_reloc_item_v2 *) &v2_hdr[1]; |
for (; r < (runtime_pseudo_reloc_item_v2 *) end; r++) |
{ |
/* location where new address will be written */ |
reloc_target = (ptrdiff_t) base + r->target; |
/* get sym pointer. It points either to the iat entry |
* of the referenced element, or to the stub function. |
*/ |
addr_imp = (ptrdiff_t) base + r->sym; |
addr_imp = *((ptrdiff_t *) addr_imp); |
/* read existing relocation value from image, casting to the |
* bitsize indicated by the 8 LSBs of flags. If the value is |
* negative, manually sign-extend to ptrdiff_t width. Raise an |
* error if the bitsize indicated by the 8 LSBs of flags is not |
* supported. |
*/ |
switch ((r->flags & 0xff)) |
{ |
case 8: |
reldata = (ptrdiff_t) (*((unsigned char *)reloc_target)); |
if ((reldata & 0x80) != 0) |
reldata |= ~((ptrdiff_t) 0xff); |
break; |
case 16: |
reldata = (ptrdiff_t) (*((unsigned short *)reloc_target)); |
if ((reldata & 0x8000) != 0) |
reldata |= ~((ptrdiff_t) 0xffff); |
break; |
case 32: |
reldata = (ptrdiff_t) (*((unsigned int *)reloc_target)); |
break; |
default: |
reldata=0; |
// printf(" Unknown pseudo relocation bit size %d.\n", |
// (int) (r->flags & 0xff)); |
break; |
} |
/* Adjust the relocation value */ |
reldata -= ((ptrdiff_t) base + r->sym); |
reldata += addr_imp; |
/* Write the new relocation value back to *reloc_target */ |
switch ((r->flags & 0xff)) |
{ |
case 8: |
*(uint8_t*)reloc_target = (uint8_t)reldata; |
break; |
case 16: |
*(uint16_t*)reloc_target = (uint16_t)reldata; |
break; |
case 32: |
*(uint32_t*)reloc_target = (uint32_t)reldata; |
break; |
} |
} |
} |
void |
_pei386_runtime_relocator (void) |
{ |
static int was_init = 0; |
if (was_init) |
return; |
++was_init; |
do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__, |
&__RUNTIME_PSEUDO_RELOC_LIST_END__, |
&_image_base__); |
} |
/contrib/sdk/sources/libc/crt/dllstart.c |
---|
0,0 → 1,27 |
extern void _pei386_runtime_relocator (void); |
typedef void (*ctp)(); |
static void __do_global_ctors () |
{ |
extern int __CTOR_LIST__; |
int *c = &__CTOR_LIST__; |
c++; |
while (*c) |
{ |
ctp d = (ctp)*c; |
(d)(); |
c++; |
} |
} |
int __attribute__((externally_visible)) DllStartup(void *module, int reason) |
{ |
if(reason == 1) |
{ |
_pei386_runtime_relocator(); |
__do_global_ctors(); |
}; |
return 1; |
}; |
/contrib/sdk/sources/libc/crt/chkstk.S |
---|
0,0 → 1,61 |
.global ___chkstk |
.global ___chkstk_ms |
.global __alloca |
.section .text |
#.def ___chkstk; .scl 2; .type 32; .endef |
#.def ___chkstk_ms; .scl 2; .type 32; .endef |
#.def __alloca; .scl 2; .type 32; .endef |
___chkstk: |
__alloca: |
pushl %ecx /* save temp */ |
leal 8(%esp), %ecx /* point past return addr */ |
subl %eax, %ecx |
cmpl %fs:8, %ecx # check low stack limit |
jb 1f |
movl %esp, %eax /* save old stack pointer */ |
movl %ecx, %esp /* decrement stack */ |
movl (%eax), %ecx /* recover saved temp */ |
movl 4(%eax), %eax /* recover return address */ |
/* Push the return value back. Doing this instead of just |
jumping to %eax preserves the cached call-return stack |
used by most modern processors. */ |
pushl %eax |
ret |
1: |
int3 #trap to debugger |
.ascii "Stack overflow" |
___chkstk_ms: |
pushl %ecx /* save temp */ |
pushl %eax |
cmpl $0x1000, %eax /* > 4k ?*/ |
leal 12(%esp), %ecx /* point past return addr */ |
jb 2f |
1: |
subl $0x1000, %ecx /* yes, move pointer down 4k*/ |
cmpl %fs:8, %ecx /* check low stack limit */ |
jb 3f |
orl $0x0, (%ecx) /* probe there */ |
subl $0x1000, %eax /* decrement count */ |
cmpl $0x1000, %eax |
ja 1b /* and do it again */ |
2: |
subl %eax, %ecx |
orl $0x0, (%ecx) /* less than 4k, just peek here */ |
popl %eax |
popl %ecx |
ret |
3: |
int3 #trap to debugger |
.ascii "Stack overflow" |
/contrib/sdk/sources/libc/crt/cpu_features.c |
---|
0,0 → 1,72 |
#include "cpu_features.h" |
/* level 1 edx bits */ |
#define EDX_CX8 (1 << 8) /* CMPXCHG8B */ |
#define EDX_CMOV (1 << 15) |
#define EDX_MMX (1 << 23) |
#define EDX_FXSR (1 << 24) /* FXSAVE and FXRSTOR */ |
#define EDX_SSE (1 << 25) |
#define EDX_SSE2 (1 << 26) |
/* level 1 ecx bits */ |
#define ECX_SSE3 (1 << 0) |
#define ECX_CX16 (1 << 13) /* CMPXCHG16B */ |
/* extended level 0x80000001 edx bits */ |
#define EDX_3DNOW (1 << 31) |
#define EDX_3DNOWP (1 << 30) |
#define EDX_LM (1 << 29) /*LONG MODE */ |
#define __cpuid(level,a,b,c,d) \ |
__asm__ __volatile__ ("cpuid;" \ |
: "=a" (a), "=b" (b), "=c" (c), "=d" (d)\ |
: "0" (level)) |
/* Combine the different cpuid flags into a single bitmap. */ |
unsigned int __cpu_features = 0; |
void __cpu_features_init (void) |
{ |
unsigned int eax, ebx, ecx, edx; |
__cpuid (0, eax, ebx, ecx, edx); |
if (eax == 0) |
return; |
__cpuid (1, eax, ebx, ecx, edx); |
if (edx & EDX_CX8) |
__cpu_features |= _CRT_CMPXCHG8B; |
if (edx & EDX_CMOV) |
__cpu_features |= _CRT_CMOV; |
if (edx & EDX_MMX) |
__cpu_features |= _CRT_MMX; |
if (edx & EDX_FXSR) |
__cpu_features |= _CRT_FXSR; |
if (edx & EDX_SSE) |
__cpu_features |= _CRT_SSE; |
if (edx & EDX_SSE2) |
__cpu_features |= _CRT_SSE2; |
if (ecx & ECX_SSE3) |
__cpu_features |= _CRT_SSE3; |
if (ecx & ECX_CX16) |
__cpu_features |= _CRT_CMPXCHG16B; |
__cpuid (0x80000000, eax, ebx, ecx, edx); |
if (eax < 0x80000001) |
return; |
__cpuid (0x80000001, eax, ebx, ecx, edx); |
if (edx & EDX_3DNOW) |
__cpu_features |= _CRT_3DNOW; |
if (edx & EDX_3DNOWP) |
__cpu_features |= _CRT_3DNOWP; |
return; |
} |
/contrib/sdk/sources/libc/crt/cpu_features.h |
---|
0,0 → 1,21 |
#ifndef _CPU_FEATURES_H |
#define _CPU_FEATURES_H |
#define _CRT_CMPXCHG8B 0x0001 |
#define _CRT_CMOV 0x0002 |
#define _CRT_MMX 0x0004 |
#define _CRT_FXSR 0x0008 |
#define _CRT_SSE 0x0010 |
#define _CRT_SSE2 0x0020 |
#define _CRT_SSE3 0x0040 |
#define _CRT_CMPXCHG16B 0x0080 |
#define _CRT_3DNOW 0x0100 |
#define _CRT_3DNOWP 0x0200 |
extern unsigned int __cpu_features; |
/* Currently we use this in fpenv functions */ |
#define __HAS_SSE __cpu_features & _CRT_SSE |
#endif |
/contrib/sdk/sources/libc/crt/crt1.c |
---|
0,0 → 1,137 |
/* |
* crt1.c |
* This file has no copyright assigned and is placed in the Public Domain. |
* This file is a part of the mingw-runtime package. |
* No warranty is given; refer to the file DISCLAIMER within the package. |
* |
* Source code for the startup proceedures used by all programs. This code |
* is compiled to make crt1.o, which should be located in the library path. |
* |
*/ |
/* Hide the declaration of _fmode with dllimport attribute in stdlib.h to |
avoid problems with older GCC. */ |
#include <newlib.h> |
#include <stdint.h> |
#include <stdlib.h> |
#include <string.h> |
#include <stdio.h> |
#include <sys/kos_io.h> |
#include "cpu_features.h" |
/* NOTE: The code for initializing the _argv, _argc, and environ variables |
* has been moved to a separate .c file which is included in both |
* crt1.c and dllcrt1.c. This means changes in the code don't have to |
* be manually synchronized, but it does lead to this not-generally- |
* a-good-idea use of include. */ |
extern char __cmdline[]; |
extern char __pgmname[]; |
extern int main (int, char **, char **); |
int _errno; |
int _fmode; |
char __appcwd[1024]; |
int __appcwdlen; |
int _argc; |
char **_argv; |
static char *arg[2]; |
void _exit(int __status) __attribute__((noreturn)); |
char * __libc_getenv(const char *name) |
{ |
return NULL; |
} |
void __main (){}; |
struct app_hdr |
{ |
char banner[8]; |
int version; |
int start; |
int iend; |
int memsize; |
int stacktop; |
char *cmdline; |
char *path; |
}; |
typedef void (*ctp)(); |
static void __do_global_ctors () |
{ |
extern int __CTOR_LIST__; |
int *c = &__CTOR_LIST__; |
c++; |
while (*c) |
{ |
ctp d = (ctp)*c; |
(d)(); |
c++; |
} |
} |
void __attribute__((noreturn)) |
__crt_startup (void) |
{ |
int nRet; |
struct app_hdr *header; |
init_global_reent(); |
/* |
* Initialize floating point unit. |
*/ |
__cpu_features_init (); /* Do we have SSE, etc.*/ |
// _fpreset (); /* Supplied by the runtime library. */ |
__do_global_ctors(); |
__appcwdlen = strrchr(&__pgmname[0], '/') - &__pgmname[0] + 1; |
__appcwdlen = __appcwdlen > 1023 ? 1023 : __appcwdlen; |
memcpy(__appcwd, &__pgmname, __appcwdlen); |
__appcwd[__appcwdlen] = 0; |
set_cwd(__appcwd); |
arg[0] = &__pgmname[0]; |
if( __cmdline[0] != 0) |
{ |
_argc = 2; |
arg[1] = &__cmdline[0]; |
} else _argc = 1; |
_argv = arg; |
/* |
* Sets the default file mode. |
* If _CRT_fmode is set, also set mode for stdin, stdout |
* and stderr, as well |
* NOTE: DLLs don't do this because that would be rude! |
*/ |
// _mingw32_init_fmode (); |
nRet = main (_argc, _argv, NULL); |
/* |
* Perform exit processing for the C library. This means |
* flushing output and calling 'atexit' registered functions. |
*/ |
exit (nRet); |
} |
/contrib/sdk/sources/libc/crt/crt2.c |
---|
0,0 → 1,22 |
#include <newlib.h> |
void init_reent(); |
void __attribute__((noreturn)) |
__thread_startup (int (*entry)(void*), void *param, |
void *stacklow, void *stackhigh) |
{ |
int retval; |
__asm__ __volatile__( // save stack limits |
"movl %0, %%fs:8 \n\t" // use TLS |
"movl %1, %%fs:12 \n\t" |
::"r"(stacklow), "r"(stackhigh)); |
init_reent(); // initialize thread reentry structure |
retval = entry(param); // call user thread function |
_exit(retval); |
}; |
/contrib/sdk/sources/libc/crt/crt_amz.S |
---|
0,0 → 1,24 |
.global __start |
.global ___main |
.global _DllMainCRTStartup |
.section .init |
.def __start; .scl 2; .type 32; .endef |
.def _DllMainCRTStartup; .scl 2; .type 32; .endef |
.align 4 |
__start: |
_DllMainCRTStartup: |
call __pei386_runtime_relocator |
jmp _main |
.align 4 |
___main: |
ret |
/contrib/sdk/sources/libc/crt/crtbegin.c |
---|
0,0 → 1,15 |
extern void _pei386_runtime_relocator (void); |
int DllStartup(void *module, int reason) |
{ |
_pei386_runtime_relocator(); |
return 1; |
}; |
void ___dll_start () |
{ |
_pei386_runtime_relocator(); |
} |
/contrib/sdk/sources/libc/crt/crtdll.c |
---|
0,0 → 1,125 |
#include <_ansi.h> |
#include <reent.h> |
#include <stdint.h> |
#include <stdlib.h> |
#include <string.h> |
#include <stdio.h> |
#include <unistd.h> |
#include <setjmp.h> |
#include <sys/kos_io.h> |
struct app_hdr |
{ |
char banner[8]; |
int version; |
int start; |
int iend; |
int memsize; |
int stacktop; |
char *cmdline; |
char *path; |
int reserved; |
void *__idata_start; |
void *__idata_end; |
int (*main)(int argc, char **argv, char **envp); |
}; |
int _argc; |
char **_argv; |
void* get_entry_point(void *raw); |
int (*entry)(int, char **, char **); |
void init_loader(void *libc_image); |
void init_reent(); |
jmp_buf loader_env; |
void __attribute__((noreturn)) |
__thread_startup (int (*entry)(void*), void *param, |
void *stacklow, void *stackhigh) |
{ |
int retval; |
asm volatile ( "xchgw %bx, %bx"); |
__asm__ __volatile__( // save stack limits |
"movl %0, %%fs:8 \n\t" // use TLS |
"movl %1, %%fs:12 \n\t" |
::"r"(stacklow), "r"(stackhigh)); |
init_reent(); // initialize thread reentry structure |
retval = entry(param); // call user thread function |
_exit(retval); |
}; |
char * __libc_getenv(const char *name) |
{ |
return NULL; |
} |
void _pei386_runtime_relocator (void); |
int link_app(); |
char __appcwd[1024]; |
int __appcwdlen; |
char* __appenv; |
int __appenv_size; |
static char *arg[2]; |
extern char _tls_map[128]; |
void __attribute__((noreturn)) |
libc_crt_startup (void *libc_base) |
{ |
struct app_hdr *header = NULL; |
int len; |
char *p; |
void *my_app; |
int retval = 0; |
_pei386_runtime_relocator(); |
memset(_tls_map, 0xFF, 32*4); |
_tls_map[0] = 0xE0; |
init_reent(); |
__initPOSIXHandles(); |
// __appenv = load_file("/sys/system.env", &__appenv_size); |
init_loader(libc_base); |
if( link_app() == 0) |
goto done; |
__appcwdlen = strrchr(header->path, '/') - header->path; |
__appcwdlen = __appcwdlen > 1022 ? 1022 : __appcwdlen; |
memcpy(__appcwd, header->path, __appcwdlen); |
set_cwd(__appcwd); |
arg[0] = header->path; |
if( header->cmdline[0] != 0) |
{ |
_argc = 2; |
arg[1] = header->cmdline; |
} |
else _argc = 1; |
_argv = arg; |
retval = header->main(_argc, _argv, NULL); |
done: |
exit (retval); |
} |
/contrib/sdk/sources/libc/crt/exit.S |
---|
0,0 → 1,20 |
.section .text |
.global __exit |
.global __Exit |
.align 4 |
__exit: |
__Exit: |
movl 4(%esp), %edx #store exit code |
movl $68, %eax |
movl $13, %ebx |
movl %fs:8, %ecx |
int $0x40 #destroy stack |
movl $-1, %eax |
int $0x40 #terminate thread |
/contrib/sdk/sources/libc/crt/i386mach.h |
---|
0,0 → 1,76 |
/* This file was based on the modified setjmp.S performed by |
* Joel Sherill (joel@OARcorp.com) which specified the use |
* of the __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ macros. |
** |
** This file is distributed WITHOUT ANY WARRANTY; without even the implied |
** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* These are predefined by new versions of GNU cpp. */ |
#ifndef __USER_LABEL_PREFIX__ |
#define __USER_LABEL_PREFIX__ _ |
#endif |
#define __REG_PREFIX__ % |
/* ANSI concatenation macros. */ |
#define CONCAT1(a, b) CONCAT2(a, b) |
#define CONCAT2(a, b) a##b |
/* Use the right prefix for global labels. */ |
#define SYM(x) CONCAT1(__USER_LABEL_PREFIX__, x) |
/* Use the right prefix for registers. */ |
#define REG(x) CONCAT1(__REG_PREFIX__, x) |
#define eax REG(eax) |
#define ebx REG(ebx) |
#define ecx REG(ecx) |
#define edx REG(edx) |
#define esi REG(esi) |
#define edi REG(edi) |
#define ebp REG(ebp) |
#define esp REG(esp) |
#define st0 REG(st) |
#define st1 REG(st(1)) |
#define st2 REG(st(2)) |
#define st3 REG(st(3)) |
#define st4 REG(st(4)) |
#define st5 REG(st(5)) |
#define st6 REG(st(6)) |
#define st7 REG(st(7)) |
#define ax REG(ax) |
#define bx REG(bx) |
#define cx REG(cx) |
#define dx REG(dx) |
#define ah REG(ah) |
#define bh REG(bh) |
#define ch REG(ch) |
#define dh REG(dh) |
#define al REG(al) |
#define bl REG(bl) |
#define cl REG(cl) |
#define dl REG(dl) |
#define mm1 REG(mm1) |
#define mm2 REG(mm2) |
#define mm3 REG(mm3) |
#define mm4 REG(mm4) |
#define mm5 REG(mm5) |
#define mm6 REG(mm6) |
#define mm7 REG(mm7) |
#ifdef _I386MACH_NEED_SOTYPE_FUNCTION |
#define SOTYPE_FUNCTION(sym) .type SYM(sym),@function |
#else |
#define SOTYPE_FUNCTION(sym) |
#endif |
/contrib/sdk/sources/libc/crt/opendial.S |
---|
0,0 → 1,149 |
format MS COFF |
public _get_moviefile |
section '.text' align 16 |
align 4 |
getprocaddress: |
mov edx, [esp + 8] ; hlib |
xor eax, eax |
test edx, edx ; If hlib = 0 then goto .end |
jz .end |
.next: |
cmp [edx], dword 0 ; If end of export table then goto .end |
jz .end |
xor eax, eax |
mov esi, [edx] |
mov edi, [esp + 4] ; name |
.next_: |
lodsb |
scasb |
jne .fail |
or al, al |
jnz .next_ |
jmp .ok |
.fail: |
add edx, 8 |
jmp .next |
.ok: ; return address |
mov eax, [edx + 4] |
.end: |
ret 8 |
align 8 |
_get_moviefile: |
pushad |
mov eax, 68 |
mov ebx, 19 |
mov ecx, sz_proc_lib |
int 0x40 |
mov [proclib], eax |
test eax, eax |
jz .fail |
push [proclib] |
push sz_OpenDialog_init |
call getprocaddress |
mov [opendialog_init], eax |
push dword[proclib] |
push sz_OpenDialog_start |
call getprocaddress |
mov [opendialog_start], eax |
mov eax, 68 |
mov ebx, 12 |
mov ecx, 4096*3 |
int 0x40 |
mov [od.procinfo], eax |
add eax, 1024 |
mov [od.filename_area], eax |
add eax, 3072 |
mov [od.opendir_path], eax |
add eax, 4096 |
mov [od.openfile_path], eax |
push od |
call [opendialog_init] |
mov eax, [od.openfile_path] |
mov [eax], byte 0 ; end of ASCIIZ-string(may be don't need?) |
push od |
call [opendialog_start] |
popad |
mov eax, [od.openfile_path]; selected filePath |
ret |
.fail: |
xor eax, eax |
ret |
align 4 |
fake_on_redraw: |
ret |
section '.rdata' align 16 |
sz_proc_lib db "/rd/1/lib/proc_lib.obj",0 |
sz_OpenDialog_init db "OpenDialog_init",0 |
sz_OpenDialog_start db "OpenDialog_start",0 |
sz_com_area_name db "FFFFFFFF_open_dialog",0 |
sz_dir_default_path db "/rd/1",0 |
sz_start_path db "/rd/1/File managers/opendial",0 |
section '.data' align 16 |
od: |
.mode dd 0 |
.procinfo dd 0 |
.com_area_name dd sz_com_area_name |
.com_area dd 0 |
.opendir_path dd 0 |
.dir_default_path dd sz_dir_default_path |
.start_path dd sz_start_path |
.draw_window dd fake_on_redraw |
.status dd 0 |
.openfile_path dd 0 |
.filename_area dd 0 |
.filter_area dd filefilter |
.x_size dw 512 |
.x_start dw 512 |
.y_size dw 512 |
.y_start dw 512 |
filefilter: |
dd filefilter.end - filefilter |
db 'avi',0 |
db 'flv',0 |
db 'mov',0 |
db 'mpg',0 |
db 'mpeg',0 |
db 'mkv',0 |
db 'mp4',0 |
db 'webm',0 |
db 'wmv',0 |
.end: |
db 0 |
section '.bss' align 16 |
proclib dd ? |
opendialog_init dd ? |
opendialog_start dd ? |
/contrib/sdk/sources/libc/crt/setjmp.S |
---|
0,0 → 1,89 |
/* This is file is a merger of SETJMP.S and LONGJMP.S */ |
/* |
* This file was modified to use the __USER_LABEL_PREFIX__ and |
* __REGISTER_PREFIX__ macros defined by later versions of GNU cpp by |
* Joel Sherrill (joel@OARcorp.com) |
* Slight change: now includes i386mach.h for this (Werner Almesberger) |
* |
* Copyright (C) 1991 DJ Delorie |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms is permitted |
* provided that the above copyright notice and following paragraph are |
* duplicated in all such forms. |
* |
* This file is distributed WITHOUT ANY WARRANTY; without even the implied |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
** jmp_buf: |
** eax ebx ecx edx esi edi ebp esp eip |
** 0 4 8 12 16 20 24 28 32 |
*/ |
#include "i386mach.h" |
.global SYM (setjmp) |
.global SYM (longjmp) |
SOTYPE_FUNCTION(setjmp) |
SOTYPE_FUNCTION(longjmp) |
.def _setjmp; .scl 2; .type 32; .endef |
SYM (setjmp): |
pushl ebp |
movl esp,ebp |
pushl edi |
movl 8 (ebp),edi |
movl eax,0 (edi) |
movl ebx,4 (edi) |
movl ecx,8 (edi) |
movl edx,12 (edi) |
movl esi,16 (edi) |
movl -4 (ebp),eax |
movl eax,20 (edi) |
movl 0 (ebp),eax |
movl eax,24 (edi) |
movl esp,eax |
addl $12,eax |
movl eax,28 (edi) |
movl 4 (ebp),eax |
movl eax,32 (edi) |
popl edi |
movl $0,eax |
leave |
ret |
.def _longjmp; .scl 2; .type 32; .endef |
SYM (longjmp): |
pushl ebp |
movl esp,ebp |
movl 8(ebp),edi /* get jmp_buf */ |
movl 12(ebp),eax /* store retval in j->eax */ |
movl eax,0(edi) |
movl 24(edi),ebp |
movl 28(edi),esp |
pushl 32(edi) |
movl 0(edi),eax |
movl 4(edi),ebx |
movl 8(edi),ecx |
movl 12(edi),edx |
movl 16(edi),esi |
movl 20(edi),edi |
ret |
/contrib/sdk/sources/libc/crt/start.S |
---|
0,0 → 1,46 |
.section .init |
.global __start |
#tls:0 pid process id |
#tls:4 tid reserved for thread slot |
#tls:8 thread's stack low limit |
#tls:12 thread's stack high limit |
#tls:16 reseved for libc |
.align 4 |
__start: |
movl $68, %eax |
movl $12, %ebx |
lea __size_of_stack_reserve__, %ecx |
addl $4095, %ecx #load stack size |
andl $-4096, %ecx #align to page granularity |
int $0x40 #and allocate |
testl %eax, %eax |
jz 1f |
addl %eax, %ecx |
movl %eax, %fs:8 |
movl %ecx, %fs:12 #save stack base - low limit |
#save stack top - high limit |
movl %ecx, %esp #reload stack |
subl $1024, %esp |
movl $9, %eax |
movl %esp, %ebx |
movl $-1, %ecx |
int $0x40 |
movl 30(%ebx), %eax |
movl %eax, %fs:0 #save pid |
addl $1024, %esp |
jmp ___crt_startup |
1: |
int3 #trap to debugger |
.ascii "No enough memory for stack allocation" |
/contrib/sdk/sources/libc/crt/thread.S |
---|
0,0 → 1,48 |
.global _create_thread |
.global ___thread_startup |
.section .text |
.def _create_thread; .scl 2; .type 32; .endef |
.align 4 |
_create_thread: |
#.thr_proc equ esp+8 |
#.param equ esp+12 |
#.stack_size equ esp+16 |
pushl %ebx |
movl $68, %eax |
movl $12, %ebx |
movl 16(%esp), %ecx #[.stack_size] |
addl $4095, %ecx |
andl $-4096, %ecx |
movl %ecx, 16(%esp) #save stack size |
int $0x40 |
testl %eax, %eax |
jz 1f |
leal -20(%eax,%ecx), %edx |
movl 8(%esp), %ebx #[.thr_proc] |
mov %ebx, 4(%edx) |
movl 12(%esp), %ebx #[.param] |
movl %ebx, 8(%edx) |
addl %eax, %ecx |
movl %eax, 12(%edx) #stack low limit |
movl %ecx, 16(%edx) #stack high limit |
movl $51, %eax |
movl $1, %ebx |
lea ___thread_startup , %ecx |
int $0x40 |
popl %ebx |
ret |
1: |
notl %eax |
popl %ebx |
ret |
/contrib/sdk/sources/libc/crt/tls.S |
---|
0,0 → 1,48 |
.section .text |
.global _tls_alloc |
.global __tls_map |
.align 4 |
_tls_alloc: |
pushl $tls_mutex |
call ___mutex_lock |
popl %eax |
movl tls_map_start, %edx |
.align 4 |
.test: |
bsfl (%edx), %eax |
jnz .done |
add $4, %edx |
cmpl $128+__tls_map, %edx |
jb .test |
xorl %eax, %eax |
mov %eax, tls_mutex |
ret |
.done: |
btrl %eax, (%edx) |
movl %edx, tls_map_start |
movl $0, tls_mutex |
subl $__tls_map, %edx |
leal (%eax, %edx, 8), %eax |
shll $2, %eax |
ret |
.section .data |
tls_mutex: .long(0) |
tls_map_start: .long(__tls_map) |
.section .bss |
.align 16 |
__tls_map: .space 128 |
/contrib/sdk/sources/libc/libc.def |
---|
0,0 → 1,509 |
EXPORTS |
_Balloc |
_Bfree |
_Exit DATA |
__assert |
__assert_func |
__ctype_ptr__ DATA |
__emutls_get_address |
__errno |
__fpclassifyd |
__fpclassifyf |
__mutex_lock |
__signbitd |
__signbitf |
__srget_r |
__swbuf_r |
_atoi_r |
_atol_r |
_buf_findstr |
_calloc_r |
_cleanup |
_cleanup_r |
_close_r |
_ctype_ DATA |
_daylight DATA |
_diprintf_r |
_dprintf_r |
_dtoa_r |
_exit DATA |
_f_atan2 DATA |
_f_atan2f DATA |
_f_exp |
_f_expf |
_f_frexp DATA |
_f_frexpf DATA |
_f_ldexp DATA |
_f_ldexpf DATA |
_f_llrint |
_f_llrintf |
_f_llrintl |
_f_log DATA |
_f_log10 DATA |
_f_log10f DATA |
_f_logf DATA |
_f_lrint |
_f_lrintf |
_f_lrintl |
_f_pow |
_f_powf |
_f_rint |
_f_rintf |
_f_rintl |
_f_tan DATA |
_f_tanf DATA |
_fclose_r |
_fdopen_r |
_fflush_r |
_fgetc_r |
_fgets_r |
_findenv |
_fiprintf_r |
_fiscanf_r |
_fopen_r |
_fprintf_r |
_fputc_r |
_fputs_r |
_fputwc_r |
_fread_r |
_free_r |
_freopen_r |
_fscanf_r |
_fseek_r |
_fseeko_r |
_fstat_r |
_ftell_r |
_ftello_r |
_fwalk |
_fwalk_reent |
_fwrite_r |
_gettimeofday |
_gettimeofday_r |
_global_impure_ptr DATA |
_grow_handles |
_init_signal |
_init_signal_r |
_isatty |
_isatty_r |
_kill_r |
_localeconv_r |
_lseek_r |
_malloc_r |
_mbrtowc_r |
_mbtowc_r |
_mktm_r |
_mprec_log10 |
_open_r |
_printf_r |
_putc_r |
_putchar_r |
_puts_r |
_raise_r |
_read |
_read_r |
_realloc_r |
_remove_r |
_rename_r |
_seed48_r |
_setlocale_r |
_sfread_r |
_signal_r |
_siprintf_r |
_sniprintf_r |
_snprintf_r |
_sprintf_r |
_srand48_r |
_sscanf_r |
_strdup_r |
_strerror_r |
_strndup_r |
_strtod_r |
_strtol_r |
_strtoll_r |
_strtoul_r |
_strtoull_r |
_sungetc_r |
_svfiprintf_r |
_svfprintf_r |
_system_r |
_tempnam_r |
_times_r |
_timezone DATA |
_tls_map DATA |
_tmpfile_r |
_tmpnam_r |
_towctrans_r |
_tzname DATA |
_ungetc_r |
_user_strerror |
_vasniprintf_r |
_vasnprintf_r |
_vdiprintf_r |
_vdprintf_r |
_vfiprintf_r |
_vfiscanf_r |
_vfprintf_r |
_vfscanf_r |
_vscanf_r |
_vsnprintf_r |
_vsprintf_r |
_vsscanf_r |
_wcrtomb_r |
_wctomb_r |
_wctrans_r |
_wctype_r |
_write_r |
abort |
abs |
acos |
acosf |
acosh |
acoshf |
asctime |
asctime_r |
asin |
asinf |
asinh |
asinhf |
atan |
atan2 |
atan2f |
atanf |
atanh |
atanhf |
atexit |
atof |
atoi |
atol |
bsearch |
calloc |
cbrt |
cbrtf |
ceil |
ceilf |
clearerr |
clock |
close |
copysign |
copysignf |
cos |
cosf |
cosh |
coshf |
create_file |
create_image |
create_thread |
ctime |
ctime_r |
debugwrite |
delete_file |
difftime |
diprintf |
div |
dprintf |
drem |
dremf |
entry DATA |
envz_get |
erf |
erfc |
erfcf |
erff |
exit |
exp |
exp10 |
exp10f |
exp2 |
exp2f |
expf |
expm1 |
expm1f |
fabs |
fabsf |
fclose |
fdim |
fdimf |
fdopen |
fflush |
fgetc |
fgets |
fileno |
finite |
finitef |
fiprintf |
fiscanf |
floor |
floorf |
fma |
fmaf |
fmax |
fmaxf |
fmin |
fminf |
fmod |
fmodf |
fopen |
fprintf |
fputc |
fputs |
fputwc |
fread |
free |
freopen |
frexp |
frexpf |
fscanf |
fseek |
fseeko |
fstat |
ftell |
ftello |
fwrite |
gamma |
gamma_r |
gammaf |
gammaf_r |
get_entry_point |
get_fileinfo |
get_proc_address |
getenv |
gettimeofday |
gmtime |
gmtime_r |
hypot |
hypotf |
ilogb |
ilogbf |
infinity |
infinityf |
init_global_reent |
init_loader |
init_reent |
isalnum |
isalpha |
isascii |
isblank |
iscntrl |
isdigit |
isgraph |
isinf |
isinff |
islower |
isnan |
isnanf |
isprint |
ispunct |
isspace |
isupper |
iswalnum |
iswalpha |
iswblank |
iswcntrl |
iswctype |
iswdigit |
iswgraph |
iswlower |
iswprint |
iswpunct |
iswspace |
iswupper |
iswxdigit |
isxdigit |
j0 |
j0f |
j1 |
j1f |
jn |
jnf |
ldexp |
ldexpf |
lgamma |
lgamma_r |
lgammaf |
lgammaf_r |
libc_crt_startup |
link_app |
link_image |
llrint |
llrintf |
llrintl |
llround |
llroundf |
load_library |
loader_env DATA |
localeconv |
localtime |
localtime_r |
log |
log10 |
log10f |
log1p |
log1pf |
log2 |
log2f |
logb |
logbf |
logf |
longjmp |
lrint |
lrintf |
lrintl |
lround |
lroundf |
lseek |
malloc |
matherr |
mbrtowc |
mbtowc |
memalign |
memchr |
memcmp |
memcpy |
memmove |
memset |
mktime |
modf |
modff |
nan |
nanf |
nearbyint |
nearbyintf |
nextafter |
nextafterf |
open |
path_list DATA |
pow |
pow10 |
pow10f |
powf |
printf |
putc |
putchar |
puts |
qsort |
raise |
rand |
rand_r |
read |
read_file |
realloc |
remainder |
remainderf |
remove |
remquo |
remquof |
rename |
rint |
rintf |
rintl |
round |
roundf |
scalb |
scalbf |
scalbln |
scalblnf |
scalbn |
scalbnf |
seed48 |
set_file_size |
setjmp |
setlocale |
setvbuf |
signal |
significand |
significandf |
sin |
sincos |
sincosf |
sinf |
sinh |
sinhf |
siprintf |
sniprintf |
snprintf |
sprintf |
sqrt |
sqrtf |
srand |
srand48 |
sscanf |
stpcpy |
stpncpy |
strcasecmp |
strcasestr |
strcat |
strchr |
strcmp |
strcoll |
strcpy |
strcspn |
strdup |
strerror |
strftime |
strlen |
strncasecmp |
strncat |
strncmp |
strncpy |
strndup |
strnlen |
strpbrk |
strrchr |
strsep |
strspn |
strstr |
strtod |
strtof |
strtok |
strtok_r |
strtol |
strtoll |
strtoul |
strtoull |
strupr |
system |
tan |
tanf |
tanh |
tanhf |
tempnam |
tgamma |
tgammaf |
time |
tls_alloc DATA |
tmpfile |
tmpnam |
toascii |
tolower |
toupper |
towctrans |
towlower |
towupper |
trunc |
truncf |
ungetc |
user_alloc |
validate_pe |
vasniprintf |
vasnprintf |
vdiprintf |
vdprintf |
vfiprintf |
vfiscanf |
vfprintf |
vfscanf |
vscanf |
vsnprintf |
vsprintf |
vsscanf |
wcrtomb |
wctrans |
wctype |
write |
write_file |
y0 |
y0f |
y1 |
y1f |
yn |
ynf |
/contrib/sdk/sources/libc/libc.orig.def |
---|
0,0 → 1,509 |
EXPORTS |
_Balloc @1 |
_Bfree @2 |
_Exit @3 DATA |
__assert @4 |
__assert_func @5 |
__ctype_ptr__ @6 DATA |
__emutls_get_address @7 |
__errno @8 |
__fpclassifyd @9 |
__fpclassifyf @10 |
__mutex_lock @11 |
__signbitd @12 |
__signbitf @13 |
__srget_r @14 |
__swbuf_r @15 |
_atoi_r @16 |
_atol_r @17 |
_buf_findstr @18 |
_calloc_r @19 |
_cleanup @20 |
_cleanup_r @21 |
_close_r @22 |
_ctype_ @23 DATA |
_daylight @24 DATA |
_diprintf_r @25 |
_dprintf_r @26 |
_dtoa_r @27 |
_exit @28 DATA |
_f_atan2 @29 DATA |
_f_atan2f @30 DATA |
_f_exp @31 |
_f_expf @32 |
_f_frexp @33 DATA |
_f_frexpf @34 DATA |
_f_ldexp @35 DATA |
_f_ldexpf @36 DATA |
_f_llrint @37 |
_f_llrintf @38 |
_f_llrintl @39 |
_f_log @40 DATA |
_f_log10 @41 DATA |
_f_log10f @42 DATA |
_f_logf @43 DATA |
_f_lrint @44 |
_f_lrintf @45 |
_f_lrintl @46 |
_f_pow @47 |
_f_powf @48 |
_f_rint @49 |
_f_rintf @50 |
_f_rintl @51 |
_f_tan @52 DATA |
_f_tanf @53 DATA |
_fclose_r @54 |
_fdopen_r @55 |
_fflush_r @56 |
_fgetc_r @57 |
_fgets_r @58 |
_findenv @59 |
_fiprintf_r @60 |
_fiscanf_r @61 |
_fopen_r @62 |
_fprintf_r @63 |
_fputc_r @64 |
_fputs_r @65 |
_fputwc_r @66 |
_fread_r @67 |
_free_r @68 |
_freopen_r @69 |
_fscanf_r @70 |
_fseek_r @71 |
_fseeko_r @72 |
_fstat_r @73 |
_ftell_r @74 |
_ftello_r @75 |
_fwalk @76 |
_fwalk_reent @77 |
_fwrite_r @78 |
_gettimeofday @79 |
_gettimeofday_r @80 |
_global_impure_ptr @81 DATA |
_grow_handles @82 |
_init_signal @83 |
_init_signal_r @84 |
_isatty @85 |
_isatty_r @86 |
_kill_r @87 |
_localeconv_r @88 |
_lseek_r @89 |
_malloc_r @90 |
_mbrtowc_r @91 |
_mbtowc_r @92 |
_mktm_r @93 |
_mprec_log10 @94 |
_open_r @95 |
_printf_r @96 |
_putc_r @97 |
_putchar_r @98 |
_puts_r @99 |
_raise_r @100 |
_read @101 |
_read_r @102 |
_realloc_r @103 |
_remove_r @104 |
_rename_r @105 |
_seed48_r @106 |
_setlocale_r @107 |
_sfread_r @108 |
_signal_r @109 |
_siprintf_r @110 |
_sniprintf_r @111 |
_snprintf_r @112 |
_sprintf_r @113 |
_srand48_r @114 |
_sscanf_r @115 |
_strdup_r @116 |
_strerror_r @117 |
_strndup_r @118 |
_strtod_r @119 |
_strtol_r @120 |
_strtoll_r @121 |
_strtoul_r @122 |
_strtoull_r @123 |
_sungetc_r @124 |
_svfiprintf_r @125 |
_svfprintf_r @126 |
_system_r @127 |
_tempnam_r @128 |
_times_r @129 |
_timezone @130 DATA |
_tls_map @131 DATA |
_tmpfile_r @132 |
_tmpnam_r @133 |
_towctrans_r @134 |
_tzname @135 DATA |
_ungetc_r @136 |
_user_strerror @137 |
_vasniprintf_r @138 |
_vasnprintf_r @139 |
_vdiprintf_r @140 |
_vdprintf_r @141 |
_vfiprintf_r @142 |
_vfiscanf_r @143 |
_vfprintf_r @144 |
_vfscanf_r @145 |
_vscanf_r @146 |
_vsnprintf_r @147 |
_vsprintf_r @148 |
_vsscanf_r @149 |
_wcrtomb_r @150 |
_wctomb_r @151 |
_wctrans_r @152 |
_wctype_r @153 |
_write_r @154 |
abort @155 |
abs @156 |
acos @157 |
acosf @158 |
acosh @159 |
acoshf @160 |
asctime @161 |
asctime_r @162 |
asin @163 |
asinf @164 |
asinh @165 |
asinhf @166 |
atan @167 |
atan2 @168 |
atan2f @169 |
atanf @170 |
atanh @171 |
atanhf @172 |
atexit @173 |
atof @174 |
atoi @175 |
atol @176 |
bsearch @177 |
calloc @178 |
cbrt @179 |
cbrtf @180 |
ceil @181 |
ceilf @182 |
clearerr @183 |
clock @184 |
close @185 |
copysign @186 |
copysignf @187 |
cos @188 |
cosf @189 |
cosh @190 |
coshf @191 |
create_file @192 |
create_image @193 |
create_thread @194 |
ctime @195 |
ctime_r @196 |
debugwrite @197 |
delete_file @198 |
difftime @199 |
diprintf @200 |
div @201 |
dprintf @202 |
drem @203 |
dremf @204 |
entry @205 DATA |
envz_get @206 |
erf @207 |
erfc @208 |
erfcf @209 |
erff @210 |
exit @211 |
exp @212 |
exp10 @213 |
exp10f @214 |
exp2 @215 |
exp2f @216 |
expf @217 |
expm1 @218 |
expm1f @219 |
fabs @220 |
fabsf @221 |
fclose @222 |
fdim @223 |
fdimf @224 |
fdopen @225 |
fflush @226 |
fgetc @227 |
fgets @228 |
fileno @229 |
finite @230 |
finitef @231 |
fiprintf @232 |
fiscanf @233 |
floor @234 |
floorf @235 |
fma @236 |
fmaf @237 |
fmax @238 |
fmaxf @239 |
fmin @240 |
fminf @241 |
fmod @242 |
fmodf @243 |
fopen @244 |
fprintf @245 |
fputc @246 |
fputs @247 |
fputwc @248 |
fread @249 |
free @250 |
freopen @251 |
frexp @252 |
frexpf @253 |
fscanf @254 |
fseek @255 |
fseeko @256 |
fstat @257 |
ftell @258 |
ftello @259 |
fwrite @260 |
gamma @261 |
gamma_r @262 |
gammaf @263 |
gammaf_r @264 |
get_entry_point @265 |
get_fileinfo @266 |
get_proc_address @267 |
getenv @268 |
gettimeofday @269 |
gmtime @270 |
gmtime_r @271 |
hypot @272 |
hypotf @273 |
ilogb @274 |
ilogbf @275 |
infinity @276 |
infinityf @277 |
init_global_reent @278 |
init_loader @279 |
init_reent @280 |
isalnum @281 |
isalpha @282 |
isascii @283 |
isblank @284 |
iscntrl @285 |
isdigit @286 |
isgraph @287 |
isinf @288 |
isinff @289 |
islower @290 |
isnan @291 |
isnanf @292 |
isprint @293 |
ispunct @294 |
isspace @295 |
isupper @296 |
iswalnum @297 |
iswalpha @298 |
iswblank @299 |
iswcntrl @300 |
iswctype @301 |
iswdigit @302 |
iswgraph @303 |
iswlower @304 |
iswprint @305 |
iswpunct @306 |
iswspace @307 |
iswupper @308 |
iswxdigit @309 |
isxdigit @310 |
j0 @311 |
j0f @312 |
j1 @313 |
j1f @314 |
jn @315 |
jnf @316 |
ldexp @317 |
ldexpf @318 |
lgamma @319 |
lgamma_r @320 |
lgammaf @321 |
lgammaf_r @322 |
libc_crt_startup @323 |
link_app @324 |
link_image @325 |
llrint @326 |
llrintf @327 |
llrintl @328 |
llround @329 |
llroundf @330 |
load_library @331 |
loader_env @332 DATA |
localeconv @333 |
localtime @334 |
localtime_r @335 |
log @336 |
log10 @337 |
log10f @338 |
log1p @339 |
log1pf @340 |
log2 @341 |
log2f @342 |
logb @343 |
logbf @344 |
logf @345 |
longjmp @346 |
lrint @347 |
lrintf @348 |
lrintl @349 |
lround @350 |
lroundf @351 |
lseek @352 |
malloc @353 |
matherr @354 |
mbrtowc @355 |
mbtowc @356 |
memalign @357 |
memchr @358 |
memcmp @359 |
memcpy @360 |
memmove @361 |
memset @362 |
mktime @363 |
modf @364 |
modff @365 |
nan @366 |
nanf @367 |
nearbyint @368 |
nearbyintf @369 |
nextafter @370 |
nextafterf @371 |
open @372 |
path_list @373 DATA |
pow @374 |
pow10 @375 |
pow10f @376 |
powf @377 |
printf @378 |
putc @379 |
putchar @380 |
puts @381 |
qsort @382 |
raise @383 |
rand @384 |
rand_r @385 |
read @386 |
read_file @387 |
realloc @388 |
remainder @389 |
remainderf @390 |
remove @391 |
remquo @392 |
remquof @393 |
rename @394 |
rint @395 |
rintf @396 |
rintl @397 |
round @398 |
roundf @399 |
scalb @400 |
scalbf @401 |
scalbln @402 |
scalblnf @403 |
scalbn @404 |
scalbnf @405 |
seed48 @406 |
set_file_size @407 |
setjmp @408 |
setlocale @409 |
setvbuf @410 |
signal @411 |
significand @412 |
significandf @413 |
sin @414 |
sincos @415 |
sincosf @416 |
sinf @417 |
sinh @418 |
sinhf @419 |
siprintf @420 |
sniprintf @421 |
snprintf @422 |
sprintf @423 |
sqrt @424 |
sqrtf @425 |
srand @426 |
srand48 @427 |
sscanf @428 |
stpcpy @429 |
stpncpy @430 |
strcasecmp @431 |
strcasestr @432 |
strcat @433 |
strchr @434 |
strcmp @435 |
strcoll @436 |
strcpy @437 |
strcspn @438 |
strdup @439 |
strerror @440 |
strftime @441 |
strlen @442 |
strncasecmp @443 |
strncat @444 |
strncmp @445 |
strncpy @446 |
strndup @447 |
strnlen @448 |
strpbrk @449 |
strrchr @450 |
strsep @451 |
strspn @452 |
strstr @453 |
strtod @454 |
strtof @455 |
strtok @456 |
strtok_r @457 |
strtol @458 |
strtoll @459 |
strtoul @460 |
strtoull @461 |
strupr @462 |
system @463 |
tan @464 |
tanf @465 |
tanh @466 |
tanhf @467 |
tempnam @468 |
tgamma @469 |
tgammaf @470 |
time @471 |
tls_alloc @472 DATA |
tmpfile @473 |
tmpnam @474 |
toascii @475 |
tolower @476 |
toupper @477 |
towctrans @478 |
towlower @479 |
towupper @480 |
trunc @481 |
truncf @482 |
ungetc @483 |
user_alloc @484 |
validate_pe @485 |
vasniprintf @486 |
vasnprintf @487 |
vdiprintf @488 |
vdprintf @489 |
vfiprintf @490 |
vfiscanf @491 |
vfprintf @492 |
vfscanf @493 |
vscanf @494 |
vsnprintf @495 |
vsprintf @496 |
vsscanf @497 |
wcrtomb @498 |
wctrans @499 |
wctype @500 |
write @501 |
write_file @502 |
y0 @503 |
y0f @504 |
y1 @505 |
y1f @506 |
yn @507 |
ynf @508 |
/contrib/sdk/sources/libc/stdlib/assert.c |
---|
0,0 → 1,76 |
/* |
FUNCTION |
<<assert>>---macro for debugging diagnostics |
INDEX |
assert |
ANSI_SYNOPSIS |
#include <assert.h> |
void assert(int <[expression]>); |
DESCRIPTION |
Use this macro to embed debuggging diagnostic statements in |
your programs. The argument <[expression]> should be an |
expression which evaluates to true (nonzero) when your program |
is working as you intended. |
When <[expression]> evaluates to false (zero), <<assert>> |
calls <<abort>>, after first printing a message showing what |
failed and where: |
. Assertion failed: <[expression]>, file <[filename]>, line <[lineno]>, function: <[func]> |
If the name of the current function is not known (for example, |
when using a C89 compiler that does not understand __func__), |
the function location is omitted. |
The macro is defined to permit you to turn off all uses of |
<<assert>> at compile time by defining <<NDEBUG>> as a |
preprocessor variable. If you do this, the <<assert>> macro |
expands to |
. (void(0)) |
RETURNS |
<<assert>> does not return a value. |
PORTABILITY |
The <<assert>> macro is required by ANSI, as is the behavior |
when <<NDEBUG>> is defined. |
Supporting OS subroutines required (only if enabled): <<close>>, <<fstat>>, |
<<getpid>>, <<isatty>>, <<kill>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <assert.h> |
#include <stdlib.h> |
#include <stdio.h> |
#ifndef HAVE_ASSERT_FUNC |
/* func can be NULL, in which case no function information is given. */ |
void |
_DEFUN (__assert_func, (file, line, func, failedexpr), |
const char *file _AND |
int line _AND |
const char *func _AND |
const char *failedexpr) |
{ |
fiprintf(stderr, |
"assertion \"%s\" failed: file \"%s\", line %d%s%s\n", |
failedexpr, file, line, |
func ? ", function: " : "", func ? func : ""); |
abort(); |
/* NOTREACHED */ |
} |
#endif /* HAVE_ASSERT_FUNC */ |
void |
_DEFUN (__assert, (file, line, failedexpr), |
const char *file _AND |
int line _AND |
const char *failedexpr) |
{ |
__assert_func (file, line, NULL, failedexpr); |
/* NOTREACHED */ |
} |
/contrib/sdk/sources/libc/stdlib/atexit.c |
---|
0,0 → 1,66 |
/* |
* Copyright (c) 1990 Regents of the University of California. |
* All rights reserved. |
* |
* %sccs.include.redist.c% |
*/ |
/* |
FUNCTION |
<<atexit>>---request execution of functions at program exit |
INDEX |
atexit |
ANSI_SYNOPSIS |
#include <stdlib.h> |
int atexit (void (*<[function]>)(void)); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
int atexit ((<[function]>) |
void (*<[function]>)(); |
DESCRIPTION |
You can use <<atexit>> to enroll functions in a list of functions that |
will be called when your program terminates normally. The argument is |
a pointer to a user-defined function (which must not require arguments and |
must not return a result). |
The functions are kept in a LIFO stack; that is, the last function |
enrolled by <<atexit>> will be the first to execute when your program |
exits. |
There is no built-in limit to the number of functions you can enroll |
in this list; however, after every group of 32 functions is enrolled, |
<<atexit>> will call <<malloc>> to get space for the next part of the |
list. The initial list of 32 functions is statically allocated, so |
you can always count on at least that many slots available. |
RETURNS |
<<atexit>> returns <<0>> if it succeeds in enrolling your function, |
<<-1>> if it fails (possible only if no space was available for |
<<malloc>> to extend the list of functions). |
PORTABILITY |
<<atexit>> is required by the ANSI standard, which also specifies that |
implementations must support enrolling at least 32 functions. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <stdlib.h> |
#include "atexit.h" |
/* |
* Register a function to be performed at exit. |
*/ |
int |
_DEFUN (atexit, |
(fn), |
_VOID _EXFNPTR(fn, (_VOID))) |
{ |
return __register_exitproc (__et_atexit, fn, NULL, NULL); |
} |
/contrib/sdk/sources/libc/stdlib/__atexit.c |
---|
0,0 → 1,99 |
/* |
* Common routine to implement atexit-like functionality. |
*/ |
#include <stddef.h> |
#include <stdlib.h> |
#include <reent.h> |
#include <sys/lock.h> |
#include "atexit.h" |
/* Make this a weak reference to avoid pulling in malloc. */ |
void * malloc(size_t) _ATTRIBUTE((__weak__)); |
__LOCK_INIT_RECURSIVE(, __atexit_lock); |
/* |
* Register a function to be performed at exit or on shared library unload. |
*/ |
int |
_DEFUN (__register_exitproc, |
(type, fn, arg, d), |
int type _AND |
void (*fn) (void) _AND |
void *arg _AND |
void *d) |
{ |
struct _on_exit_args * args; |
register struct _atexit *p; |
#ifndef __SINGLE_THREAD__ |
__lock_acquire_recursive(__atexit_lock); |
#endif |
p = _GLOBAL_REENT->_atexit; |
if (p == NULL) |
_GLOBAL_REENT->_atexit = p = &_GLOBAL_REENT->_atexit0; |
if (p->_ind >= _ATEXIT_SIZE) |
{ |
#ifndef _ATEXIT_DYNAMIC_ALLOC |
return -1; |
#else |
/* Don't dynamically allocate the atexit array if malloc is not |
available. */ |
if (!malloc) |
return -1; |
p = (struct _atexit *) malloc (sizeof *p); |
if (p == NULL) |
{ |
#ifndef __SINGLE_THREAD__ |
__lock_release_recursive(__atexit_lock); |
#endif |
return -1; |
} |
p->_ind = 0; |
p->_next = _GLOBAL_REENT->_atexit; |
_GLOBAL_REENT->_atexit = p; |
#ifndef _REENT_SMALL |
p->_on_exit_args._fntypes = 0; |
p->_on_exit_args._is_cxa = 0; |
#endif |
#endif |
} |
if (type != __et_atexit) |
{ |
#ifdef _REENT_SMALL |
args = p->_on_exit_args_ptr; |
if (args == NULL) |
{ |
if (malloc) |
args = malloc (sizeof * p->_on_exit_args_ptr); |
if (args == NULL) |
{ |
#ifndef __SINGLE_THREAD__ |
__lock_release(lock); |
#endif |
return -1; |
} |
args->_fntypes = 0; |
args->_is_cxa = 0; |
p->_on_exit_args_ptr = args; |
} |
#else |
args = &p->_on_exit_args; |
#endif |
args->_fnargs[p->_ind] = arg; |
args->_fntypes |= (1 << p->_ind); |
args->_dso_handle[p->_ind] = d; |
if (type == __et_cxa) |
args->_is_cxa |= (1 << p->_ind); |
} |
p->_fns[p->_ind++] = fn; |
#ifndef __SINGLE_THREAD__ |
__lock_release_recursive(__atexit_lock); |
#endif |
return 0; |
} |
/contrib/sdk/sources/libc/stdlib/__call_atexit.c |
---|
0,0 → 1,161 |
/* |
* COmmon routine to call call registered atexit-like routines. |
*/ |
#include <stdlib.h> |
#include <reent.h> |
#include <sys/lock.h> |
#include "atexit.h" |
/* Make this a weak reference to avoid pulling in free. */ |
void free(void *) _ATTRIBUTE((__weak__)); |
#ifndef __SINGLE_THREAD__ |
extern _LOCK_RECURSIVE_T __atexit_lock; |
#endif |
#ifdef _WANT_REGISTER_FINI |
/* If "__libc_fini" is defined, finalizers (either |
"__libc_fini_array", or "_fini", as appropriate) will be run after |
all user-specified atexit handlers. For example, you can define |
"__libc_fini" to "_fini" in your linker script if you want the C |
library, rather than startup code, to register finalizers. If you |
do that, then your startup code need not contain references to |
"atexit" or "exit". As a result, only applications that reference |
"exit" explicitly will pull in finalization code. |
The choice of whether to register finalizers from libc or from |
startup code is deferred to link-time, rather than being a |
configure-time option, so that the same C library binary can be |
used with multiple BSPs, some of which register finalizers from |
startup code, while others defer to the C library. */ |
extern char __libc_fini __attribute__((weak)); |
/* Register the application finalization function with atexit. These |
finalizers should run last. Therefore, we want to call atexit as |
soon as possible. */ |
static void |
register_fini(void) __attribute__((constructor (0))); |
static void |
register_fini(void) |
{ |
if (&__libc_fini) { |
#ifdef HAVE_INITFINI_ARRAY |
extern void __libc_fini_array (void); |
atexit (__libc_fini_array); |
#else |
extern void _fini (void); |
atexit (_fini); |
#endif |
} |
} |
#endif /* _WANT_REGISTER_FINI */ |
/* |
* Call registered exit handlers. If D is null then all handlers are called, |
* otherwise only the handlers from that DSO are called. |
*/ |
void |
_DEFUN (__call_exitprocs, (code, d), |
int code _AND _PTR d) |
{ |
register struct _atexit *p; |
struct _atexit **lastp; |
register struct _on_exit_args * args; |
register int n; |
int i; |
void (*fn) (void); |
#ifndef __SINGLE_THREAD__ |
__lock_acquire_recursive(__atexit_lock); |
#endif |
restart: |
p = _GLOBAL_REENT->_atexit; |
lastp = &_GLOBAL_REENT->_atexit; |
while (p) |
{ |
#ifdef _REENT_SMALL |
args = p->_on_exit_args_ptr; |
#else |
args = &p->_on_exit_args; |
#endif |
for (n = p->_ind - 1; n >= 0; n--) |
{ |
int ind; |
i = 1 << n; |
/* Skip functions not from this dso. */ |
if (d && (!args || args->_dso_handle[n] != d)) |
continue; |
/* Remove the function now to protect against the |
function calling exit recursively. */ |
fn = p->_fns[n]; |
if (n == p->_ind - 1) |
p->_ind--; |
else |
p->_fns[n] = NULL; |
/* Skip functions that have already been called. */ |
if (!fn) |
continue; |
ind = p->_ind; |
/* Call the function. */ |
if (!args || (args->_fntypes & i) == 0) |
fn (); |
else if ((args->_is_cxa & i) == 0) |
(*((void (*)(int, _PTR)) fn))(code, args->_fnargs[n]); |
else |
(*((void (*)(_PTR)) fn))(args->_fnargs[n]); |
/* The function we called call atexit and registered another |
function (or functions). Call these new functions before |
continuing with the already registered functions. */ |
if (ind != p->_ind || *lastp != p) |
goto restart; |
} |
#ifndef _ATEXIT_DYNAMIC_ALLOC |
break; |
#else |
/* Don't dynamically free the atexit array if free is not |
available. */ |
if (!free) |
break; |
/* Move to the next block. Free empty blocks except the last one, |
which is part of _GLOBAL_REENT. */ |
if (p->_ind == 0 && p->_next) |
{ |
/* Remove empty block from the list. */ |
*lastp = p->_next; |
#ifdef _REENT_SMALL |
if (args) |
free (args); |
#endif |
free (p); |
p = *lastp; |
} |
else |
{ |
lastp = &p->_next; |
p = p->_next; |
} |
#endif |
} |
#ifndef __SINGLE_THREAD__ |
__lock_release_recursive(__atexit_lock); |
#endif |
} |
/contrib/sdk/sources/libc/stdlib/abort.c |
---|
0,0 → 1,67 |
/* NetWare can not use this implementation of abort. It provides its |
own version of abort in clib.nlm. If we can not use clib.nlm, then |
we must write abort in sys/netware. */ |
#ifdef ABORT_PROVIDED |
int _dummy_abort = 1; |
#else |
/* |
FUNCTION |
<<abort>>---abnormal termination of a program |
INDEX |
abort |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void abort(void); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
void abort(); |
DESCRIPTION |
Use <<abort>> to signal that your program has detected a condition it |
cannot deal with. Normally, <<abort>> ends your program's execution. |
Before terminating your program, <<abort>> raises the exception <<SIGABRT>> |
(using `<<raise(SIGABRT)>>'). If you have used <<signal>> to register |
an exception handler for this condition, that handler has the |
opportunity to retain control, thereby avoiding program termination. |
In this implementation, <<abort>> does not perform any stream- or |
file-related cleanup (the host environment may do so; if not, you can |
arrange for your program to do its own cleanup with a <<SIGABRT>> |
exception handler). |
RETURNS |
<<abort>> does not return to its caller. |
PORTABILITY |
ANSI C requires <<abort>>. |
Supporting OS subroutines required: <<_exit>> and optionally, <<write>>. |
*/ |
#include <stdlib.h> |
#include <unistd.h> |
#include <signal.h> |
_VOID |
_DEFUN_VOID (abort) |
{ |
#ifdef ABORT_MESSAGE |
write (2, "Abort called\n", sizeof ("Abort called\n")-1); |
#endif |
while (1) |
{ |
// raise (SIGABRT); |
_exit (1); |
} |
} |
#endif |
/contrib/sdk/sources/libc/stdlib/abs.c |
---|
0,0 → 1,43 |
/* |
FUNCTION |
<<abs>>---integer absolute value (magnitude) |
INDEX |
abs |
ANSI_SYNOPSIS |
#include <stdlib.h> |
int abs(int <[i]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
int abs(<[i]>) |
int <[i]>; |
DESCRIPTION |
<<abs>> returns |
@tex |
$|x|$, |
@end tex |
the absolute value of <[i]> (also called the magnitude |
of <[i]>). That is, if <[i]> is negative, the result is the opposite |
of <[i]>, but if <[i]> is nonnegative the result is <[i]>. |
The similar function <<labs>> uses and returns <<long>> rather than <<int>> values. |
RETURNS |
The result is a nonnegative integer. |
PORTABILITY |
<<abs>> is ANSI. |
No supporting OS subroutines are required. |
*/ |
#include <stdlib.h> |
int |
_DEFUN (abs, (i), int i) |
{ |
return (i < 0) ? -i : i; |
} |
/contrib/sdk/sources/libc/stdlib/atexit.h |
---|
0,0 → 1,14 |
/* |
* Common definitions for atexit-like routines |
*/ |
enum __atexit_types |
{ |
__et_atexit, |
__et_onexit, |
__et_cxa |
}; |
void __call_exitprocs _PARAMS ((int, _PTR)); |
int __register_exitproc _PARAMS ((int, void (*fn) (void), _PTR, _PTR)); |
/contrib/sdk/sources/libc/stdlib/atof.c |
---|
0,0 → 1,72 |
/* |
FUNCTION |
<<atof>>, <<atoff>>---string to double or float |
INDEX |
atof |
INDEX |
atoff |
ANSI_SYNOPSIS |
#include <stdlib.h> |
double atof(const char *<[s]>); |
float atoff(const char *<[s]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
double atof(<[s]>) |
char *<[s]>; |
float atoff(<[s]>) |
char *<[s]>; |
DESCRIPTION |
<<atof>> converts the initial portion of a string to a <<double>>. |
<<atoff>> converts the initial portion of a string to a <<float>>. |
The functions parse the character string <[s]>, |
locating a substring which can be converted to a floating-point |
value. The substring must match the format: |
. [+|-]<[digits]>[.][<[digits]>][(e|E)[+|-]<[digits]>] |
The substring converted is the longest initial |
fragment of <[s]> that has the expected format, beginning with |
the first non-whitespace character. The substring |
is empty if <<str>> is empty, consists entirely |
of whitespace, or if the first non-whitespace character is |
something other than <<+>>, <<->>, <<.>>, or a digit. |
<<atof(<[s]>)>> is implemented as <<strtod(<[s]>, NULL)>>. |
<<atoff(<[s]>)>> is implemented as <<strtof(<[s]>, NULL)>>. |
RETURNS |
<<atof>> returns the converted substring value, if any, as a |
<<double>>; or <<0.0>>, if no conversion could be performed. |
If the correct value is out of the range of representable values, plus |
or minus <<HUGE_VAL>> is returned, and <<ERANGE>> is stored in |
<<errno>>. |
If the correct value would cause underflow, <<0.0>> is returned |
and <<ERANGE>> is stored in <<errno>>. |
<<atoff>> obeys the same rules as <<atof>>, except that it |
returns a <<float>>. |
PORTABILITY |
<<atof>> is ANSI C. <<atof>>, <<atoi>>, and <<atol>> are subsumed by <<strod>> |
and <<strol>>, but are used extensively in existing code. These functions are |
less reliable, but may be faster if the argument is verified to be in a valid |
range. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <stdlib.h> |
#include <_ansi.h> |
double |
_DEFUN (atof, (s), |
_CONST char *s) |
{ |
return strtod (s, NULL); |
} |
/contrib/sdk/sources/libc/stdlib/atoi.c |
---|
0,0 → 1,81 |
/* |
FUNCTION |
<<atoi>>, <<atol>>---string to integer |
INDEX |
atoi |
INDEX |
atol |
INDEX |
_atoi_r |
INDEX |
_atol_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
int atoi(const char *<[s]>); |
long atol(const char *<[s]>); |
int _atoi_r(struct _reent *<[ptr]>, const char *<[s]>); |
long _atol_r(struct _reent *<[ptr]>, const char *<[s]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
int atoi(<[s]>) |
char *<[s]>; |
long atol(<[s]>) |
char *<[s]>; |
int _atoi_r(<[ptr]>, <[s]>) |
struct _reent *<[ptr]>; |
char *<[s]>; |
long _atol_r(<[ptr]>, <[s]>) |
struct _reent *<[ptr]>; |
char *<[s]>; |
DESCRIPTION |
<<atoi>> converts the initial portion of a string to an <<int>>. |
<<atol>> converts the initial portion of a string to a <<long>>. |
<<atoi(s)>> is implemented as <<(int)strtol(s, NULL, 10).>> |
<<atol(s)>> is implemented as <<strtol(s, NULL, 10).>> |
<<_atoi_r>> and <<_atol_r>> are reentrant versions of <<atoi>> and |
<<atol>> respectively, passing the reentrancy struct pointer. |
RETURNS |
The functions return the converted value, if any. If no conversion was |
made, <<0>> is returned. |
PORTABILITY |
<<atoi>>, <<atol>> are ANSI. |
No supporting OS subroutines are required. |
*/ |
/* |
* Andy Wilson, 2-Oct-89. |
*/ |
#include <stdlib.h> |
#include <_ansi.h> |
#ifndef _REENT_ONLY |
int |
_DEFUN (atoi, (s), |
_CONST char *s) |
{ |
return (int) strtol (s, NULL, 10); |
} |
#endif /* !_REENT_ONLY */ |
int |
_DEFUN (_atoi_r, (s), |
struct _reent *ptr _AND |
_CONST char *s) |
{ |
return (int) _strtol_r (ptr, s, NULL, 10); |
} |
/contrib/sdk/sources/libc/stdlib/atol.c |
---|
0,0 → 1,21 |
/* |
* Andy Wilson, 2-Oct-89. |
*/ |
#include <stdlib.h> |
#include <_ansi.h> |
#ifndef _REENT_ONLY |
long |
_DEFUN (atol, (s), _CONST char *s) |
{ |
return strtol (s, NULL, 10); |
} |
#endif /* !_REENT_ONLY */ |
long |
_DEFUN (_atol_r, (ptr, s), struct _reent *ptr _AND _CONST char *s) |
{ |
return _strtol_r (ptr, s, NULL, 10); |
} |
/contrib/sdk/sources/libc/stdlib/calloc.c |
---|
0,0 → 1,69 |
#ifdef MALLOC_PROVIDED |
int _dummy_calloc = 1; |
#else |
/* |
FUNCTION |
<<calloc>>---allocate space for arrays |
INDEX |
calloc |
INDEX |
_calloc_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void *calloc(size_t <[n]>, size_t <[s]>); |
void *_calloc_r(void *<[reent]>, size_t <[n]>, size_t <[s]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
char *calloc(<[n]>, <[s]>) |
size_t <[n]>, <[s]>; |
char *_calloc_r(<[reent]>, <[n]>, <[s]>) |
char *<[reent]>; |
size_t <[n]>; |
size_t <[s]>; |
DESCRIPTION |
Use <<calloc>> to request a block of memory sufficient to hold an |
array of <[n]> elements, each of which has size <[s]>. |
The memory allocated by <<calloc>> comes out of the same memory pool |
used by <<malloc>>, but the memory block is initialized to all zero |
bytes. (To avoid the overhead of initializing the space, use |
<<malloc>> instead.) |
The alternate function <<_calloc_r>> is reentrant. |
The extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
If successful, a pointer to the newly allocated space. |
If unsuccessful, <<NULL>>. |
PORTABILITY |
<<calloc>> is ANSI. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <string.h> |
#include <stdlib.h> |
#ifndef _REENT_ONLY |
_PTR |
_DEFUN (calloc, (n, size), |
size_t n _AND |
size_t size) |
{ |
return _calloc_r (_REENT, n, size); |
} |
#endif |
#endif /* MALLOC_PROVIDED */ |
/contrib/sdk/sources/libc/stdlib/div.c |
---|
0,0 → 1,132 |
/* |
FUNCTION |
<<div>>---divide two integers |
INDEX |
div |
ANSI_SYNOPSIS |
#include <stdlib.h> |
div_t div(int <[n]>, int <[d]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
div_t div(<[n]>, <[d]>) |
int <[n]>, <[d]>; |
DESCRIPTION |
Divide |
@tex |
$n/d$, |
@end tex |
@ifnottex |
<[n]>/<[d]>, |
@end ifnottex |
returning quotient and remainder as two integers in a structure <<div_t>>. |
RETURNS |
The result is represented with the structure |
. typedef struct |
. { |
. int quot; |
. int rem; |
. } div_t; |
where the <<quot>> field represents the quotient, and <<rem>> the |
remainder. For nonzero <[d]>, if `<<<[r]> = div(<[n]>,<[d]>);>>' then |
<[n]> equals `<<<[r]>.rem + <[d]>*<[r]>.quot>>'. |
To divide <<long>> rather than <<int>> values, use the similar |
function <<ldiv>>. |
PORTABILITY |
<<div>> is ANSI. |
No supporting OS subroutines are required. |
*/ |
/* |
* Copyright (c) 1990 Regents of the University of California. |
* All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Chris Torek. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <_ansi.h> |
#include <stdlib.h> /* div_t */ |
div_t |
_DEFUN (div, (num, denom), |
int num _AND |
int denom) |
{ |
div_t r; |
r.quot = num / denom; |
r.rem = num % denom; |
/* |
* The ANSI standard says that |r.quot| <= |n/d|, where |
* n/d is to be computed in infinite precision. In other |
* words, we should always truncate the quotient towards |
* 0, never -infinity or +infinity. |
* |
* Machine division and remainer may work either way when |
* one or both of n or d is negative. If only one is |
* negative and r.quot has been truncated towards -inf, |
* r.rem will have the same sign as denom and the opposite |
* sign of num; if both are negative and r.quot has been |
* truncated towards -inf, r.rem will be positive (will |
* have the opposite sign of num). These are considered |
* `wrong'. |
* |
* If both are num and denom are positive, r will always |
* be positive. |
* |
* This all boils down to: |
* if num >= 0, but r.rem < 0, we got the wrong answer. |
* In that case, to get the right answer, add 1 to r.quot and |
* subtract denom from r.rem. |
* if num < 0, but r.rem > 0, we also have the wrong answer. |
* In this case, to get the right answer, subtract 1 from r.quot and |
* add denom to r.rem. |
*/ |
if (num >= 0 && r.rem < 0) { |
++r.quot; |
r.rem -= denom; |
} |
else if (num < 0 && r.rem > 0) { |
--r.quot; |
r.rem += denom; |
} |
return (r); |
} |
/contrib/sdk/sources/libc/stdlib/dtoa.c |
---|
0,0 → 1,862 |
/**************************************************************** |
* |
* The author of this software is David M. Gay. |
* |
* Copyright (c) 1991 by AT&T. |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software and in all copies of the supporting |
* documentation for such software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY |
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY |
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
***************************************************************/ |
/* Please send bug reports to |
David M. Gay |
AT&T Bell Laboratories, Room 2C-463 |
600 Mountain Avenue |
Murray Hill, NJ 07974-2070 |
U.S.A. |
dmg@research.att.com or research!dmg |
*/ |
#include <_ansi.h> |
#include <stdlib.h> |
#include <reent.h> |
#include <string.h> |
#include "mprec.h" |
static int |
_DEFUN (quorem, |
(b, S), |
_Bigint * b _AND _Bigint * S) |
{ |
int n; |
__Long borrow, y; |
__ULong carry, q, ys; |
__ULong *bx, *bxe, *sx, *sxe; |
#ifdef Pack_32 |
__Long z; |
__ULong si, zs; |
#endif |
n = S->_wds; |
#ifdef DEBUG |
/*debug*/ if (b->_wds > n) |
/*debug*/ Bug ("oversize b in quorem"); |
#endif |
if (b->_wds < n) |
return 0; |
sx = S->_x; |
sxe = sx + --n; |
bx = b->_x; |
bxe = bx + n; |
q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ |
#ifdef DEBUG |
/*debug*/ if (q > 9) |
/*debug*/ Bug ("oversized quotient in quorem"); |
#endif |
if (q) |
{ |
borrow = 0; |
carry = 0; |
do |
{ |
#ifdef Pack_32 |
si = *sx++; |
ys = (si & 0xffff) * q + carry; |
zs = (si >> 16) * q + (ys >> 16); |
carry = zs >> 16; |
y = (*bx & 0xffff) - (ys & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
z = (*bx >> 16) - (zs & 0xffff) + borrow; |
borrow = z >> 16; |
Sign_Extend (borrow, z); |
Storeinc (bx, z, y); |
#else |
ys = *sx++ * q + carry; |
carry = ys >> 16; |
y = *bx - (ys & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
*bx++ = y & 0xffff; |
#endif |
} |
while (sx <= sxe); |
if (!*bxe) |
{ |
bx = b->_x; |
while (--bxe > bx && !*bxe) |
--n; |
b->_wds = n; |
} |
} |
if (cmp (b, S) >= 0) |
{ |
q++; |
borrow = 0; |
carry = 0; |
bx = b->_x; |
sx = S->_x; |
do |
{ |
#ifdef Pack_32 |
si = *sx++; |
ys = (si & 0xffff) + carry; |
zs = (si >> 16) + (ys >> 16); |
carry = zs >> 16; |
y = (*bx & 0xffff) - (ys & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
z = (*bx >> 16) - (zs & 0xffff) + borrow; |
borrow = z >> 16; |
Sign_Extend (borrow, z); |
Storeinc (bx, z, y); |
#else |
ys = *sx++ + carry; |
carry = ys >> 16; |
y = *bx - (ys & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
*bx++ = y & 0xffff; |
#endif |
} |
while (sx <= sxe); |
bx = b->_x; |
bxe = bx + n; |
if (!*bxe) |
{ |
while (--bxe > bx && !*bxe) |
--n; |
b->_wds = n; |
} |
} |
return q; |
} |
/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. |
* |
* Inspired by "How to Print Floating-Point Numbers Accurately" by |
* Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101]. |
* |
* Modifications: |
* 1. Rather than iterating, we use a simple numeric overestimate |
* to determine k = floor(log10(d)). We scale relevant |
* quantities using O(log2(k)) rather than O(k) multiplications. |
* 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't |
* try to generate digits strictly left to right. Instead, we |
* compute with fewer bits and propagate the carry if necessary |
* when rounding the final digit up. This is often faster. |
* 3. Under the assumption that input will be rounded nearest, |
* mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. |
* That is, we allow equality in stopping tests when the |
* round-nearest rule will give the same floating-point value |
* as would satisfaction of the stopping test with strict |
* inequality. |
* 4. We remove common factors of powers of 2 from relevant |
* quantities. |
* 5. When converting floating-point integers less than 1e16, |
* we use floating-point arithmetic rather than resorting |
* to multiple-precision integers. |
* 6. When asked to produce fewer than 15 digits, we first try |
* to get by with floating-point arithmetic; we resort to |
* multiple-precision integer arithmetic only if we cannot |
* guarantee that the floating-point calculation has given |
* the correctly rounded result. For k requested digits and |
* "uniformly" distributed input, the probability is |
* something like 10^(k-15) that we must resort to the long |
* calculation. |
*/ |
char * |
_DEFUN (_dtoa_r, |
(ptr, _d, mode, ndigits, decpt, sign, rve), |
struct _reent *ptr _AND |
double _d _AND |
int mode _AND |
int ndigits _AND |
int *decpt _AND |
int *sign _AND |
char **rve) |
{ |
/* Arguments ndigits, decpt, sign are similar to those |
of ecvt and fcvt; trailing zeros are suppressed from |
the returned string. If not null, *rve is set to point |
to the end of the return value. If d is +-Infinity or NaN, |
then *decpt is set to 9999. |
mode: |
0 ==> shortest string that yields d when read in |
and rounded to nearest. |
1 ==> like 0, but with Steele & White stopping rule; |
e.g. with IEEE P754 arithmetic , mode 0 gives |
1e23 whereas mode 1 gives 9.999999999999999e22. |
2 ==> max(1,ndigits) significant digits. This gives a |
return value similar to that of ecvt, except |
that trailing zeros are suppressed. |
3 ==> through ndigits past the decimal point. This |
gives a return value similar to that from fcvt, |
except that trailing zeros are suppressed, and |
ndigits can be negative. |
4-9 should give the same return values as 2-3, i.e., |
4 <= mode <= 9 ==> same return as mode |
2 + (mode & 1). These modes are mainly for |
debugging; often they run slower but sometimes |
faster than modes 2-3. |
4,5,8,9 ==> left-to-right digit generation. |
6-9 ==> don't try fast floating-point estimate |
(if applicable). |
Values of mode other than 0-9 are treated as mode 0. |
Sufficient space is allocated to the return value |
to hold the suppressed trailing zeros. |
*/ |
int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, j, j1, k, k0, |
k_check, leftright, m2, m5, s2, s5, spec_case, try_quick; |
union double_union d, d2, eps; |
__Long L; |
#ifndef Sudden_Underflow |
int denorm; |
__ULong x; |
#endif |
_Bigint *b, *b1, *delta, *mlo = NULL, *mhi, *S; |
double ds; |
char *s, *s0; |
d.d = _d; |
_REENT_CHECK_MP(ptr); |
if (_REENT_MP_RESULT(ptr)) |
{ |
_REENT_MP_RESULT(ptr)->_k = _REENT_MP_RESULT_K(ptr); |
_REENT_MP_RESULT(ptr)->_maxwds = 1 << _REENT_MP_RESULT_K(ptr); |
Bfree (ptr, _REENT_MP_RESULT(ptr)); |
_REENT_MP_RESULT(ptr) = 0; |
} |
if (word0 (d) & Sign_bit) |
{ |
/* set sign for everything, including 0's and NaNs */ |
*sign = 1; |
word0 (d) &= ~Sign_bit; /* clear sign bit */ |
} |
else |
*sign = 0; |
#if defined(IEEE_Arith) + defined(VAX) |
#ifdef IEEE_Arith |
if ((word0 (d) & Exp_mask) == Exp_mask) |
#else |
if (word0 (d) == 0x8000) |
#endif |
{ |
/* Infinity or NaN */ |
*decpt = 9999; |
s = |
#ifdef IEEE_Arith |
!word1 (d) && !(word0 (d) & 0xfffff) ? "Infinity" : |
#endif |
"NaN"; |
if (rve) |
*rve = |
#ifdef IEEE_Arith |
s[3] ? s + 8 : |
#endif |
s + 3; |
return s; |
} |
#endif |
#ifdef IBM |
d.d += 0; /* normalize */ |
#endif |
if (!d.d) |
{ |
*decpt = 1; |
s = "0"; |
if (rve) |
*rve = s + 1; |
return s; |
} |
b = d2b (ptr, d.d, &be, &bbits); |
#ifdef Sudden_Underflow |
i = (int) (word0 (d) >> Exp_shift1 & (Exp_mask >> Exp_shift1)); |
#else |
if ((i = (int) (word0 (d) >> Exp_shift1 & (Exp_mask >> Exp_shift1))) != 0) |
{ |
#endif |
d2.d = d.d; |
word0 (d2) &= Frac_mask1; |
word0 (d2) |= Exp_11; |
#ifdef IBM |
if (j = 11 - hi0bits (word0 (d2) & Frac_mask)) |
d2.d /= 1 << j; |
#endif |
/* log(x) ~=~ log(1.5) + (x-1.5)/1.5 |
* log10(x) = log(x) / log(10) |
* ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) |
* log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) |
* |
* This suggests computing an approximation k to log10(d) by |
* |
* k = (i - Bias)*0.301029995663981 |
* + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); |
* |
* We want k to be too large rather than too small. |
* The error in the first-order Taylor series approximation |
* is in our favor, so we just round up the constant enough |
* to compensate for any error in the multiplication of |
* (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, |
* and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, |
* adding 1e-13 to the constant term more than suffices. |
* Hence we adjust the constant term to 0.1760912590558. |
* (We could get a more accurate k by invoking log10, |
* but this is probably not worthwhile.) |
*/ |
i -= Bias; |
#ifdef IBM |
i <<= 2; |
i += j; |
#endif |
#ifndef Sudden_Underflow |
denorm = 0; |
} |
else |
{ |
/* d is denormalized */ |
i = bbits + be + (Bias + (P - 1) - 1); |
#if defined (_DOUBLE_IS_32BITS) |
x = word0 (d) << (32 - i); |
#else |
x = (i > 32) ? (word0 (d) << (64 - i)) | (word1 (d) >> (i - 32)) |
: (word1 (d) << (32 - i)); |
#endif |
d2.d = x; |
word0 (d2) -= 31 * Exp_msk1; /* adjust exponent */ |
i -= (Bias + (P - 1) - 1) + 1; |
denorm = 1; |
} |
#endif |
#if defined (_DOUBLE_IS_32BITS) |
ds = (d2.d - 1.5) * 0.289529651 + 0.176091269 + i * 0.30103001; |
#else |
ds = (d2.d - 1.5) * 0.289529654602168 + 0.1760912590558 + i * 0.301029995663981; |
#endif |
k = (int) ds; |
if (ds < 0. && ds != k) |
k--; /* want k = floor(ds) */ |
k_check = 1; |
if (k >= 0 && k <= Ten_pmax) |
{ |
if (d.d < tens[k]) |
k--; |
k_check = 0; |
} |
j = bbits - i - 1; |
if (j >= 0) |
{ |
b2 = 0; |
s2 = j; |
} |
else |
{ |
b2 = -j; |
s2 = 0; |
} |
if (k >= 0) |
{ |
b5 = 0; |
s5 = k; |
s2 += k; |
} |
else |
{ |
b2 -= k; |
b5 = -k; |
s5 = 0; |
} |
if (mode < 0 || mode > 9) |
mode = 0; |
try_quick = 1; |
if (mode > 5) |
{ |
mode -= 4; |
try_quick = 0; |
} |
leftright = 1; |
ilim = ilim1 = -1; |
switch (mode) |
{ |
case 0: |
case 1: |
i = 18; |
ndigits = 0; |
break; |
case 2: |
leftright = 0; |
/* no break */ |
case 4: |
if (ndigits <= 0) |
ndigits = 1; |
ilim = ilim1 = i = ndigits; |
break; |
case 3: |
leftright = 0; |
/* no break */ |
case 5: |
i = ndigits + k + 1; |
ilim = i; |
ilim1 = i - 1; |
if (i <= 0) |
i = 1; |
} |
j = sizeof (__ULong); |
for (_REENT_MP_RESULT_K(ptr) = 0; sizeof (_Bigint) - sizeof (__ULong) + j <= i; |
j <<= 1) |
_REENT_MP_RESULT_K(ptr)++; |
_REENT_MP_RESULT(ptr) = Balloc (ptr, _REENT_MP_RESULT_K(ptr)); |
s = s0 = (char *) _REENT_MP_RESULT(ptr); |
if (ilim >= 0 && ilim <= Quick_max && try_quick) |
{ |
/* Try to get by with floating-point arithmetic. */ |
i = 0; |
d2.d = d.d; |
k0 = k; |
ilim0 = ilim; |
ieps = 2; /* conservative */ |
if (k > 0) |
{ |
ds = tens[k & 0xf]; |
j = k >> 4; |
if (j & Bletch) |
{ |
/* prevent overflows */ |
j &= Bletch - 1; |
d.d /= bigtens[n_bigtens - 1]; |
ieps++; |
} |
for (; j; j >>= 1, i++) |
if (j & 1) |
{ |
ieps++; |
ds *= bigtens[i]; |
} |
d.d /= ds; |
} |
else if ((j1 = -k) != 0) |
{ |
d.d *= tens[j1 & 0xf]; |
for (j = j1 >> 4; j; j >>= 1, i++) |
if (j & 1) |
{ |
ieps++; |
d.d *= bigtens[i]; |
} |
} |
if (k_check && d.d < 1. && ilim > 0) |
{ |
if (ilim1 <= 0) |
goto fast_failed; |
ilim = ilim1; |
k--; |
d.d *= 10.; |
ieps++; |
} |
eps.d = ieps * d.d + 7.; |
word0 (eps) -= (P - 1) * Exp_msk1; |
if (ilim == 0) |
{ |
S = mhi = 0; |
d.d -= 5.; |
if (d.d > eps.d) |
goto one_digit; |
if (d.d < -eps.d) |
goto no_digits; |
goto fast_failed; |
} |
#ifndef No_leftright |
if (leftright) |
{ |
/* Use Steele & White method of only |
* generating digits needed. |
*/ |
eps.d = 0.5 / tens[ilim - 1] - eps.d; |
for (i = 0;;) |
{ |
L = d.d; |
d.d -= L; |
*s++ = '0' + (int) L; |
if (d.d < eps.d) |
goto ret1; |
if (1. - d.d < eps.d) |
goto bump_up; |
if (++i >= ilim) |
break; |
eps.d *= 10.; |
d.d *= 10.; |
} |
} |
else |
{ |
#endif |
/* Generate ilim digits, then fix them up. */ |
eps.d *= tens[ilim - 1]; |
for (i = 1;; i++, d.d *= 10.) |
{ |
L = d.d; |
d.d -= L; |
*s++ = '0' + (int) L; |
if (i == ilim) |
{ |
if (d.d > 0.5 + eps.d) |
goto bump_up; |
else if (d.d < 0.5 - eps.d) |
{ |
while (*--s == '0'); |
s++; |
goto ret1; |
} |
break; |
} |
} |
#ifndef No_leftright |
} |
#endif |
fast_failed: |
s = s0; |
d.d = d2.d; |
k = k0; |
ilim = ilim0; |
} |
/* Do we have a "small" integer? */ |
if (be >= 0 && k <= Int_max) |
{ |
/* Yes. */ |
ds = tens[k]; |
if (ndigits < 0 && ilim <= 0) |
{ |
S = mhi = 0; |
if (ilim < 0 || d.d <= 5 * ds) |
goto no_digits; |
goto one_digit; |
} |
for (i = 1;; i++) |
{ |
L = d.d / ds; |
d.d -= L * ds; |
#ifdef Check_FLT_ROUNDS |
/* If FLT_ROUNDS == 2, L will usually be high by 1 */ |
if (d.d < 0) |
{ |
L--; |
d.d += ds; |
} |
#endif |
*s++ = '0' + (int) L; |
if (i == ilim) |
{ |
d.d += d.d; |
if ((d.d > ds) || ((d.d == ds) && (L & 1))) |
{ |
bump_up: |
while (*--s == '9') |
if (s == s0) |
{ |
k++; |
*s = '0'; |
break; |
} |
++*s++; |
} |
break; |
} |
if (!(d.d *= 10.)) |
break; |
} |
goto ret1; |
} |
m2 = b2; |
m5 = b5; |
mhi = mlo = 0; |
if (leftright) |
{ |
if (mode < 2) |
{ |
i = |
#ifndef Sudden_Underflow |
denorm ? be + (Bias + (P - 1) - 1 + 1) : |
#endif |
#ifdef IBM |
1 + 4 * P - 3 - bbits + ((bbits + be - 1) & 3); |
#else |
1 + P - bbits; |
#endif |
} |
else |
{ |
j = ilim - 1; |
if (m5 >= j) |
m5 -= j; |
else |
{ |
s5 += j -= m5; |
b5 += j; |
m5 = 0; |
} |
if ((i = ilim) < 0) |
{ |
m2 -= i; |
i = 0; |
} |
} |
b2 += i; |
s2 += i; |
mhi = i2b (ptr, 1); |
} |
if (m2 > 0 && s2 > 0) |
{ |
i = m2 < s2 ? m2 : s2; |
b2 -= i; |
m2 -= i; |
s2 -= i; |
} |
if (b5 > 0) |
{ |
if (leftright) |
{ |
if (m5 > 0) |
{ |
mhi = pow5mult (ptr, mhi, m5); |
b1 = mult (ptr, mhi, b); |
Bfree (ptr, b); |
b = b1; |
} |
if ((j = b5 - m5) != 0) |
b = pow5mult (ptr, b, j); |
} |
else |
b = pow5mult (ptr, b, b5); |
} |
S = i2b (ptr, 1); |
if (s5 > 0) |
S = pow5mult (ptr, S, s5); |
/* Check for special case that d is a normalized power of 2. */ |
spec_case = 0; |
if (mode < 2) |
{ |
if (!word1 (d) && !(word0 (d) & Bndry_mask) |
#ifndef Sudden_Underflow |
&& word0 (d) & Exp_mask |
#endif |
) |
{ |
/* The special case */ |
b2 += Log2P; |
s2 += Log2P; |
spec_case = 1; |
} |
} |
/* Arrange for convenient computation of quotients: |
* shift left if necessary so divisor has 4 leading 0 bits. |
* |
* Perhaps we should just compute leading 28 bits of S once |
* and for all and pass them and a shift to quorem, so it |
* can do shifts and ors to compute the numerator for q. |
*/ |
#ifdef Pack_32 |
if ((i = ((s5 ? 32 - hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0x1f) != 0) |
i = 32 - i; |
#else |
if ((i = ((s5 ? 32 - hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0xf) != 0) |
i = 16 - i; |
#endif |
if (i > 4) |
{ |
i -= 4; |
b2 += i; |
m2 += i; |
s2 += i; |
} |
else if (i < 4) |
{ |
i += 28; |
b2 += i; |
m2 += i; |
s2 += i; |
} |
if (b2 > 0) |
b = lshift (ptr, b, b2); |
if (s2 > 0) |
S = lshift (ptr, S, s2); |
if (k_check) |
{ |
if (cmp (b, S) < 0) |
{ |
k--; |
b = multadd (ptr, b, 10, 0); /* we botched the k estimate */ |
if (leftright) |
mhi = multadd (ptr, mhi, 10, 0); |
ilim = ilim1; |
} |
} |
if (ilim <= 0 && mode > 2) |
{ |
if (ilim < 0 || cmp (b, S = multadd (ptr, S, 5, 0)) <= 0) |
{ |
/* no digits, fcvt style */ |
no_digits: |
k = -1 - ndigits; |
goto ret; |
} |
one_digit: |
*s++ = '1'; |
k++; |
goto ret; |
} |
if (leftright) |
{ |
if (m2 > 0) |
mhi = lshift (ptr, mhi, m2); |
/* Compute mlo -- check for special case |
* that d is a normalized power of 2. |
*/ |
mlo = mhi; |
if (spec_case) |
{ |
mhi = Balloc (ptr, mhi->_k); |
Bcopy (mhi, mlo); |
mhi = lshift (ptr, mhi, Log2P); |
} |
for (i = 1;; i++) |
{ |
dig = quorem (b, S) + '0'; |
/* Do we yet have the shortest decimal string |
* that will round to d? |
*/ |
j = cmp (b, mlo); |
delta = diff (ptr, S, mhi); |
j1 = delta->_sign ? 1 : cmp (b, delta); |
Bfree (ptr, delta); |
#ifndef ROUND_BIASED |
if (j1 == 0 && !mode && !(word1 (d) & 1)) |
{ |
if (dig == '9') |
goto round_9_up; |
if (j > 0) |
dig++; |
*s++ = dig; |
goto ret; |
} |
#endif |
if ((j < 0) || ((j == 0) && !mode |
#ifndef ROUND_BIASED |
&& !(word1 (d) & 1) |
#endif |
)) |
{ |
if (j1 > 0) |
{ |
b = lshift (ptr, b, 1); |
j1 = cmp (b, S); |
if (((j1 > 0) || ((j1 == 0) && (dig & 1))) |
&& dig++ == '9') |
goto round_9_up; |
} |
*s++ = dig; |
goto ret; |
} |
if (j1 > 0) |
{ |
if (dig == '9') |
{ /* possible if i == 1 */ |
round_9_up: |
*s++ = '9'; |
goto roundoff; |
} |
*s++ = dig + 1; |
goto ret; |
} |
*s++ = dig; |
if (i == ilim) |
break; |
b = multadd (ptr, b, 10, 0); |
if (mlo == mhi) |
mlo = mhi = multadd (ptr, mhi, 10, 0); |
else |
{ |
mlo = multadd (ptr, mlo, 10, 0); |
mhi = multadd (ptr, mhi, 10, 0); |
} |
} |
} |
else |
for (i = 1;; i++) |
{ |
*s++ = dig = quorem (b, S) + '0'; |
if (i >= ilim) |
break; |
b = multadd (ptr, b, 10, 0); |
} |
/* Round off last digit */ |
b = lshift (ptr, b, 1); |
j = cmp (b, S); |
if ((j > 0) || ((j == 0) && (dig & 1))) |
{ |
roundoff: |
while (*--s == '9') |
if (s == s0) |
{ |
k++; |
*s++ = '1'; |
goto ret; |
} |
++*s++; |
} |
else |
{ |
while (*--s == '0'); |
s++; |
} |
ret: |
Bfree (ptr, S); |
if (mhi) |
{ |
if (mlo && mlo != mhi) |
Bfree (ptr, mlo); |
Bfree (ptr, mhi); |
} |
ret1: |
Bfree (ptr, b); |
*s = 0; |
*decpt = k + 1; |
if (rve) |
*rve = s; |
return s0; |
} |
/contrib/sdk/sources/libc/stdlib/dtoastub.c |
---|
0,0 → 1,23 |
#include <_ansi.h> |
#include <stdlib.h> |
#include <reent.h> |
#include <string.h> |
/* Nothing in newlib actually *calls* dtoa, they all call _dtoa_r, so this |
is a safe way of providing it to the user. */ |
#ifndef _REENT_ONLY |
char * |
_DEFUN (__dtoa, |
(d, mode, ndigits, decpt, sign, rve), |
double d _AND |
int mode _AND |
int ndigits _AND |
int *decpt _AND |
int *sign _AND |
char **rve) |
{ |
return _dtoa_r (_REENT, d, mode, ndigits, decpt, sign, rve); |
} |
#endif |
/contrib/sdk/sources/libc/stdlib/exit.c |
---|
0,0 → 1,66 |
/* |
* Copyright (c) 1990 Regents of the University of California. |
* All rights reserved. |
* |
* %sccs.include.redist.c% |
*/ |
/* |
FUNCTION |
<<exit>>---end program execution |
INDEX |
exit |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void exit(int <[code]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
void exit(<[code]>) |
int <[code]>; |
DESCRIPTION |
Use <<exit>> to return control from a program to the host operating |
environment. Use the argument <[code]> to pass an exit status to the |
operating environment: two particular values, <<EXIT_SUCCESS>> and |
<<EXIT_FAILURE>>, are defined in `<<stdlib.h>>' to indicate success or |
failure in a portable fashion. |
<<exit>> does two kinds of cleanup before ending execution of your |
program. First, it calls all application-defined cleanup functions |
you have enrolled with <<atexit>>. Second, files and streams are |
cleaned up: any pending output is delivered to the host system, each |
open file or stream is closed, and files created by <<tmpfile>> are |
deleted. |
RETURNS |
<<exit>> does not return to its caller. |
PORTABILITY |
ANSI C requires <<exit>>, and specifies that <<EXIT_SUCCESS>> and |
<<EXIT_FAILURE>> must be defined. |
Supporting OS subroutines required: <<_exit>>. |
*/ |
#include <stdlib.h> |
#include <unistd.h> /* for _exit() declaration */ |
#include <reent.h> |
#include "atexit.h" |
/* |
* Exit, flushing stdio buffers if necessary. |
*/ |
void |
_DEFUN (exit, (code), |
int code) |
{ |
__call_exitprocs (code, NULL); |
if (_GLOBAL_REENT->__cleanup) |
(*_GLOBAL_REENT->__cleanup) (_GLOBAL_REENT); |
_exit (code); |
} |
/contrib/sdk/sources/libc/stdlib/gd_qnan.h |
---|
0,0 → 1,33 |
#ifdef __IEEE_BIG_ENDIAN |
#define f_QNAN 0x7fc00000 |
#define d_QNAN0 0x7ff80000 |
#define d_QNAN1 0x0 |
#define ld_QNAN0 0x7ff80000 |
#define ld_QNAN1 0x0 |
#define ld_QNAN2 0x0 |
#define ld_QNAN3 0x0 |
#define ldus_QNAN0 0x7ff8 |
#define ldus_QNAN1 0x0 |
#define ldus_QNAN2 0x0 |
#define ldus_QNAN3 0x0 |
#define ldus_QNAN4 0x0 |
#elif defined(__IEEE_LITTLE_ENDIAN) |
#define f_QNAN 0xffc00000 |
#define d_QNAN0 0x0 |
#define d_QNAN1 0xfff80000 |
#define ld_QNAN0 0x0 |
#define ld_QNAN1 0xc0000000 |
#define ld_QNAN2 0xffff |
#define ld_QNAN3 0x0 |
#define ldus_QNAN0 0x0 |
#define ldus_QNAN1 0x0 |
#define ldus_QNAN2 0x0 |
#define ldus_QNAN3 0xc000 |
#define ldus_QNAN4 0xffff |
#else |
#error IEEE endian not defined |
#endif |
/contrib/sdk/sources/libc/stdlib/gdtoa-gethex.c |
---|
0,0 → 1,354 |
/**************************************************************** |
The author of this software is David M. Gay. |
Copyright (C) 1998 by Lucent Technologies |
All Rights Reserved |
Permission to use, copy, modify, and distribute this software and |
its documentation for any purpose and without fee is hereby |
granted, provided that the above copyright notice appear in all |
copies and that both that the copyright notice and this |
permission notice and warranty disclaimer appear in supporting |
documentation, and that the name of Lucent or any of its entities |
not be used in advertising or publicity pertaining to |
distribution of the software without specific, written prior |
permission. |
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. |
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY |
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER |
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
THIS SOFTWARE. |
****************************************************************/ |
/* Please send bug reports to David M. Gay (dmg at acm dot org, |
* with " at " changed at "@" and " dot " changed to "."). */ |
#include <_ansi.h> |
#include <reent.h> |
#include <string.h> |
#include "mprec.h" |
#include "gdtoa.h" |
#include "gd_qnan.h" |
#include "locale.h" |
unsigned char hexdig[256]; |
static void |
_DEFUN (htinit, (h, s, inc), |
unsigned char *h _AND |
unsigned char *s _AND |
int inc) |
{ |
int i, j; |
for(i = 0; (j = s[i]) !=0; i++) |
h[j] = i + inc; |
} |
void |
_DEFUN_VOID (hexdig_init) |
{ |
#define USC (unsigned char *) |
htinit(hexdig, USC "0123456789", 0x10); |
htinit(hexdig, USC "abcdef", 0x10 + 10); |
htinit(hexdig, USC "ABCDEF", 0x10 + 10); |
} |
static void |
_DEFUN(rshift, (b, k), |
_Bigint *b _AND |
int k) |
{ |
__ULong *x, *x1, *xe, y; |
int n; |
x = x1 = b->_x; |
n = k >> kshift; |
if (n < b->_wds) { |
xe = x + b->_wds; |
x += n; |
if (k &= kmask) { |
n = ULbits - k; |
y = *x++ >> k; |
while(x < xe) { |
*x1++ = (y | (*x << n)) & ALL_ON; |
y = *x++ >> k; |
} |
if ((*x1 = y) !=0) |
x1++; |
} |
else |
while(x < xe) |
*x1++ = *x++; |
} |
if ((b->_wds = x1 - b->_x) == 0) |
b->_x[0] = 0; |
} |
static _Bigint * |
_DEFUN (increment, (ptr, b), |
struct _reent *ptr _AND |
_Bigint *b) |
{ |
__ULong *x, *xe; |
_Bigint *b1; |
#ifdef Pack_16 |
__ULong carry = 1, y; |
#endif |
x = b->_x; |
xe = x + b->_wds; |
#ifdef Pack_32 |
do { |
if (*x < (__ULong)0xffffffffL) { |
++*x; |
return b; |
} |
*x++ = 0; |
} while(x < xe); |
#else |
do { |
y = *x + carry; |
carry = y >> 16; |
*x++ = y & 0xffff; |
if (!carry) |
return b; |
} while(x < xe); |
if (carry) |
#endif |
{ |
if (b->_wds >= b->_maxwds) { |
b1 = Balloc(ptr, b->_k+1); |
Bcopy(b1, b); |
Bfree(ptr, b); |
b = b1; |
} |
b->_x[b->_wds++] = 1; |
} |
return b; |
} |
int |
_DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign), |
struct _reent *ptr _AND |
_CONST char **sp _AND |
FPI *fpi _AND |
Long *exp _AND |
_Bigint **bp _AND |
int sign) |
{ |
_Bigint *b; |
_CONST unsigned char *decpt, *s0, *s, *s1; |
int esign, havedig, irv, k, n, nbits, up, zret; |
__ULong L, lostbits, *x; |
Long e, e1; |
unsigned char *decimalpoint = (unsigned char *) |
_localeconv_r (ptr)->decimal_point; |
size_t decp_len = strlen ((const char *) decimalpoint); |
unsigned char decp_end = decimalpoint[decp_len - 1]; |
if (!hexdig['0']) |
hexdig_init(); |
havedig = 0; |
s0 = *(_CONST unsigned char **)sp + 2; |
while(s0[havedig] == '0') |
havedig++; |
s0 += havedig; |
s = s0; |
decpt = 0; |
zret = 0; |
e = 0; |
if (!hexdig[*s]) { |
zret = 1; |
if (strncmp ((const char *) s, (const char *) decimalpoint, |
decp_len) != 0) |
goto pcheck; |
decpt = (s += decp_len); |
if (!hexdig[*s]) |
goto pcheck; |
while(*s == '0') |
s++; |
if (hexdig[*s]) |
zret = 0; |
havedig = 1; |
s0 = s; |
} |
while(hexdig[*s]) |
s++; |
if (strncmp ((const char *) s, (const char *) decimalpoint, |
decp_len) == 0 |
&& !decpt) { |
decpt = (s += decp_len); |
while(hexdig[*s]) |
s++; |
} |
if (decpt) |
e = -(((Long)(s-decpt)) << 2); |
pcheck: |
s1 = s; |
switch(*s) { |
case 'p': |
case 'P': |
esign = 0; |
switch(*++s) { |
case '-': |
esign = 1; |
/* no break */ |
case '+': |
s++; |
} |
if ((n = hexdig[*s]) == 0 || n > 0x19) { |
s = s1; |
break; |
} |
e1 = n - 0x10; |
while((n = hexdig[*++s]) !=0 && n <= 0x19) |
e1 = 10*e1 + n - 0x10; |
if (esign) |
e1 = -e1; |
e += e1; |
} |
*sp = (char*)s; |
if (zret) |
return havedig ? STRTOG_Zero : STRTOG_NoNumber; |
n = s1 - s0 - 1; |
for(k = 0; n > 7; n >>= 1) |
k++; |
b = Balloc(ptr, k); |
x = b->_x; |
n = 0; |
L = 0; |
while(s1 > s0) { |
if (*--s1 == decp_end && s1 - decp_len + 1 >= s0 |
&& strncmp ((const char *) s1 - decp_len + 1, |
(const char *) decimalpoint, decp_len) == 0) { |
s1 -= decp_len - 1; /* Note the --s1 above! */ |
continue; |
} |
if (n == 32) { |
*x++ = L; |
L = 0; |
n = 0; |
} |
L |= (hexdig[*s1] & 0x0f) << n; |
n += 4; |
} |
*x++ = L; |
b->_wds = n = x - b->_x; |
n = 32*n - hi0bits(L); |
nbits = fpi->nbits; |
lostbits = 0; |
x = b->_x; |
if (n > nbits) { |
n -= nbits; |
if (any_on(b,n)) { |
lostbits = 1; |
k = n - 1; |
if (x[k>>kshift] & 1 << (k & kmask)) { |
lostbits = 2; |
if (k > 1 && any_on(b,k-1)) |
lostbits = 3; |
} |
} |
rshift(b, n); |
e += n; |
} |
else if (n < nbits) { |
n = nbits - n; |
b = lshift(ptr, b, n); |
e -= n; |
x = b->_x; |
} |
if (e > fpi->emax) { |
ovfl: |
Bfree(ptr, b); |
*bp = 0; |
return STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi; |
} |
irv = STRTOG_Normal; |
if (e < fpi->emin) { |
irv = STRTOG_Denormal; |
n = fpi->emin - e; |
if (n >= nbits) { |
switch (fpi->rounding) { |
case FPI_Round_near: |
if (n == nbits && (n < 2 || any_on(b,n-1))) |
goto one_bit; |
break; |
case FPI_Round_up: |
if (!sign) |
goto one_bit; |
break; |
case FPI_Round_down: |
if (sign) { |
one_bit: |
*exp = fpi->emin; |
x[0] = b->_wds = 1; |
*bp = b; |
return STRTOG_Denormal | STRTOG_Inexhi |
| STRTOG_Underflow; |
} |
} |
Bfree(ptr, b); |
*bp = 0; |
return STRTOG_Zero | STRTOG_Inexlo | STRTOG_Underflow; |
} |
k = n - 1; |
if (lostbits) |
lostbits = 1; |
else if (k > 0) |
lostbits = any_on(b,k); |
if (x[k>>kshift] & 1 << (k & kmask)) |
lostbits |= 2; |
nbits -= n; |
rshift(b,n); |
e = fpi->emin; |
} |
if (lostbits) { |
up = 0; |
switch(fpi->rounding) { |
case FPI_Round_zero: |
break; |
case FPI_Round_near: |
if ((lostbits & 2) |
&& ((lostbits & 1) | (x[0] & 1))) |
up = 1; |
break; |
case FPI_Round_up: |
up = 1 - sign; |
break; |
case FPI_Round_down: |
up = sign; |
} |
if (up) { |
k = b->_wds; |
b = increment(ptr, b); |
x = b->_x; |
if (irv == STRTOG_Denormal) { |
if (nbits == fpi->nbits - 1 |
&& x[nbits >> kshift] & 1 << (nbits & kmask)) |
irv = STRTOG_Normal; |
} |
else if ((b->_wds > k) |
|| ((n = nbits & kmask) !=0 |
&& (hi0bits(x[k-1]) < 32-n))) { |
rshift(b,1); |
if (++e > fpi->emax) |
goto ovfl; |
} |
irv |= STRTOG_Inexhi; |
} |
else |
irv |= STRTOG_Inexlo; |
} |
*bp = b; |
*exp = e; |
return irv; |
} |
/contrib/sdk/sources/libc/stdlib/gdtoa-hexnan.c |
---|
0,0 → 1,142 |
/**************************************************************** |
The author of this software is David M. Gay. |
Copyright (C) 2000 by Lucent Technologies |
All Rights Reserved |
Permission to use, copy, modify, and distribute this software and |
its documentation for any purpose and without fee is hereby |
granted, provided that the above copyright notice appear in all |
copies and that both that the copyright notice and this |
permission notice and warranty disclaimer appear in supporting |
documentation, and that the name of Lucent or any of its entities |
not be used in advertising or publicity pertaining to |
distribution of the software without specific, written prior |
permission. |
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. |
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY |
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER |
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
THIS SOFTWARE. |
****************************************************************/ |
/* Please send bug reports to |
David M. Gay |
Bell Laboratories, Room 2C-463 |
600 Mountain Avenue |
Murray Hill, NJ 07974-0636 |
U.S.A. |
dmg@bell-labs.com |
*/ |
/* Modified 06-21-2006 by Jeff Johnston to work with newlib. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <string.h> |
#include "mprec.h" |
#include "gdtoa.h" |
#ifdef INFNAN_CHECK |
static void |
_DEFUN (L_shift, (x, x1, i), |
__ULong *x _AND |
__ULong *x1 _AND |
int i) |
{ |
int j; |
i = 8 - i; |
i <<= 2; |
j = ULbits - i; |
do { |
*x |= x[1] << j; |
x[1] >>= i; |
} while(++x < x1); |
} |
int |
_DEFUN (hexnan, (sp, fpi, x0), |
_CONST char **sp _AND |
FPI *fpi _AND |
__ULong *x0) |
{ |
__ULong c, h, *x, *x1, *xe; |
_CONST char *s; |
int havedig, hd0, i, nbits; |
if (!hexdig['0']) |
hexdig_init(); |
nbits = fpi->nbits; |
x = x0 + (nbits >> kshift); |
if (nbits & kmask) |
x++; |
*--x = 0; |
x1 = xe = x; |
havedig = hd0 = i = 0; |
s = *sp; |
while((c = *(_CONST unsigned char*)++s)) { |
if (!(h = hexdig[c])) { |
if (c <= ' ') { |
if (hd0 < havedig) { |
if (x < x1 && i < 8) |
L_shift(x, x1, i); |
if (x <= x0) { |
i = 8; |
continue; |
} |
hd0 = havedig; |
*--x = 0; |
x1 = x; |
i = 0; |
} |
continue; |
} |
if (/*(*/ c == ')') { |
*sp = s + 1; |
break; |
} |
return STRTOG_NaN; |
} |
havedig++; |
if (++i > 8) { |
if (x <= x0) |
continue; |
i = 1; |
*--x = 0; |
} |
*x = ((*x << 4) | (h & 0xf)); |
} |
if (!havedig) |
return STRTOG_NaN; |
if (x < x1 && i < 8) |
L_shift(x, x1, i); |
if (x > x0) { |
x1 = x0; |
do *x1++ = *x++; |
while(x <= xe); |
do *x1++ = 0; |
while(x1 <= xe); |
} |
else { |
/* truncate high-order word if necessary */ |
if ( (i = nbits & (ULbits-1)) !=0) |
*xe &= ((__ULong)0xffffffff) >> (ULbits - i); |
} |
for(x1 = xe;; --x1) { |
if (*x1 != 0) |
break; |
if (x1 == x0) { |
*x1 = 1; |
break; |
} |
} |
return STRTOG_NaNbits; |
} |
#endif /* INFNAN_CHECK */ |
/contrib/sdk/sources/libc/stdlib/gdtoa.h |
---|
0,0 → 1,72 |
/**************************************************************** |
The author of this software is David M. Gay. |
Copyright (C) 1998 by Lucent Technologies |
All Rights Reserved |
Permission to use, copy, modify, and distribute this software and |
its documentation for any purpose and without fee is hereby |
granted, provided that the above copyright notice appear in all |
copies and that both that the copyright notice and this |
permission notice and warranty disclaimer appear in supporting |
documentation, and that the name of Lucent or any of its entities |
not be used in advertising or publicity pertaining to |
distribution of the software without specific, written prior |
permission. |
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. |
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY |
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER |
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
THIS SOFTWARE. |
****************************************************************/ |
/* Please send bug reports to David M. Gay (dmg at acm dot org, |
* with " at " changed at "@" and " dot " changed to "."). */ |
#ifndef GDTOA_H_INCLUDED |
#define GDTOA_H_INCLUDED |
enum { /* return values from strtodg */ |
STRTOG_Zero = 0, |
STRTOG_Normal = 1, |
STRTOG_Denormal = 2, |
STRTOG_Infinite = 3, |
STRTOG_NaN = 4, |
STRTOG_NaNbits = 5, |
STRTOG_NoNumber = 6, |
STRTOG_Retmask = 7, |
/* The following may be or-ed into one of the above values. */ |
STRTOG_Neg = 0x08, |
STRTOG_Inexlo = 0x10, |
STRTOG_Inexhi = 0x20, |
STRTOG_Inexact = 0x30, |
STRTOG_Underflow= 0x40, |
STRTOG_Overflow = 0x80 |
}; |
typedef struct |
FPI { |
int nbits; |
int emin; |
int emax; |
int rounding; |
int sudden_underflow; |
} FPI; |
enum { /* FPI.rounding values: same as FLT_ROUNDS */ |
FPI_Round_zero = 0, |
FPI_Round_near = 1, |
FPI_Round_up = 2, |
FPI_Round_down = 3 |
}; |
#endif /* GDTOA_H_INCLUDED */ |
/contrib/sdk/sources/libc/stdlib/getenv.c |
---|
0,0 → 1,93 |
/* |
FUNCTION |
<<getenv>>---look up environment variable |
INDEX |
getenv |
INDEX |
environ |
ANSI_SYNOPSIS |
#include <stdlib.h> |
char *getenv(const char *<[name]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
char *getenv(<[name]>) |
char *<[name]>; |
DESCRIPTION |
<<getenv>> searches the list of environment variable names and values |
(using the global pointer ``<<char **environ>>'') for a variable whose |
name matches the string at <[name]>. If a variable name matches, |
<<getenv>> returns a pointer to the associated value. |
RETURNS |
A pointer to the (string) value of the environment variable, or |
<<NULL>> if there is no such environment variable. |
PORTABILITY |
<<getenv>> is ANSI, but the rules for properly forming names of environment |
variables vary from one system to another. |
<<getenv>> requires a global pointer <<environ>>. |
*/ |
/* |
* Copyright (c) 1987, 2000 Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that: (1) source distributions retain this entire copyright |
* notice and comment, and (2) distributions including binaries display |
* the following acknowledgement: ``This product includes software |
* developed by the University of California, Berkeley and its contributors'' |
* in the documentation or other materials provided with the distribution |
* and in all advertising materials mentioning features or use of this |
* software. Neither the name of the University nor the names of its |
* contributors may be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
#ifndef _REENT_ONLY |
#include <stdlib.h> |
#include <stddef.h> |
#include <string.h> |
/* |
* _findenv -- |
* Returns pointer to value associated with name, if any, else NULL. |
* Sets offset to be the offset of the name/value combination in the |
* environmental array, for use by setenv(3) and unsetenv(3). |
* Explicitly removes '=' in argument name. |
* |
* This routine *should* be a static; don't use it. |
*/ |
char * |
_DEFUN (_findenv, (name, offset), |
register _CONST char *name _AND |
int *offset) |
{ |
return NULL; //_findenv_r (_REENT, name, offset); |
} |
/* |
* getenv -- |
* Returns ptr to value associated with name, if any, else NULL. |
*/ |
char * |
_DEFUN (getenv, (name), |
_CONST char *name) |
{ |
int offset; |
return NULL; //_findenv_r (_REENT, name, &offset); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdlib/local.h |
---|
0,0 → 1,66 |
/* Misc. local definitions for libc/stdlib */ |
#ifndef _LOCAL_H_ |
#define _LOCAL_H_ |
char * _EXFUN(_gcvt,(struct _reent *, double , int , char *, char, int)); |
char *__locale_charset(_NOARGS); |
#ifndef __mbstate_t_defined |
#include <wchar.h> |
#endif |
extern int (*__wctomb) (struct _reent *, char *, wchar_t, const char *, |
mbstate_t *); |
int __ascii_wctomb (struct _reent *, char *, wchar_t, const char *, |
mbstate_t *); |
#ifdef _MB_CAPABLE |
int __utf8_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __sjis_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __eucjp_wctomb (struct _reent *, char *, wchar_t, const char *, |
mbstate_t *); |
int __jis_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __iso_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __cp_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
#ifdef __CYGWIN__ |
int __gbk_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __kr_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int __big5_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
#endif |
#endif |
extern int (*__mbtowc) (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __ascii_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
#ifdef _MB_CAPABLE |
int __utf8_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __sjis_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __eucjp_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __jis_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __iso_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __cp_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
#ifdef __CYGWIN__ |
int __gbk_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __kr_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int __big5_mbtowc (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
#endif |
#endif |
extern wchar_t __iso_8859_conv[14][0x60]; |
int __iso_8859_index (const char *); |
extern wchar_t __cp_conv[][0x80]; |
int __cp_index (const char *); |
#endif |
/contrib/sdk/sources/libc/stdlib/malloc.c |
---|
0,0 → 1,227 |
/* VxWorks provides its own version of malloc, and we can't use this |
one because VxWorks does not provide sbrk. So we have a hook to |
not compile this code. */ |
/* The routines here are simple cover fns to the routines that do the real |
work (the reentrant versions). */ |
/* FIXME: Does the warning below (see WARNINGS) about non-reentrancy still |
apply? A first guess would be "no", but how about reentrancy in the *same* |
thread? */ |
#ifdef MALLOC_PROVIDED |
int _dummy_malloc = 1; |
#else |
/* |
FUNCTION |
<<malloc>>, <<realloc>>, <<free>>---manage memory |
INDEX |
malloc |
INDEX |
realloc |
INDEX |
reallocf |
INDEX |
free |
INDEX |
memalign |
INDEX |
malloc_usable_size |
INDEX |
_malloc_r |
INDEX |
_realloc_r |
INDEX |
_reallocf_r |
INDEX |
_free_r |
INDEX |
_memalign_r |
INDEX |
_malloc_usable_size_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void *malloc(size_t <[nbytes]>); |
void *realloc(void *<[aptr]>, size_t <[nbytes]>); |
void *reallocf(void *<[aptr]>, size_t <[nbytes]>); |
void free(void *<[aptr]>); |
void *memalign(size_t <[align]>, size_t <[nbytes]>); |
size_t malloc_usable_size(void *<[aptr]>); |
void *_malloc_r(void *<[reent]>, size_t <[nbytes]>); |
void *_realloc_r(void *<[reent]>, |
void *<[aptr]>, size_t <[nbytes]>); |
void *_reallocf_r(void *<[reent]>, |
void *<[aptr]>, size_t <[nbytes]>); |
void _free_r(void *<[reent]>, void *<[aptr]>); |
void *_memalign_r(void *<[reent]>, |
size_t <[align]>, size_t <[nbytes]>); |
size_t _malloc_usable_size_r(void *<[reent]>, void *<[aptr]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
char *malloc(<[nbytes]>) |
size_t <[nbytes]>; |
char *realloc(<[aptr]>, <[nbytes]>) |
char *<[aptr]>; |
size_t <[nbytes]>; |
char *reallocf(<[aptr]>, <[nbytes]>) |
char *<[aptr]>; |
size_t <[nbytes]>; |
void free(<[aptr]>) |
char *<[aptr]>; |
char *memalign(<[align]>, <[nbytes]>) |
size_t <[align]>; |
size_t <[nbytes]>; |
size_t malloc_usable_size(<[aptr]>) |
char *<[aptr]>; |
char *_malloc_r(<[reent]>,<[nbytes]>) |
char *<[reent]>; |
size_t <[nbytes]>; |
char *_realloc_r(<[reent]>, <[aptr]>, <[nbytes]>) |
char *<[reent]>; |
char *<[aptr]>; |
size_t <[nbytes]>; |
char *_reallocf_r(<[reent]>, <[aptr]>, <[nbytes]>) |
char *<[reent]>; |
char *<[aptr]>; |
size_t <[nbytes]>; |
void _free_r(<[reent]>, <[aptr]>) |
char *<[reent]>; |
char *<[aptr]>; |
char *_memalign_r(<[reent]>, <[align]>, <[nbytes]>) |
char *<[reent]>; |
size_t <[align]>; |
size_t <[nbytes]>; |
size_t malloc_usable_size(<[reent]>, <[aptr]>) |
char *<[reent]>; |
char *<[aptr]>; |
DESCRIPTION |
These functions manage a pool of system memory. |
Use <<malloc>> to request allocation of an object with at least |
<[nbytes]> bytes of storage available. If the space is available, |
<<malloc>> returns a pointer to a newly allocated block as its result. |
If you already have a block of storage allocated by <<malloc>>, but |
you no longer need all the space allocated to it, you can make it |
smaller by calling <<realloc>> with both the object pointer and the |
new desired size as arguments. <<realloc>> guarantees that the |
contents of the smaller object match the beginning of the original object. |
Similarly, if you need more space for an object, use <<realloc>> to |
request the larger size; again, <<realloc>> guarantees that the |
beginning of the new, larger object matches the contents of the |
original object. |
When you no longer need an object originally allocated by <<malloc>> |
or <<realloc>> (or the related function <<calloc>>), return it to the |
memory storage pool by calling <<free>> with the address of the object |
as the argument. You can also use <<realloc>> for this purpose by |
calling it with <<0>> as the <[nbytes]> argument. |
The <<reallocf>> function behaves just like <<realloc>> except if the |
function is required to allocate new storage and this fails. In this |
case <<reallocf>> will free the original object passed in whereas |
<<realloc>> will not. |
The <<memalign>> function returns a block of size <[nbytes]> aligned |
to a <[align]> boundary. The <[align]> argument must be a power of |
two. |
The <<malloc_usable_size>> function takes a pointer to a block |
allocated by <<malloc>>. It returns the amount of space that is |
available in the block. This may or may not be more than the size |
requested from <<malloc>>, due to alignment or minimum size |
constraints. |
The alternate functions <<_malloc_r>>, <<_realloc_r>>, <<_reallocf_r>>, |
<<_free_r>>, <<_memalign_r>>, and <<_malloc_usable_size_r>> are reentrant |
versions. The extra argument <[reent]> is a pointer to a reentrancy structure. |
If you have multiple threads of execution which may call any of these |
routines, or if any of these routines may be called reentrantly, then |
you must provide implementations of the <<__malloc_lock>> and |
<<__malloc_unlock>> functions for your system. See the documentation |
for those functions. |
These functions operate by calling the function <<_sbrk_r>> or |
<<sbrk>>, which allocates space. You may need to provide one of these |
functions for your system. <<_sbrk_r>> is called with a positive |
value to allocate more space, and with a negative value to release |
previously allocated space if it is no longer required. |
@xref{Stubs}. |
RETURNS |
<<malloc>> returns a pointer to the newly allocated space, if |
successful; otherwise it returns <<NULL>>. If your application needs |
to generate empty objects, you may use <<malloc(0)>> for this purpose. |
<<realloc>> returns a pointer to the new block of memory, or <<NULL>> |
if a new block could not be allocated. <<NULL>> is also the result |
when you use `<<realloc(<[aptr]>,0)>>' (which has the same effect as |
`<<free(<[aptr]>)>>'). You should always check the result of |
<<realloc>>; successful reallocation is not guaranteed even when |
you request a smaller object. |
<<free>> does not return a result. |
<<memalign>> returns a pointer to the newly allocated space. |
<<malloc_usable_size>> returns the usable size. |
PORTABILITY |
<<malloc>>, <<realloc>>, and <<free>> are specified by the ANSI C |
standard, but other conforming implementations of <<malloc>> may |
behave differently when <[nbytes]> is zero. |
<<memalign>> is part of SVR4. |
<<malloc_usable_size>> is not portable. |
Supporting OS subroutines required: <<sbrk>>. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdlib.h> |
#include <malloc.h> |
#ifndef _REENT_ONLY |
_PTR |
_DEFUN (malloc, (nbytes), |
size_t nbytes) /* get a block */ |
{ |
return _malloc_r (_REENT, nbytes); |
} |
void |
_DEFUN (free, (aptr), |
_PTR aptr) |
{ |
_free_r (_REENT, aptr); |
} |
#endif |
#endif /* ! defined (MALLOC_PROVIDED) */ |
/contrib/sdk/sources/libc/stdlib/mallocr.c |
---|
0,0 → 1,2171 |
/* |
This is a version (aka dlmalloc) of malloc/free/realloc written by |
Doug Lea and released to the public domain, as explained at |
http://creativecommons.org/licenses/publicdomain. Send questions, |
comments, complaints, performance data, etc to dl@cs.oswego.edu |
* Version 2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee) |
Note: There may be an updated version of this malloc obtainable at |
ftp://gee.cs.oswego.edu/pub/misc/malloc.c |
Check before installing! |
* Quickstart |
This library is all in one file to simplify the most common usage: |
ftp it, compile it (-O3), and link it into another program. All of |
the compile-time options default to reasonable values for use on |
most platforms. You might later want to step through various |
compile-time and dynamic tuning options. |
For convenience, an include file for code using this malloc is at: |
ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.4.h |
You don't really need this .h file unless you call functions not |
defined in your system include files. The .h file contains only the |
excerpts from this file needed for using this malloc on ANSI C/C++ |
systems, so long as you haven't changed compile-time options about |
naming and tuning parameters. If you do, then you can create your |
own malloc.h that does include all settings by cutting at the point |
indicated below. Note that you may already by default be using a C |
library containing a malloc that is based on some version of this |
malloc (for example in linux). You might still want to use the one |
in this file to customize settings or to avoid overheads associated |
with library versions. |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
struct malloc_chunk { |
size_t prev_foot; /* Size of previous chunk (if free). */ |
size_t head; /* Size and inuse bits. */ |
struct malloc_chunk* fd; /* double links -- used only if free. */ |
struct malloc_chunk* bk; |
}; |
typedef struct malloc_chunk mchunk; |
typedef struct malloc_chunk* mchunkptr; |
typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ |
typedef unsigned int bindex_t; /* Described below */ |
typedef unsigned int binmap_t; /* Described below */ |
typedef unsigned int flag_t; /* The type of various bit flag sets */ |
/* ------------------- size_t and alignment properties -------------------- */ |
/* The maximum possible size_t value has all bits set */ |
#define MAX_SIZE_T (~(size_t)0) |
void *user_alloc(size_t size) |
{ |
void *val; |
// __asm__("int3"); |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(12),"c"(size)); |
return val; |
} |
static inline |
int user_free(void *mem) |
{ |
int val; |
// __asm__("int3"); |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(13),"c"(mem)); |
return val; |
} |
/* ------------------- size_t and alignment properties -------------------- */ |
/* The byte and bit size of a size_t */ |
#define SIZE_T_SIZE (sizeof(size_t)) |
#define SIZE_T_BITSIZE (sizeof(size_t) << 3) |
/* Some constants coerced to size_t */ |
/* Annoying but necessary to avoid errors on some platforms */ |
#define SIZE_T_ZERO ((size_t)0) |
#define SIZE_T_ONE ((size_t)1) |
#define SIZE_T_TWO ((size_t)2) |
#define SIZE_T_FOUR ((size_t)4) |
#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) |
#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) |
#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) |
#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) |
#define USE_LOCK_BIT (2U) |
#define USE_MMAP_BIT (SIZE_T_ONE) |
#define USE_NONCONTIGUOUS_BIT (4U) |
/* segment bit set in create_mspace_with_base */ |
#define EXTERN_BIT (8U) |
#define HAVE_MMAP 1 |
#define CALL_MMAP(s) MMAP_DEFAULT(s) |
#define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) |
#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL |
#define calloc_must_clear(p) (!is_mmapped(p)) |
#define MALLOC_FAILURE_ACTION |
#define MAX_RELEASE_CHECK_RATE 4095 |
#define NO_SEGMENT_TRAVERSAL 1 |
#define MALLOC_ALIGNMENT ((size_t)8U) |
#define CHUNK_OVERHEAD (SIZE_T_SIZE) |
#define DEFAULT_GRANULARITY ((size_t)512U * (size_t)1024U) |
#define DEFAULT_MMAP_THRESHOLD ((size_t)1024U * (size_t)1024U) |
#define DEFAULT_TRIM_THRESHOLD ((size_t)2048U * (size_t)1024U) |
/* The bit mask value corresponding to MALLOC_ALIGNMENT */ |
#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) |
/* True if address a has acceptable alignment */ |
#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) |
/* the number of bytes to offset an address to align it */ |
#define align_offset(A)\ |
((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ |
((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) |
#define MFAIL ((void*)(MAX_SIZE_T)) |
#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ |
/* For sys_alloc, enough padding to ensure can malloc request on success */ |
#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) |
/* |
TOP_FOOT_SIZE is padding at the end of a segment, including space |
that may be needed to place segment records and fenceposts when new |
noncontiguous segments are added. |
*/ |
#define TOP_FOOT_SIZE\ |
(align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) |
/* ------------------- Chunks sizes and alignments ----------------------- */ |
#define MCHUNK_SIZE (sizeof(mchunk)) |
/* MMapped chunks need a second word of overhead ... */ |
#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) |
/* ... and additional padding for fake next-chunk at foot */ |
#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) |
/* The smallest size we can malloc is an aligned minimal chunk */ |
#define MIN_CHUNK_SIZE\ |
((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) |
/* conversion from malloc headers to user pointers, and back */ |
#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) |
#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) |
/* chunk associated with aligned address A */ |
#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) |
/* Bounds on request (not chunk) sizes. */ |
#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) |
#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) |
/* pad request bytes into a usable size */ |
#define pad_request(req) \ |
(((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) |
/* pad request, checking for minimum (but not maximum) */ |
#define request2size(req) \ |
(((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) |
/* ------------------ Operations on head and foot fields ----------------- */ |
/* |
The head field of a chunk is or'ed with PINUSE_BIT when previous |
adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in |
use, unless mmapped, in which case both bits are cleared. |
FLAG4_BIT is not used by this malloc, but might be useful in extensions. |
*/ |
#define PINUSE_BIT (SIZE_T_ONE) |
#define CINUSE_BIT (SIZE_T_TWO) |
#define FLAG4_BIT (SIZE_T_FOUR) |
#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) |
#define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) |
/* Head value for fenceposts */ |
#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) |
/* extraction of fields from head words */ |
#define cinuse(p) ((p)->head & CINUSE_BIT) |
#define pinuse(p) ((p)->head & PINUSE_BIT) |
#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) |
#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) |
#define chunksize(p) ((p)->head & ~(FLAG_BITS)) |
#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) |
/* Treat space at ptr +/- offset as a chunk */ |
#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) |
#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) |
/* Ptr to next or previous physical malloc_chunk. */ |
#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS))) |
#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) |
/* extract next chunk's pinuse bit */ |
#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) |
/* Set size, pinuse bit, and foot */ |
#define set_size_and_pinuse_of_free_chunk(p, s)\ |
((p)->head = (s|PINUSE_BIT), set_foot(p, s)) |
/* Set size, pinuse bit, foot, and clear next pinuse */ |
#define set_free_with_pinuse(p, s, n)\ |
(clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) |
/* Get the internal overhead associated with chunk p */ |
#define overhead_for(p)\ |
(is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) |
struct malloc_tree_chunk { |
/* The first four fields must be compatible with malloc_chunk */ |
size_t prev_foot; |
size_t head; |
struct malloc_tree_chunk* fd; |
struct malloc_tree_chunk* bk; |
struct malloc_tree_chunk* child[2]; |
struct malloc_tree_chunk* parent; |
bindex_t index; |
}; |
typedef struct malloc_tree_chunk tchunk; |
typedef struct malloc_tree_chunk* tchunkptr; |
typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ |
/* A little helper macro for trees */ |
#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) |
struct malloc_segment { |
char* base; /* base address */ |
size_t size; /* allocated size */ |
struct malloc_segment* next; /* ptr to next segment */ |
flag_t sflags; /* mmap and extern flag */ |
}; |
#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) |
#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) |
typedef struct malloc_segment msegment; |
typedef struct malloc_segment* msegmentptr; |
/* ---------------------------- malloc_state ----------------------------- */ |
/* |
A malloc_state holds all of the bookkeeping for a space. |
The main fields are: |
Top |
The topmost chunk of the currently active segment. Its size is |
cached in topsize. The actual size of topmost space is |
topsize+TOP_FOOT_SIZE, which includes space reserved for adding |
fenceposts and segment records if necessary when getting more |
space from the system. The size at which to autotrim top is |
cached from mparams in trim_check, except that it is disabled if |
an autotrim fails. |
Designated victim (dv) |
This is the preferred chunk for servicing small requests that |
don't have exact fits. It is normally the chunk split off most |
recently to service another small request. Its size is cached in |
dvsize. The link fields of this chunk are not maintained since it |
is not kept in a bin. |
SmallBins |
An array of bin headers for free chunks. These bins hold chunks |
with sizes less than MIN_LARGE_SIZE bytes. Each bin contains |
chunks of all the same size, spaced 8 bytes apart. To simplify |
use in double-linked lists, each bin header acts as a malloc_chunk |
pointing to the real first node, if it exists (else pointing to |
itself). This avoids special-casing for headers. But to avoid |
waste, we allocate only the fd/bk pointers of bins, and then use |
repositioning tricks to treat these as the fields of a chunk. |
TreeBins |
Treebins are pointers to the roots of trees holding a range of |
sizes. There are 2 equally spaced treebins for each power of two |
from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything |
larger. |
Bin maps |
There is one bit map for small bins ("smallmap") and one for |
treebins ("treemap). Each bin sets its bit when non-empty, and |
clears the bit when empty. Bit operations are then used to avoid |
bin-by-bin searching -- nearly all "search" is done without ever |
looking at bins that won't be selected. The bit maps |
conservatively use 32 bits per map word, even if on 64bit system. |
For a good description of some of the bit-based techniques used |
here, see Henry S. Warren Jr's book "Hacker's Delight" (and |
supplement at http://hackersdelight.org/). Many of these are |
intended to reduce the branchiness of paths through malloc etc, as |
well as to reduce the number of memory locations read or written. |
Segments |
A list of segments headed by an embedded malloc_segment record |
representing the initial space. |
Address check support |
The least_addr field is the least address ever obtained from |
MORECORE or MMAP. Attempted frees and reallocs of any address less |
than this are trapped (unless INSECURE is defined). |
Magic tag |
A cross-check field that should always hold same value as mparams.magic. |
Flags |
Bits recording whether to use MMAP, locks, or contiguous MORECORE |
Statistics |
Each space keeps track of current and maximum system memory |
obtained via MORECORE or MMAP. |
Trim support |
Fields holding the amount of unused topmost memory that should trigger |
timming, and a counter to force periodic scanning to release unused |
non-topmost segments. |
Locking |
If USE_LOCKS is defined, the "mutex" lock is acquired and released |
around every public call using this mspace. |
Extension support |
A void* pointer and a size_t field that can be used to help implement |
extensions to this malloc. |
*/ |
/* Bin types, widths and sizes */ |
#define NSMALLBINS (32U) |
#define NTREEBINS (32U) |
#define SMALLBIN_SHIFT (3U) |
#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) |
#define TREEBIN_SHIFT (8U) |
#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) |
#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) |
#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) |
struct malloc_state { |
binmap_t smallmap; |
binmap_t treemap; |
size_t dvsize; |
size_t topsize; |
char* least_addr; |
mchunkptr dv; |
mchunkptr top; |
size_t trim_check; |
size_t release_checks; |
size_t magic; |
mchunkptr smallbins[(NSMALLBINS+1)*2]; |
tbinptr treebins[NTREEBINS]; |
size_t footprint; |
size_t max_footprint; |
flag_t mflags; |
__libc_lock_recursive_t lock; /* locate lock among fields that rarely change */ |
msegment seg; |
void* extp; /* Unused but available for extensions */ |
size_t exts; |
}; |
typedef struct malloc_state* mstate; |
/* ------------- Global malloc_state and malloc_params ------------------- */ |
/* |
malloc_params holds global properties, including those that can be |
dynamically set using mallopt. There is a single instance, mparams, |
initialized in init_mparams. Note that the non-zeroness of "magic" |
also serves as an initialization flag. |
*/ |
struct malloc_params |
{ |
volatile size_t magic; |
size_t page_size; |
size_t granularity; |
size_t mmap_threshold; |
size_t trim_threshold; |
flag_t default_mflags; |
}; |
static struct malloc_params mparams; |
/* Ensure mparams initialized */ |
#define ensure_initialization() (void)(mparams.magic != 0 || init_mparams()) |
static struct malloc_state _gm_; |
#define gm (&_gm_) |
#define is_global(M) ((M) == &_gm_) |
#define is_initialized(M) ((M)->top != 0) |
__LOCK_INIT_RECURSIVE(static, malloc_global_mutex); |
#define ACQUIRE_MALLOC_GLOBAL_LOCK() __libc_lock_lock_recursive(malloc_global_mutex); |
#define RELEASE_MALLOC_GLOBAL_LOCK() __libc_lock_unlock_recursive(malloc_global_mutex); |
#define PREACTION(M) ( __libc_lock_lock_recursive((M)->lock)) |
#define POSTACTION(M) { __libc_lock_unlock_recursive((M)->lock); } |
/* ---------------------------- Indexing Bins ---------------------------- */ |
#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) |
#define small_index(s) ((s) >> SMALLBIN_SHIFT) |
#define small_index2size(i) ((i) << SMALLBIN_SHIFT) |
#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) |
/* addressing by index. See above about smallbin repositioning */ |
#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) |
#define treebin_at(M,i) (&((M)->treebins[i])) |
#define compute_tree_index(S, I)\ |
{\ |
unsigned int X = S >> TREEBIN_SHIFT;\ |
if (X == 0)\ |
I = 0;\ |
else if (X > 0xFFFF)\ |
I = NTREEBINS-1;\ |
else {\ |
unsigned int K;\ |
__asm__("bsrl\t%1, %0\n\t" : "=r" (K) : "g" (X));\ |
I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ |
}\ |
} |
/* Bit representing maximum resolved size in a treebin at i */ |
#define bit_for_tree_index(i) \ |
(i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) |
/* Shift placing maximum resolved bit in a treebin at i as sign bit */ |
#define leftshift_for_tree_index(i) \ |
((i == NTREEBINS-1)? 0 : \ |
((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) |
/* The size of the smallest chunk held in bin with index i */ |
#define minsize_for_tree_index(i) \ |
((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ |
(((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) |
/* ------------------------ Operations on bin maps ----------------------- */ |
/* bit corresponding to given index */ |
#define idx2bit(i) ((binmap_t)(1) << (i)) |
/* Mark/Clear bits with given index */ |
#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) |
#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) |
#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) |
#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) |
#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) |
#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) |
/* isolate the least set bit of a bitmap */ |
#define least_bit(x) ((x) & -(x)) |
/* mask with all bits to left of least bit of x on */ |
#define left_bits(x) ((x<<1) | -(x<<1)) |
/* mask with all bits to left of or equal to least bit of x on */ |
#define same_or_left_bits(x) ((x) | -(x)) |
/* index corresponding to given bit. Use x86 asm if possible */ |
#define compute_bit2idx(X, I)\ |
{\ |
unsigned int J;\ |
__asm__("bsfl\t%1, %0\n\t" : "=r" (J) : "g" (X));\ |
I = (bindex_t)J;\ |
} |
#define mark_inuse_foot(M,p,s) |
/* Get/set size at footer */ |
#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) |
#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) |
/* Macros for setting head/foot of non-mmapped chunks */ |
/* Set cinuse bit and pinuse bit of next chunk */ |
#define set_inuse(M,p,s)\ |
((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ |
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) |
/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ |
#define set_inuse_and_pinuse(M,p,s)\ |
((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ |
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) |
/* Set size, cinuse and pinuse bit of this chunk */ |
#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ |
((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) |
#define assert(x) |
#define RTCHECK(e) __builtin_expect(e, 1) |
#define check_free_chunk(M,P) |
#define check_inuse_chunk(M,P) |
#define check_malloced_chunk(M,P,N) |
#define check_mmapped_chunk(M,P) |
#define check_malloc_state(M) |
#define check_top_chunk(M,P) |
/* Check if address a is at least as high as any from MORECORE or MMAP */ |
#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) |
/* Check if address of next chunk n is higher than base chunk p */ |
#define ok_next(p, n) ((char*)(p) < (char*)(n)) |
/* Check if p has inuse status */ |
#define ok_inuse(p) is_inuse(p) |
/* Check if p has its pinuse bit on */ |
#define ok_pinuse(p) pinuse(p) |
#define CORRUPTION_ERROR_ACTION(m) \ |
do { \ |
printf("%s malloc heap corrupted\n",__FUNCTION__); \ |
__asm__("int3"); \ |
}while(0) \ |
#define USAGE_ERROR_ACTION(m, p) \ |
do { \ |
printf("%s malloc heap corrupted\n",__FUNCTION__); \ |
__asm__("int3"); \ |
}while(0) \ |
/* ----------------------- Operations on smallbins ----------------------- */ |
/* |
Various forms of linking and unlinking are defined as macros. Even |
the ones for trees, which are very long but have very short typical |
paths. This is ugly but reduces reliance on inlining support of |
compilers. |
*/ |
/* Link a free chunk into a smallbin */ |
#define insert_small_chunk(M, P, S) {\ |
bindex_t I = small_index(S);\ |
mchunkptr B = smallbin_at(M, I);\ |
mchunkptr F = B;\ |
assert(S >= MIN_CHUNK_SIZE);\ |
if (!smallmap_is_marked(M, I))\ |
mark_smallmap(M, I);\ |
else if (RTCHECK(ok_address(M, B->fd)))\ |
F = B->fd;\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
B->fd = P;\ |
F->bk = P;\ |
P->fd = F;\ |
P->bk = B;\ |
} |
/* Unlink a chunk from a smallbin */ |
#define unlink_small_chunk(M, P, S) {\ |
mchunkptr F = P->fd;\ |
mchunkptr B = P->bk;\ |
bindex_t I = small_index(S);\ |
assert(P != B);\ |
assert(P != F);\ |
assert(chunksize(P) == small_index2size(I));\ |
if (F == B)\ |
clear_smallmap(M, I);\ |
else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\ |
(B == smallbin_at(M,I) || ok_address(M, B)))) {\ |
F->bk = B;\ |
B->fd = F;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
} |
/* Unlink the first chunk from a smallbin */ |
#define unlink_first_small_chunk(M, B, P, I) {\ |
mchunkptr F = P->fd;\ |
assert(P != B);\ |
assert(P != F);\ |
assert(chunksize(P) == small_index2size(I));\ |
if (B == F)\ |
clear_smallmap(M, I);\ |
else if (RTCHECK(ok_address(M, F))) {\ |
B->fd = F;\ |
F->bk = B;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
} |
/* Replace dv node, binning the old one */ |
/* Used only when dvsize known to be small */ |
#define replace_dv(M, P, S) {\ |
size_t DVS = M->dvsize;\ |
if (DVS != 0) {\ |
mchunkptr DV = M->dv;\ |
assert(is_small(DVS));\ |
insert_small_chunk(M, DV, DVS);\ |
}\ |
M->dvsize = S;\ |
M->dv = P;\ |
} |
/* ------------------------- Operations on trees ------------------------- */ |
/* Insert chunk into tree */ |
#define insert_large_chunk(M, X, S) {\ |
tbinptr* H;\ |
bindex_t I;\ |
compute_tree_index(S, I);\ |
H = treebin_at(M, I);\ |
X->index = I;\ |
X->child[0] = X->child[1] = 0;\ |
if (!treemap_is_marked(M, I)) {\ |
mark_treemap(M, I);\ |
*H = X;\ |
X->parent = (tchunkptr)H;\ |
X->fd = X->bk = X;\ |
}\ |
else {\ |
tchunkptr T = *H;\ |
size_t K = S << leftshift_for_tree_index(I);\ |
for (;;) {\ |
if (chunksize(T) != S) {\ |
tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ |
K <<= 1;\ |
if (*C != 0)\ |
T = *C;\ |
else if (RTCHECK(ok_address(M, C))) {\ |
*C = X;\ |
X->parent = T;\ |
X->fd = X->bk = X;\ |
break;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
break;\ |
}\ |
}\ |
else {\ |
tchunkptr F = T->fd;\ |
if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ |
T->fd = F->bk = X;\ |
X->fd = F;\ |
X->bk = T;\ |
X->parent = 0;\ |
break;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
break;\ |
}\ |
}\ |
}\ |
}\ |
} |
/* |
Unlink steps: |
1. If x is a chained node, unlink it from its same-sized fd/bk links |
and choose its bk node as its replacement. |
2. If x was the last node of its size, but not a leaf node, it must |
be replaced with a leaf node (not merely one with an open left or |
right), to make sure that lefts and rights of descendents |
correspond properly to bit masks. We use the rightmost descendent |
of x. We could use any other leaf, but this is easy to locate and |
tends to counteract removal of leftmosts elsewhere, and so keeps |
paths shorter than minimally guaranteed. This doesn't loop much |
because on average a node in a tree is near the bottom. |
3. If x is the base of a chain (i.e., has parent links) relink |
x's parent and children to x's replacement (or null if none). |
*/ |
#define unlink_large_chunk(M, X) {\ |
tchunkptr XP = X->parent;\ |
tchunkptr R;\ |
if (X->bk != X) {\ |
tchunkptr F = X->fd;\ |
R = X->bk;\ |
if (RTCHECK(ok_address(M, F))) {\ |
F->bk = R;\ |
R->fd = F;\ |
}\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
else {\ |
tchunkptr* RP;\ |
if (((R = *(RP = &(X->child[1]))) != 0) ||\ |
((R = *(RP = &(X->child[0]))) != 0)) {\ |
tchunkptr* CP;\ |
while ((*(CP = &(R->child[1])) != 0) ||\ |
(*(CP = &(R->child[0])) != 0)) {\ |
R = *(RP = CP);\ |
}\ |
if (RTCHECK(ok_address(M, RP)))\ |
*RP = 0;\ |
else {\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
}\ |
if (XP != 0) {\ |
tbinptr* H = treebin_at(M, X->index);\ |
if (X == *H) {\ |
if ((*H = R) == 0) \ |
clear_treemap(M, X->index);\ |
}\ |
else if (RTCHECK(ok_address(M, XP))) {\ |
if (XP->child[0] == X) \ |
XP->child[0] = R;\ |
else \ |
XP->child[1] = R;\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
if (R != 0) {\ |
if (RTCHECK(ok_address(M, R))) {\ |
tchunkptr C0, C1;\ |
R->parent = XP;\ |
if ((C0 = X->child[0]) != 0) {\ |
if (RTCHECK(ok_address(M, C0))) {\ |
R->child[0] = C0;\ |
C0->parent = R;\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
if ((C1 = X->child[1]) != 0) {\ |
if (RTCHECK(ok_address(M, C1))) {\ |
R->child[1] = C1;\ |
C1->parent = R;\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
else\ |
CORRUPTION_ERROR_ACTION(M);\ |
}\ |
}\ |
} |
/* Relays to large vs small bin operations */ |
#define insert_chunk(M, P, S)\ |
if (is_small(S)) insert_small_chunk(M, P, S)\ |
else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } |
#define unlink_chunk(M, P, S)\ |
if (is_small(S)) unlink_small_chunk(M, P, S)\ |
else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } |
/* -------------------------- system alloc setup ------------------------- */ |
/* Operations on mflags */ |
#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) |
#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) |
#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) |
#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) |
#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) |
#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) |
#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) |
#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) |
#define set_lock(M,L)\ |
((M)->mflags = (L)?\ |
((M)->mflags | USE_LOCK_BIT) :\ |
((M)->mflags & ~USE_LOCK_BIT)) |
/* page-align a size */ |
#define page_align(S)\ |
(((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) |
/* granularity-align a size */ |
#define granularity_align(S)\ |
(((S) + (mparams.granularity - SIZE_T_ONE))\ |
& ~(mparams.granularity - SIZE_T_ONE)) |
/* For mmap, use granularity alignment */ |
#define mmap_align(S) granularity_align(S) |
/* For sys_alloc, enough padding to ensure can malloc request on success */ |
#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) |
#define is_page_aligned(S)\ |
(((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) |
#define is_granularity_aligned(S)\ |
(((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) |
/* True if segment S holds address A */ |
#define segment_holds(S, A)\ |
((char*)(A) >= S->base && (char*)(A) < S->base + S->size) |
/* Return segment holding given address */ |
static msegmentptr segment_holding(mstate m, char* addr) |
{ |
msegmentptr sp = &m->seg; |
for (;;) { |
if (addr >= sp->base && addr < sp->base + sp->size) |
return sp; |
if ((sp = sp->next) == 0) |
return 0; |
} |
} |
/* Return true if segment contains a segment link */ |
static int has_segment_link(mstate m, msegmentptr ss) |
{ |
msegmentptr sp = &m->seg; |
for (;;) { |
if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) |
return 1; |
if ((sp = sp->next) == 0) |
return 0; |
} |
} |
static inline void* os_mmap(size_t size) |
{ |
void* ptr = user_alloc(size); |
return (ptr != 0)? ptr: MFAIL; |
} |
static inline int os_munmap(void* ptr, size_t size) |
{ |
return (user_free(ptr) != 0) ? 0 : -1; |
} |
#define should_trim(M,s) ((s) > (M)->trim_check) |
#define MMAP_DEFAULT(s) os_mmap(s) |
#define MUNMAP_DEFAULT(a, s) os_munmap((a), (s)) |
#define DIRECT_MMAP_DEFAULT(s) os_mmap(s) |
#define internal_malloc(m, b) malloc(b) |
#define internal_free(m, mem) free(mem) |
/* ----------------------- Direct-mmapping chunks ----------------------- */ |
/* |
Directly mmapped chunks are set up with an offset to the start of |
the mmapped region stored in the prev_foot field of the chunk. This |
allows reconstruction of the required argument to MUNMAP when freed, |
and also allows adjustment of the returned chunk to meet alignment |
requirements (especially in memalign). |
*/ |
/* Malloc using mmap */ |
static void* mmap_alloc(mstate m, size_t nb) |
{ |
size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); |
if (mmsize > nb) /* Check for wrap around 0 */ |
{ |
char* mm = (char*)(os_mmap(mmsize)); |
if (mm != CMFAIL) |
{ |
size_t offset = align_offset(chunk2mem(mm)); |
size_t psize = mmsize - offset - MMAP_FOOT_PAD; |
mchunkptr p = (mchunkptr)(mm + offset); |
p->prev_foot = offset; |
p->head = psize; |
mark_inuse_foot(m, p, psize); |
chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; |
chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; |
if (m->least_addr == 0 || mm < m->least_addr) |
m->least_addr = mm; |
if ((m->footprint += mmsize) > m->max_footprint) |
m->max_footprint = m->footprint; |
assert(is_aligned(chunk2mem(p))); |
check_mmapped_chunk(m, p); |
return chunk2mem(p); |
} |
} |
return 0; |
} |
/* Realloc using mmap */ |
static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) |
{ |
size_t oldsize = chunksize(oldp); |
if (is_small(nb)) /* Can't shrink mmap regions below small size */ |
return 0; |
/* Keep old chunk if big enough but not too big */ |
if (oldsize >= nb + SIZE_T_SIZE && |
(oldsize - nb) <= (mparams.granularity << 1)) |
return oldp; |
else |
{ |
size_t offset = oldp->prev_foot; |
size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; |
size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); |
char* cp = (char*)CALL_MREMAP((char*)oldp - offset, |
oldmmsize, newmmsize, 1); |
if (cp != CMFAIL) |
{ |
mchunkptr newp = (mchunkptr)(cp + offset); |
size_t psize = newmmsize - offset - MMAP_FOOT_PAD; |
newp->head = psize; |
mark_inuse_foot(m, newp, psize); |
chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; |
chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; |
if (cp < m->least_addr) |
m->least_addr = cp; |
if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) |
m->max_footprint = m->footprint; |
check_mmapped_chunk(m, newp); |
return newp; |
} |
} |
return 0; |
} |
/* ---------------------------- setting mparams -------------------------- */ |
/* Initialize mparams */ |
static int init_mparams(void) { |
ACQUIRE_MALLOC_GLOBAL_LOCK(); |
if (mparams.magic == 0) |
{ |
size_t magic; |
size_t psize; |
size_t gsize; |
psize = 4096; |
gsize = DEFAULT_GRANULARITY; |
/* Sanity-check configuration: |
size_t must be unsigned and as wide as pointer type. |
ints must be at least 4 bytes. |
alignment must be at least 8. |
Alignment, min chunk size, and page size must all be powers of 2. |
*/ |
mparams.granularity = gsize; |
mparams.page_size = psize; |
mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; |
mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; |
mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; |
/* Set up lock for main malloc area */ |
gm->mflags = mparams.default_mflags; |
__libc_lock_init_recursive(gm->lock); |
magic = (size_t)(0x12345678 ^ (size_t)0x55555555U); |
magic |= (size_t)8U; /* ensure nonzero */ |
magic &= ~(size_t)7U; /* improve chances of fault for bad values */ |
mparams.magic = magic; |
} |
RELEASE_MALLOC_GLOBAL_LOCK(); |
return 1; |
} |
/* -------------------------- mspace management -------------------------- */ |
/* Initialize top chunk and its size */ |
static void init_top(mstate m, mchunkptr p, size_t psize) |
{ |
/* Ensure alignment */ |
size_t offset = align_offset(chunk2mem(p)); |
p = (mchunkptr)((char*)p + offset); |
psize -= offset; |
m->top = p; |
m->topsize = psize; |
p->head = psize | PINUSE_BIT; |
/* set size of fake trailing chunk holding overhead space only once */ |
chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; |
m->trim_check = mparams.trim_threshold; /* reset on each update */ |
} |
/* Initialize bins for a new mstate that is otherwise zeroed out */ |
static void init_bins(mstate m) |
{ |
/* Establish circular links for smallbins */ |
bindex_t i; |
for (i = 0; i < NSMALLBINS; ++i) { |
sbinptr bin = smallbin_at(m,i); |
bin->fd = bin->bk = bin; |
} |
} |
/* Allocate chunk and prepend remainder with chunk in successor base. */ |
static void* prepend_alloc(mstate m, char* newbase, char* oldbase, |
size_t nb) |
{ |
mchunkptr p = align_as_chunk(newbase); |
mchunkptr oldfirst = align_as_chunk(oldbase); |
size_t psize = (char*)oldfirst - (char*)p; |
mchunkptr q = chunk_plus_offset(p, nb); |
size_t qsize = psize - nb; |
set_size_and_pinuse_of_inuse_chunk(m, p, nb); |
assert((char*)oldfirst > (char*)q); |
assert(pinuse(oldfirst)); |
assert(qsize >= MIN_CHUNK_SIZE); |
/* consolidate remainder with first chunk of old base */ |
if (oldfirst == m->top) { |
size_t tsize = m->topsize += qsize; |
m->top = q; |
q->head = tsize | PINUSE_BIT; |
check_top_chunk(m, q); |
} |
else if (oldfirst == m->dv) { |
size_t dsize = m->dvsize += qsize; |
m->dv = q; |
set_size_and_pinuse_of_free_chunk(q, dsize); |
} |
else { |
if (!is_inuse(oldfirst)) { |
size_t nsize = chunksize(oldfirst); |
unlink_chunk(m, oldfirst, nsize); |
oldfirst = chunk_plus_offset(oldfirst, nsize); |
qsize += nsize; |
} |
set_free_with_pinuse(q, qsize, oldfirst); |
insert_chunk(m, q, qsize); |
check_free_chunk(m, q); |
} |
check_malloced_chunk(m, chunk2mem(p), nb); |
return chunk2mem(p); |
} |
/* Add a segment to hold a new noncontiguous region */ |
static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) |
{ |
/* Determine locations and sizes of segment, fenceposts, old top */ |
char* old_top = (char*)m->top; |
msegmentptr oldsp = segment_holding(m, old_top); |
char* old_end = oldsp->base + oldsp->size; |
size_t ssize = pad_request(sizeof(struct malloc_segment)); |
char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); |
size_t offset = align_offset(chunk2mem(rawsp)); |
char* asp = rawsp + offset; |
char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; |
mchunkptr sp = (mchunkptr)csp; |
msegmentptr ss = (msegmentptr)(chunk2mem(sp)); |
mchunkptr tnext = chunk_plus_offset(sp, ssize); |
mchunkptr p = tnext; |
int nfences = 0; |
/* reset top to new space */ |
init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); |
/* Set up segment record */ |
assert(is_aligned(ss)); |
set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); |
*ss = m->seg; /* Push current record */ |
m->seg.base = tbase; |
m->seg.size = tsize; |
m->seg.sflags = mmapped; |
m->seg.next = ss; |
/* Insert trailing fenceposts */ |
for (;;) { |
mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); |
p->head = FENCEPOST_HEAD; |
++nfences; |
if ((char*)(&(nextp->head)) < old_end) |
p = nextp; |
else |
break; |
} |
assert(nfences >= 2); |
/* Insert the rest of old top into a bin as an ordinary free chunk */ |
if (csp != old_top) { |
mchunkptr q = (mchunkptr)old_top; |
size_t psize = csp - old_top; |
mchunkptr tn = chunk_plus_offset(q, psize); |
set_free_with_pinuse(q, psize, tn); |
insert_chunk(m, q, psize); |
} |
check_top_chunk(m, m->top); |
} |
/* -------------------------- System allocation -------------------------- */ |
/* Get memory from system using MORECORE or MMAP */ |
static void* sys_alloc(mstate m, size_t nb) |
{ |
char* tbase = CMFAIL; |
size_t tsize = 0; |
flag_t mmap_flag = 0; |
ensure_initialization(); |
/* Directly map large chunks, but only if already initialized */ |
if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) |
{ |
void* mem = mmap_alloc(m, nb); |
if (mem != 0) |
return mem; |
} |
/* |
Try getting memory in any of three ways (in most-preferred to |
least-preferred order): |
1. A call to MORECORE that can normally contiguously extend memory. |
(disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or |
or main space is mmapped or a previous contiguous call failed) |
2. A call to MMAP new space (disabled if not HAVE_MMAP). |
Note that under the default settings, if MORECORE is unable to |
fulfill a request, and HAVE_MMAP is true, then mmap is |
used as a noncontiguous system allocator. This is a useful backup |
strategy for systems with holes in address spaces -- in this case |
sbrk cannot contiguously expand the heap, but mmap may be able to |
find space. |
3. A call to MORECORE that cannot usually contiguously extend memory. |
(disabled if not HAVE_MORECORE) |
In all cases, we need to request enough bytes from system to ensure |
we can malloc nb bytes upon success, so pad with enough space for |
top_foot, plus alignment-pad to make sure we don't lose bytes if |
not on boundary, and round this up to a granularity unit. |
*/ |
if (HAVE_MMAP && tbase == CMFAIL) /* Try MMAP */ |
{ |
size_t rsize = granularity_align(nb + SYS_ALLOC_PADDING); |
if (rsize > nb) /* Fail if wraps around zero */ |
{ |
char* mp = (char*)(CALL_MMAP(rsize)); |
if (mp != CMFAIL) |
{ |
tbase = mp; |
tsize = rsize; |
mmap_flag = USE_MMAP_BIT; |
} |
} |
} |
if (tbase != CMFAIL) |
{ |
if ((m->footprint += tsize) > m->max_footprint) |
m->max_footprint = m->footprint; |
if (!is_initialized(m)) /* first-time initialization */ |
{ |
if (m->least_addr == 0 || tbase < m->least_addr) |
m->least_addr = tbase; |
m->seg.base = tbase; |
m->seg.size = tsize; |
m->seg.sflags = mmap_flag; |
m->magic = mparams.magic; |
m->release_checks = MAX_RELEASE_CHECK_RATE; |
init_bins(m); |
if (is_global(m)) |
init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); |
else |
{ |
/* Offset top by embedded malloc_state */ |
mchunkptr mn = next_chunk(mem2chunk(m)); |
init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); |
} |
} |
else |
{ |
/* Try to merge with an existing segment */ |
msegmentptr sp = &m->seg; |
/* Only consider most recent segment if traversal suppressed */ |
while (sp != 0 && tbase != sp->base + sp->size) |
sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; |
if (sp != 0 && !is_extern_segment(sp) && |
(sp->sflags & USE_MMAP_BIT) == mmap_flag && |
segment_holds(sp, m->top)) /* append */ |
{ |
sp->size += tsize; |
init_top(m, m->top, m->topsize + tsize); |
} |
else |
{ |
if (tbase < m->least_addr) |
m->least_addr = tbase; |
sp = &m->seg; |
while (sp != 0 && sp->base != tbase + tsize) |
sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; |
if (sp != 0 && !is_extern_segment(sp) && |
(sp->sflags & USE_MMAP_BIT) == mmap_flag) |
{ |
char* oldbase = sp->base; |
sp->base = tbase; |
sp->size += tsize; |
return prepend_alloc(m, tbase, oldbase, nb); |
} |
else |
add_segment(m, tbase, tsize, mmap_flag); |
} |
} |
if (nb < m->topsize) /* Allocate from new or extended top space */ |
{ |
size_t rsize = m->topsize -= nb; |
mchunkptr p = m->top; |
mchunkptr r = m->top = chunk_plus_offset(p, nb); |
r->head = rsize | PINUSE_BIT; |
set_size_and_pinuse_of_inuse_chunk(m, p, nb); |
check_top_chunk(m, m->top); |
check_malloced_chunk(m, chunk2mem(p), nb); |
return chunk2mem(p); |
} |
} |
MALLOC_FAILURE_ACTION; |
return 0; |
} |
/* ----------------------- system deallocation -------------------------- */ |
/* Unmap and unlink any mmapped segments that don't contain used chunks */ |
static size_t release_unused_segments(mstate m) |
{ |
size_t released = 0; |
int nsegs = 0; |
msegmentptr pred = &m->seg; |
msegmentptr sp = pred->next; |
while (sp != 0) |
{ |
char* base = sp->base; |
size_t size = sp->size; |
msegmentptr next = sp->next; |
++nsegs; |
if (is_mmapped_segment(sp) && !is_extern_segment(sp)) |
{ |
mchunkptr p = align_as_chunk(base); |
size_t psize = chunksize(p); |
/* Can unmap if first chunk holds entire segment and not pinned */ |
if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) |
{ |
tchunkptr tp = (tchunkptr)p; |
assert(segment_holds(sp, (char*)sp)); |
if (p == m->dv) { |
m->dv = 0; |
m->dvsize = 0; |
} |
else { |
unlink_large_chunk(m, tp); |
} |
if (CALL_MUNMAP(base, size) == 0) |
{ |
released += size; |
m->footprint -= size; |
/* unlink obsoleted record */ |
sp = pred; |
sp->next = next; |
} |
else { /* back out if cannot unmap */ |
insert_large_chunk(m, tp, psize); |
} |
} |
} |
if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ |
break; |
pred = sp; |
sp = next; |
} |
/* Reset check counter */ |
m->release_checks = ((nsegs > MAX_RELEASE_CHECK_RATE)? |
nsegs : MAX_RELEASE_CHECK_RATE); |
return released; |
} |
static int sys_trim(mstate m, size_t pad) |
{ |
size_t released = 0; |
ensure_initialization(); |
if (pad < MAX_REQUEST && is_initialized(m)) |
{ |
pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ |
if (m->topsize > pad) |
{ |
/* Shrink top space in granularity-size units, keeping at least one */ |
size_t unit = mparams.granularity; |
size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - |
SIZE_T_ONE) * unit; |
msegmentptr sp = segment_holding(m, (char*)m->top); |
if (!is_extern_segment(sp)) |
{ |
if (is_mmapped_segment(sp)) |
{ |
if (HAVE_MMAP && |
sp->size >= extra && |
!has_segment_link(m, sp)) /* can't shrink if pinned */ |
{ |
size_t newsize = sp->size - extra; |
/* Prefer mremap, fall back to munmap */ |
if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || |
(CALL_MUNMAP(sp->base + newsize, extra) == 0)) |
{ |
released = extra; |
} |
} |
} |
} |
if (released != 0) |
{ |
sp->size -= released; |
m->footprint -= released; |
init_top(m, m->top, m->topsize - released); |
check_top_chunk(m, m->top); |
} |
} |
/* Unmap any unused mmapped segments */ |
if (HAVE_MMAP) |
released += release_unused_segments(m); |
/* On failure, disable autotrim to avoid repeated failed future calls */ |
if (released == 0 && m->topsize > m->trim_check) |
m->trim_check = MAX_SIZE_T; |
} |
return (released != 0)? 1 : 0; |
} |
/* ---------------------------- malloc support --------------------------- */ |
/* allocate a large request from the best fitting chunk in a treebin */ |
static void* tmalloc_large(mstate m, size_t nb) { |
tchunkptr v = 0; |
size_t rsize = -nb; /* Unsigned negation */ |
tchunkptr t; |
bindex_t idx; |
compute_tree_index(nb, idx); |
if ((t = *treebin_at(m, idx)) != 0) { |
/* Traverse tree for this bin looking for node with size == nb */ |
size_t sizebits = nb << leftshift_for_tree_index(idx); |
tchunkptr rst = 0; /* The deepest untaken right subtree */ |
for (;;) { |
tchunkptr rt; |
size_t trem = chunksize(t) - nb; |
if (trem < rsize) { |
v = t; |
if ((rsize = trem) == 0) |
break; |
} |
rt = t->child[1]; |
t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; |
if (rt != 0 && rt != t) |
rst = rt; |
if (t == 0) { |
t = rst; /* set t to least subtree holding sizes > nb */ |
break; |
} |
sizebits <<= 1; |
} |
} |
if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ |
binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; |
if (leftbits != 0) { |
bindex_t i; |
binmap_t leastbit = least_bit(leftbits); |
compute_bit2idx(leastbit, i); |
t = *treebin_at(m, i); |
} |
} |
while (t != 0) { /* find smallest of tree or subtree */ |
size_t trem = chunksize(t) - nb; |
if (trem < rsize) { |
rsize = trem; |
v = t; |
} |
t = leftmost_child(t); |
} |
/* If dv is a better fit, return 0 so malloc will use it */ |
if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { |
if (RTCHECK(ok_address(m, v))) { /* split */ |
mchunkptr r = chunk_plus_offset(v, nb); |
assert(chunksize(v) == rsize + nb); |
if (RTCHECK(ok_next(v, r))) { |
unlink_large_chunk(m, v); |
if (rsize < MIN_CHUNK_SIZE) |
set_inuse_and_pinuse(m, v, (rsize + nb)); |
else { |
set_size_and_pinuse_of_inuse_chunk(m, v, nb); |
set_size_and_pinuse_of_free_chunk(r, rsize); |
insert_chunk(m, r, rsize); |
} |
return chunk2mem(v); |
} |
} |
CORRUPTION_ERROR_ACTION(m); |
} |
return 0; |
} |
/* allocate a small request from the best fitting chunk in a treebin */ |
static void* tmalloc_small(mstate m, size_t nb) |
{ |
tchunkptr t, v; |
size_t rsize; |
bindex_t i; |
binmap_t leastbit = least_bit(m->treemap); |
compute_bit2idx(leastbit, i); |
v = t = *treebin_at(m, i); |
rsize = chunksize(t) - nb; |
while ((t = leftmost_child(t)) != 0) { |
size_t trem = chunksize(t) - nb; |
if (trem < rsize) { |
rsize = trem; |
v = t; |
} |
} |
if (RTCHECK(ok_address(m, v))) { |
mchunkptr r = chunk_plus_offset(v, nb); |
assert(chunksize(v) == rsize + nb); |
if (RTCHECK(ok_next(v, r))) { |
unlink_large_chunk(m, v); |
if (rsize < MIN_CHUNK_SIZE) |
set_inuse_and_pinuse(m, v, (rsize + nb)); |
else { |
set_size_and_pinuse_of_inuse_chunk(m, v, nb); |
set_size_and_pinuse_of_free_chunk(r, rsize); |
replace_dv(m, r, rsize); |
} |
return chunk2mem(v); |
} |
} |
CORRUPTION_ERROR_ACTION(m); |
return 0; |
} |
/* --------------------------- realloc support --------------------------- */ |
static void* internal_realloc(struct _reent *reent_ptr, mstate m, void* oldmem, size_t bytes) |
{ |
if (bytes >= MAX_REQUEST) |
{ |
MALLOC_FAILURE_ACTION; |
return 0; |
} |
PREACTION(m); |
{ |
mchunkptr oldp = mem2chunk(oldmem); |
size_t oldsize = chunksize(oldp); |
mchunkptr next = chunk_plus_offset(oldp, oldsize); |
mchunkptr newp = 0; |
void* extra = 0; |
/* Try to either shrink or extend into top. Else malloc-copy-free */ |
if (RTCHECK(ok_address(m, oldp) && ok_inuse(oldp) && |
ok_next(oldp, next) && ok_pinuse(next))) |
{ |
size_t nb = request2size(bytes); |
if (is_mmapped(oldp)) |
newp = mmap_resize(m, oldp, nb); |
else if (oldsize >= nb) { /* already big enough */ |
size_t rsize = oldsize - nb; |
newp = oldp; |
if (rsize >= MIN_CHUNK_SIZE) |
{ |
mchunkptr remainder = chunk_plus_offset(newp, nb); |
set_inuse(m, newp, nb); |
set_inuse_and_pinuse(m, remainder, rsize); |
extra = chunk2mem(remainder); |
} |
} |
else if (next == m->top && oldsize + m->topsize > nb) |
{ |
/* Expand into top */ |
size_t newsize = oldsize + m->topsize; |
size_t newtopsize = newsize - nb; |
mchunkptr newtop = chunk_plus_offset(oldp, nb); |
set_inuse(m, oldp, nb); |
newtop->head = newtopsize |PINUSE_BIT; |
m->top = newtop; |
m->topsize = newtopsize; |
newp = oldp; |
} |
} |
else { |
USAGE_ERROR_ACTION(m, oldmem); |
POSTACTION(m); |
return 0; |
} |
#if DEBUG |
if (newp != 0) { |
check_inuse_chunk(m, newp); /* Check requires lock */ |
} |
#endif |
POSTACTION(m); |
if (newp != 0) |
{ |
if (extra != 0) { |
_free_r(reent_ptr, extra); |
} |
return chunk2mem(newp); |
} |
else |
{ |
void* newmem = _malloc_r(reent_ptr, bytes); |
if (newmem != 0) { |
size_t oc = oldsize - overhead_for(oldp); |
memcpy(newmem, oldmem, (oc < bytes)? oc : bytes); |
_free_r(reent_ptr, oldmem); |
} |
return newmem; |
} |
} |
return 0; |
} |
/* --------------------------- memalign support -------------------------- */ |
static void* internal_memalign(mstate m, size_t alignment, size_t bytes) |
{ |
if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ |
return internal_malloc(m, bytes); |
if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ |
alignment = MIN_CHUNK_SIZE; |
if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ |
size_t a = MALLOC_ALIGNMENT << 1; |
while (a < alignment) a <<= 1; |
alignment = a; |
} |
if (bytes >= MAX_REQUEST - alignment) { |
if (m != 0) { /* Test isn't needed but avoids compiler warning */ |
MALLOC_FAILURE_ACTION; |
} |
} |
else |
{ |
size_t nb = request2size(bytes); |
size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; |
char* mem = (char*)internal_malloc(m, req); |
if (mem != 0) |
{ |
void* leader = 0; |
void* trailer = 0; |
mchunkptr p = mem2chunk(mem); |
PREACTION(m); |
if ((((size_t)(mem)) % alignment) != 0) /* misaligned */ |
{ |
/* |
Find an aligned spot inside chunk. Since we need to give |
back leading space in a chunk of at least MIN_CHUNK_SIZE, if |
the first calculation places us at a spot with less than |
MIN_CHUNK_SIZE leader, we can move to the next aligned spot. |
We've allocated enough total room so that this is always |
possible. |
*/ |
char* br = (char*)mem2chunk((size_t)(((size_t)(mem + |
alignment - |
SIZE_T_ONE)) & |
-alignment)); |
char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? |
br : br+alignment; |
mchunkptr newp = (mchunkptr)pos; |
size_t leadsize = pos - (char*)(p); |
size_t newsize = chunksize(p) - leadsize; |
if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ |
newp->prev_foot = p->prev_foot + leadsize; |
newp->head = newsize; |
} |
else { /* Otherwise, give back leader, use the rest */ |
set_inuse(m, newp, newsize); |
set_inuse(m, p, leadsize); |
leader = chunk2mem(p); |
} |
p = newp; |
} |
/* Give back spare room at the end */ |
if (!is_mmapped(p)) |
{ |
size_t size = chunksize(p); |
if (size > nb + MIN_CHUNK_SIZE) |
{ |
size_t remainder_size = size - nb; |
mchunkptr remainder = chunk_plus_offset(p, nb); |
set_inuse(m, p, nb); |
set_inuse(m, remainder, remainder_size); |
trailer = chunk2mem(remainder); |
} |
} |
assert (chunksize(p) >= nb); |
assert((((size_t)(chunk2mem(p))) % alignment) == 0); |
check_inuse_chunk(m, p); |
POSTACTION(m); |
if (leader != 0) { |
internal_free(m, leader); |
} |
if (trailer != 0) { |
internal_free(m, trailer); |
} |
return chunk2mem(p); |
} |
} |
return 0; |
} |
void* memalign(size_t alignment, size_t bytes) |
{ |
return internal_memalign(gm, alignment, bytes); |
} |
void* _malloc_r(struct _reent *reent_ptr, size_t bytes) { |
/* |
Basic algorithm: |
If a small request (< 256 bytes minus per-chunk overhead): |
1. If one exists, use a remainderless chunk in associated smallbin. |
(Remainderless means that there are too few excess bytes to |
represent as a chunk.) |
2. If it is big enough, use the dv chunk, which is normally the |
chunk adjacent to the one used for the most recent small request. |
3. If one exists, split the smallest available chunk in a bin, |
saving remainder in dv. |
4. If it is big enough, use the top chunk. |
5. If available, get memory from system and use it |
Otherwise, for a large request: |
1. Find the smallest available binned chunk that fits, and use it |
if it is better fitting than dv chunk, splitting if necessary. |
2. If better fitting than any binned chunk, use the dv chunk. |
3. If it is big enough, use the top chunk. |
4. If request size >= mmap threshold, try to directly mmap this chunk. |
5. If available, get memory from system and use it |
The ugly goto's here ensure that postaction occurs along all paths. |
*/ |
ensure_initialization(); /* initialize in sys_alloc if not using locks */ |
PREACTION(gm); |
{ |
void* mem; |
size_t nb; |
if (bytes <= MAX_SMALL_REQUEST) |
{ |
bindex_t idx; |
binmap_t smallbits; |
nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); |
idx = small_index(nb); |
smallbits = gm->smallmap >> idx; |
if ((smallbits & 0x3U) != 0) /* Remainderless fit to a smallbin. */ |
{ |
mchunkptr b, p; |
idx += ~smallbits & 1; /* Uses next bin if idx empty */ |
b = smallbin_at(gm, idx); |
p = b->fd; |
assert(chunksize(p) == small_index2size(idx)); |
unlink_first_small_chunk(gm, b, p, idx); |
set_inuse_and_pinuse(gm, p, small_index2size(idx)); |
mem = chunk2mem(p); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
else if (nb > gm->dvsize) |
{ |
if (smallbits != 0) /* Use chunk in next nonempty smallbin */ |
{ |
mchunkptr b, p, r; |
size_t rsize; |
bindex_t i; |
binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); |
binmap_t leastbit = least_bit(leftbits); |
compute_bit2idx(leastbit, i); |
b = smallbin_at(gm, i); |
p = b->fd; |
assert(chunksize(p) == small_index2size(i)); |
unlink_first_small_chunk(gm, b, p, i); |
rsize = small_index2size(i) - nb; |
/* Fit here cannot be remainderless if 4byte sizes */ |
if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) |
set_inuse_and_pinuse(gm, p, small_index2size(i)); |
else |
{ |
set_size_and_pinuse_of_inuse_chunk(gm, p, nb); |
r = chunk_plus_offset(p, nb); |
set_size_and_pinuse_of_free_chunk(r, rsize); |
replace_dv(gm, r, rsize); |
} |
mem = chunk2mem(p); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) |
{ |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
} |
} |
else if (bytes >= MAX_REQUEST) |
nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ |
else |
{ |
nb = pad_request(bytes); |
if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) |
{ |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
} |
if (nb <= gm->dvsize) { |
size_t rsize = gm->dvsize - nb; |
mchunkptr p = gm->dv; |
if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ |
mchunkptr r = gm->dv = chunk_plus_offset(p, nb); |
gm->dvsize = rsize; |
set_size_and_pinuse_of_free_chunk(r, rsize); |
set_size_and_pinuse_of_inuse_chunk(gm, p, nb); |
} |
else { /* exhaust dv */ |
size_t dvs = gm->dvsize; |
gm->dvsize = 0; |
gm->dv = 0; |
set_inuse_and_pinuse(gm, p, dvs); |
} |
mem = chunk2mem(p); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
else if (nb < gm->topsize) { /* Split top */ |
size_t rsize = gm->topsize -= nb; |
mchunkptr p = gm->top; |
mchunkptr r = gm->top = chunk_plus_offset(p, nb); |
r->head = rsize | PINUSE_BIT; |
set_size_and_pinuse_of_inuse_chunk(gm, p, nb); |
mem = chunk2mem(p); |
check_top_chunk(gm, gm->top); |
check_malloced_chunk(gm, mem, nb); |
goto postaction; |
} |
mem = sys_alloc(gm, nb); |
postaction: |
POSTACTION(gm); |
return mem; |
} |
return 0; |
} |
void _free_r(struct _reent *reent_ptr, void* mem) { |
/* |
Consolidate freed chunks with preceeding or succeeding bordering |
free chunks, if they exist, and then place in a bin. Intermixed |
with special cases for top, dv, mmapped chunks, and usage errors. |
*/ |
if (mem != 0) |
{ |
mchunkptr p = mem2chunk(mem); |
#define fm gm |
PREACTION(fm); |
{ |
check_inuse_chunk(fm, p); |
if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) |
{ |
size_t psize = chunksize(p); |
mchunkptr next = chunk_plus_offset(p, psize); |
if (!pinuse(p)) |
{ |
size_t prevsize = p->prev_foot; |
if (is_mmapped(p)) |
{ |
psize += prevsize + MMAP_FOOT_PAD; |
if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) |
fm->footprint -= psize; |
goto postaction; |
} |
else |
{ |
mchunkptr prev = chunk_minus_offset(p, prevsize); |
psize += prevsize; |
p = prev; |
if (RTCHECK(ok_address(fm, prev))) /* consolidate backward */ |
{ |
if (p != fm->dv) |
{ |
unlink_chunk(fm, p, prevsize); |
} |
else if ((next->head & INUSE_BITS) == INUSE_BITS) |
{ |
fm->dvsize = psize; |
set_free_with_pinuse(p, psize, next); |
goto postaction; |
} |
} |
else |
goto erroraction; |
} |
} |
if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) |
{ |
if (!cinuse(next)) /* consolidate forward */ |
{ |
if (next == fm->top) |
{ |
size_t tsize = fm->topsize += psize; |
fm->top = p; |
p->head = tsize | PINUSE_BIT; |
if (p == fm->dv) |
{ |
fm->dv = 0; |
fm->dvsize = 0; |
} |
if (should_trim(fm, tsize)) |
sys_trim(fm, 0); |
goto postaction; |
} |
else if (next == fm->dv) |
{ |
size_t dsize = fm->dvsize += psize; |
fm->dv = p; |
set_size_and_pinuse_of_free_chunk(p, dsize); |
goto postaction; |
} |
else |
{ |
size_t nsize = chunksize(next); |
psize += nsize; |
unlink_chunk(fm, next, nsize); |
set_size_and_pinuse_of_free_chunk(p, psize); |
if (p == fm->dv) |
{ |
fm->dvsize = psize; |
goto postaction; |
} |
} |
} |
else |
set_free_with_pinuse(p, psize, next); |
if (is_small(psize)) |
{ |
insert_small_chunk(fm, p, psize); |
check_free_chunk(fm, p); |
} |
else |
{ |
tchunkptr tp = (tchunkptr)p; |
insert_large_chunk(fm, tp, psize); |
check_free_chunk(fm, p); |
if (--fm->release_checks == 0) |
release_unused_segments(fm); |
} |
goto postaction; |
} |
} |
erroraction: |
USAGE_ERROR_ACTION(fm, p); |
postaction: |
POSTACTION(fm); |
} |
} |
#undef fm |
} |
void* _calloc_r(struct _reent *reent_ptr, size_t n_elements, size_t elem_size) { |
void* mem; |
size_t req = 0; |
if (n_elements != 0) { |
req = n_elements * elem_size; |
if (((n_elements | elem_size) & ~(size_t)0xffff) && |
(req / n_elements != elem_size)) |
req = MAX_SIZE_T; /* force downstream failure on overflow */ |
} |
mem = _malloc_r(reent_ptr, req); |
if (mem != 0 && calloc_must_clear(mem2chunk(mem))) |
memset(mem, 0, req); |
return mem; |
} |
void* _realloc_r (struct _reent *reent_ptr, void* oldmem, size_t bytes){ |
if (oldmem == 0) |
return _malloc_r(reent_ptr, bytes); |
#ifdef REALLOC_ZERO_BYTES_FREES |
if (bytes == 0) { |
_free_r(ptr, oldmem); |
return 0; |
} |
#endif /* REALLOC_ZERO_BYTES_FREES */ |
else { |
#if ! FOOTERS |
mstate m = gm; |
#else /* FOOTERS */ |
mstate m = get_mstate_for(mem2chunk(oldmem)); |
if (!ok_magic(m)) { |
USAGE_ERROR_ACTION(m, oldmem); |
return 0; |
} |
#endif /* FOOTERS */ |
return internal_realloc(reent_ptr, m, oldmem, bytes); |
} |
} |
/* ----------------------------------------------------------------------- |
History: |
V2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee) |
* Use zeros instead of prev foot for is_mmapped |
* Add mspace_track_large_chunks; thanks to Jean Brouwers |
* Fix set_inuse in internal_realloc; thanks to Jean Brouwers |
* Fix insufficient sys_alloc padding when using 16byte alignment |
* Fix bad error check in mspace_footprint |
* Adaptations for ptmalloc; thanks to Wolfram Gloger. |
* Reentrant spin locks; thanks to Earl Chew and others |
* Win32 improvements; thanks to Niall Douglas and Earl Chew |
* Add NO_SEGMENT_TRAVERSAL and MAX_RELEASE_CHECK_RATE options |
* Extension hook in malloc_state |
* Various small adjustments to reduce warnings on some compilers |
* Various configuration extensions/changes for more platforms. Thanks |
to all who contributed these. |
V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee) |
* Add max_footprint functions |
* Ensure all appropriate literals are size_t |
* Fix conditional compilation problem for some #define settings |
* Avoid concatenating segments with the one provided |
in create_mspace_with_base |
* Rename some variables to avoid compiler shadowing warnings |
* Use explicit lock initialization. |
* Better handling of sbrk interference. |
* Simplify and fix segment insertion, trimming and mspace_destroy |
* Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x |
* Thanks especially to Dennis Flanagan for help on these. |
V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee) |
* Fix memalign brace error. |
V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee) |
* Fix improper #endif nesting in C++ |
* Add explicit casts needed for C++ |
V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee) |
* Use trees for large bins |
* Support mspaces |
* Use segments to unify sbrk-based and mmap-based system allocation, |
removing need for emulation on most platforms without sbrk. |
* Default safety checks |
* Optional footer checks. Thanks to William Robertson for the idea. |
* Internal code refactoring |
* Incorporate suggestions and platform-specific changes. |
Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas, |
Aaron Bachmann, Emery Berger, and others. |
* Speed up non-fastbin processing enough to remove fastbins. |
* Remove useless cfree() to avoid conflicts with other apps. |
* Remove internal memcpy, memset. Compilers handle builtins better. |
* Remove some options that no one ever used and rename others. |
V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) |
* Fix malloc_state bitmap array misdeclaration |
V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee) |
* Allow tuning of FIRST_SORTED_BIN_SIZE |
* Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte. |
* Better detection and support for non-contiguousness of MORECORE. |
Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger |
* Bypass most of malloc if no frees. Thanks To Emery Berger. |
* Fix freeing of old top non-contiguous chunk im sysmalloc. |
* Raised default trim and map thresholds to 256K. |
* Fix mmap-related #defines. Thanks to Lubos Lunak. |
* Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield. |
* Branch-free bin calculation |
* Default trim and mmap thresholds now 256K. |
V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) |
* Introduce independent_comalloc and independent_calloc. |
Thanks to Michael Pachos for motivation and help. |
* Make optional .h file available |
* Allow > 2GB requests on 32bit systems. |
* new WIN32 sbrk, mmap, munmap, lock code from <Walter@GeNeSys-e.de>. |
Thanks also to Andreas Mueller <a.mueller at paradatec.de>, |
and Anonymous. |
* Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for |
helping test this.) |
* memalign: check alignment arg |
* realloc: don't try to shift chunks backwards, since this |
leads to more fragmentation in some programs and doesn't |
seem to help in any others. |
* Collect all cases in malloc requiring system memory into sysmalloc |
* Use mmap as backup to sbrk |
* Place all internal state in malloc_state |
* Introduce fastbins (although similar to 2.5.1) |
* Many minor tunings and cosmetic improvements |
* Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK |
* Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS |
Thanks to Tony E. Bennett <tbennett@nvidia.com> and others. |
* Include errno.h to support default failure action. |
V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee) |
* return null for negative arguments |
* Added Several WIN32 cleanups from Martin C. Fong <mcfong at yahoo.com> |
* Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h' |
(e.g. WIN32 platforms) |
* Cleanup header file inclusion for WIN32 platforms |
* Cleanup code to avoid Microsoft Visual C++ compiler complaints |
* Add 'USE_DL_PREFIX' to quickly allow co-existence with existing |
memory allocation routines |
* Set 'malloc_getpagesize' for WIN32 platforms (needs more work) |
* Use 'assert' rather than 'ASSERT' in WIN32 code to conform to |
usage of 'assert' in non-WIN32 code |
* Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to |
avoid infinite loop |
* Always call 'fREe()' rather than 'free()' |
V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee) |
* Fixed ordering problem with boundary-stamping |
V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) |
* Added pvalloc, as recommended by H.J. Liu |
* Added 64bit pointer support mainly from Wolfram Gloger |
* Added anonymously donated WIN32 sbrk emulation |
* Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen |
* malloc_extend_top: fix mask error that caused wastage after |
foreign sbrks |
* Add linux mremap support code from HJ Liu |
V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) |
* Integrated most documentation with the code. |
* Add support for mmap, with help from |
Wolfram Gloger (Gloger@lrz.uni-muenchen.de). |
* Use last_remainder in more cases. |
* Pack bins using idea from colin@nyx10.cs.du.edu |
* Use ordered bins instead of best-fit threshhold |
* Eliminate block-local decls to simplify tracing and debugging. |
* Support another case of realloc via move into top |
* Fix error occuring when initial sbrk_base not word-aligned. |
* Rely on page size for units instead of SBRK_UNIT to |
avoid surprises about sbrk alignment conventions. |
* Add mallinfo, mallopt. Thanks to Raymond Nijssen |
(raymond@es.ele.tue.nl) for the suggestion. |
* Add `pad' argument to malloc_trim and top_pad mallopt parameter. |
* More precautions for cases where other routines call sbrk, |
courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de). |
* Added macros etc., allowing use in linux libc from |
H.J. Lu (hjl@gnu.ai.mit.edu) |
* Inverted this history list |
V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) |
* Re-tuned and fixed to behave more nicely with V2.6.0 changes. |
* Removed all preallocation code since under current scheme |
the work required to undo bad preallocations exceeds |
the work saved in good cases for most test programs. |
* No longer use return list or unconsolidated bins since |
no scheme using them consistently outperforms those that don't |
given above changes. |
* Use best fit for very large chunks to prevent some worst-cases. |
* Added some support for debugging |
V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) |
* Removed footers when chunks are in use. Thanks to |
Paul Wilson (wilson@cs.texas.edu) for the suggestion. |
V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) |
* Added malloc_trim, with help from Wolfram Gloger |
(wmglo@Dent.MED.Uni-Muenchen.DE). |
V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) |
V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) |
* realloc: try to expand in both directions |
* malloc: swap order of clean-bin strategy; |
* realloc: only conditionally expand backwards |
* Try not to scavenge used bins |
* Use bin counts as a guide to preallocation |
* Occasionally bin return list chunks in first scan |
* Add a few optimizations from colin@nyx10.cs.du.edu |
V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) |
* faster bin computation & slightly different binning |
* merged all consolidations to one part of malloc proper |
(eliminating old malloc_find_space & malloc_clean_bin) |
* Scan 2 returns chunks (not just 1) |
* Propagate failure in realloc if malloc returns 0 |
* Add stuff to allow compilation on non-ANSI compilers |
from kpv@research.att.com |
V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) |
* removed potential for odd address access in prev_chunk |
* removed dependency on getpagesize.h |
* misc cosmetics and a bit more internal documentation |
* anticosmetics: mangled names in macros to evade debugger strangeness |
* tested on sparc, hp-700, dec-mips, rs6000 |
with gcc & native cc (hp, dec only) allowing |
Detlefs & Zorn comparison study (in SIGPLAN Notices.) |
Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) |
* Based loosely on libg++-1.2X malloc. (It retains some of the overall |
structure of old version, but most details differ.) |
*/ |
/contrib/sdk/sources/libc/stdlib/mbctype.h |
---|
0,0 → 1,21 |
#ifndef _MBCTYPE_H_ |
#define _MBCTYPE_H_ |
/* escape character used for JIS encoding */ |
#define ESC_CHAR 0x1b |
/* functions used to support SHIFT_JIS, EUC-JP, and JIS multibyte encodings */ |
int _EXFUN(_issjis1, (int c)); |
int _EXFUN(_issjis2, (int c)); |
int _EXFUN(_iseucjp, (int c)); |
int _EXFUN(_isjis, (int c)); |
#define _issjis1(c) (((c) >= 0x81 && (c) <= 0x9f) || ((c) >= 0xe0 && (c) <= 0xef)) |
#define _issjis2(c) (((c) >= 0x40 && (c) <= 0x7e) || ((c) >= 0x80 && (c) <= 0xfc)) |
#define _iseucjp1(c) ((c) == 0x8e || (c) == 0x8f || ((c) >= 0xa1 && (c) <= 0xfe)) |
#define _iseucjp2(c) ((c) >= 0xa1 && (c) <= 0xfe) |
#define _isjis(c) ((c) >= 0x21 && (c) <= 0x7e) |
#endif /* _MBCTYPE_H_ */ |
/contrib/sdk/sources/libc/stdlib/mbrtowc.c |
---|
0,0 → 1,79 |
#include <reent.h> |
#include <newlib.h> |
#include <wchar.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <errno.h> |
#include <string.h> |
#include "local.h" |
size_t |
_DEFUN (_mbrtowc_r, (ptr, pwc, s, n, ps), |
struct _reent *ptr _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
mbstate_t *ps) |
{ |
int retval = 0; |
#ifdef _MB_CAPABLE |
if (ps == NULL) |
{ |
_REENT_CHECK_MISC(ptr); |
ps = &(_REENT_MBRTOWC_STATE(ptr)); |
} |
#endif |
if (s == NULL) |
retval = __mbtowc (ptr, NULL, "", 1, __locale_charset (), ps); |
else |
retval = __mbtowc (ptr, pwc, s, n, __locale_charset (), ps); |
if (retval == -1) |
{ |
ps->__count = 0; |
ptr->_errno = EILSEQ; |
return (size_t)(-1); |
} |
else |
return (size_t)retval; |
} |
#ifndef _REENT_ONLY |
size_t |
_DEFUN (mbrtowc, (pwc, s, n, ps), |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
mbstate_t *ps) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
return _mbrtowc_r (_REENT, pwc, s, n, ps); |
#else |
int retval = 0; |
#ifdef _MB_CAPABLE |
if (ps == NULL) |
{ |
_REENT_CHECK_MISC(_REENT); |
ps = &(_REENT_MBRTOWC_STATE(_REENT)); |
} |
#endif |
if (s == NULL) |
retval = __mbtowc (_REENT, NULL, "", 1, __locale_charset (), ps); |
else |
retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps); |
if (retval == -1) |
{ |
ps->__count = 0; |
_REENT->_errno = EILSEQ; |
return (size_t)(-1); |
} |
else |
return (size_t)retval; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdlib/mbtowc.c |
---|
0,0 → 1,95 |
/* |
FUNCTION |
<<mbtowc>>---minimal multibyte to wide char converter |
INDEX |
mbtowc |
ANSI_SYNOPSIS |
#include <stdlib.h> |
int mbtowc(wchar_t *<[pwc]>, const char *<[s]>, size_t <[n]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
int mbtowc(<[pwc]>, <[s]>, <[n]>) |
wchar_t *<[pwc]>; |
const char *<[s]>; |
size_t <[n]>; |
DESCRIPTION |
When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming |
implementation of <<mbtowc>>. In this case, |
only ``multi-byte character sequences'' recognized are single bytes, |
and they are ``converted'' to themselves. |
Each call to <<mbtowc>> copies one character from <<*<[s]>>> to |
<<*<[pwc]>>>, unless <[s]> is a null pointer. The argument n |
is ignored. |
When _MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform |
the conversion, passing a state variable to allow state dependent |
decoding. The result is based on the locale setting which may |
be restricted to a defined set of locales. |
RETURNS |
This implementation of <<mbtowc>> returns <<0>> if |
<[s]> is <<NULL>> or is the empty string; |
it returns <<1>> if not _MB_CAPABLE or |
the character is a single-byte character; it returns <<-1>> |
if n is <<0>> or the multi-byte character is invalid; |
otherwise it returns the number of bytes in the multibyte character. |
If the return value is -1, no changes are made to the <<pwc>> |
output string. If the input is the empty string, a wchar_t nul |
is placed in the output string and 0 is returned. If the input |
has a length of 0, no changes are made to the <<pwc>> output string. |
PORTABILITY |
<<mbtowc>> is required in the ANSI C standard. However, the precise |
effects vary with the locale. |
<<mbtowc>> requires no supporting OS subroutines. |
*/ |
#ifndef _REENT_ONLY |
#include <newlib.h> |
#include <stdlib.h> |
#include <wchar.h> |
#include "local.h" |
int |
_DEFUN (mbtowc, (pwc, s, n), |
wchar_t *pwc _AND |
const char *s _AND |
size_t n) |
{ |
#ifdef _MB_CAPABLE |
int retval = 0; |
mbstate_t *ps; |
_REENT_CHECK_MISC(_REENT); |
ps = &(_REENT_MBTOWC_STATE(_REENT)); |
retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps); |
if (retval < 0) |
{ |
ps->__count = 0; |
return -1; |
} |
return retval; |
#else /* not _MB_CAPABLE */ |
if (s == NULL) |
return 0; |
if (n == 0) |
return -1; |
if (pwc) |
*pwc = (wchar_t) *s; |
return (*s != '\0'); |
#endif /* not _MB_CAPABLE */ |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdlib/mbtowc_r.c |
---|
0,0 → 1,646 |
#include <newlib.h> |
#include <stdlib.h> |
#include <locale.h> |
#include "mbctype.h" |
#include <wchar.h> |
#include <string.h> |
#include <errno.h> |
#include "local.h" |
int (*__mbtowc) (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *) |
#ifdef __CYGWIN__ |
/* Cygwin starts up in UTF-8 mode. */ |
= __utf8_mbtowc; |
#else |
= __ascii_mbtowc; |
#endif |
int |
_DEFUN (_mbtowc_r, (r, pwc, s, n, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
mbstate_t *state) |
{ |
return __mbtowc (r, pwc, s, n, __locale_charset (), state); |
} |
int |
_DEFUN (__ascii_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; |
if (n == 0) |
return -2; |
#ifdef __CYGWIN__ |
if ((wchar_t)*t >= 0x80) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
#endif |
*pwc = (wchar_t)*t; |
if (*t == '\0') |
return 0; |
return 1; |
} |
#ifdef _MB_CAPABLE |
typedef enum { ESCAPE, DOLLAR, BRACKET, AT, B, J, |
NUL, JIS_CHAR, OTHER, JIS_C_NUM } JIS_CHAR_TYPE; |
typedef enum { ASCII, JIS, A_ESC, A_ESC_DL, JIS_1, J_ESC, J_ESC_BR, |
INV, JIS_S_NUM } JIS_STATE; |
typedef enum { COPY_A, COPY_J1, COPY_J2, MAKE_A, NOOP, EMPTY, ERROR } JIS_ACTION; |
/************************************************************************************** |
* state/action tables for processing JIS encoding |
* Where possible, switches to JIS are grouped with proceding JIS characters and switches |
* to ASCII are grouped with preceding JIS characters. Thus, maximum returned length |
* is 2 (switch to JIS) + 2 (JIS characters) + 2 (switch back to ASCII) = 6. |
*************************************************************************************/ |
static JIS_STATE JIS_state_table[JIS_S_NUM][JIS_C_NUM] = { |
/* ESCAPE DOLLAR BRACKET AT B J NUL JIS_CHAR OTHER */ |
/* ASCII */ { A_ESC, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII }, |
/* JIS */ { J_ESC, JIS_1, JIS_1, JIS_1, JIS_1, JIS_1, INV, JIS_1, INV }, |
/* A_ESC */ { ASCII, A_ESC_DL, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII }, |
/* A_ESC_DL */{ ASCII, ASCII, ASCII, JIS, JIS, ASCII, ASCII, ASCII, ASCII }, |
/* JIS_1 */ { INV, JIS, JIS, JIS, JIS, JIS, INV, JIS, INV }, |
/* J_ESC */ { INV, INV, J_ESC_BR, INV, INV, INV, INV, INV, INV }, |
/* J_ESC_BR */{ INV, INV, INV, INV, ASCII, ASCII, INV, INV, INV }, |
}; |
static JIS_ACTION JIS_action_table[JIS_S_NUM][JIS_C_NUM] = { |
/* ESCAPE DOLLAR BRACKET AT B J NUL JIS_CHAR OTHER */ |
/* ASCII */ { NOOP, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A, EMPTY, COPY_A, COPY_A}, |
/* JIS */ { NOOP, COPY_J1, COPY_J1, COPY_J1, COPY_J1, COPY_J1, ERROR, COPY_J1, ERROR }, |
/* A_ESC */ { COPY_A, NOOP, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A}, |
/* A_ESC_DL */{ COPY_A, COPY_A, COPY_A, NOOP, NOOP, COPY_A, COPY_A, COPY_A, COPY_A}, |
/* JIS_1 */ { ERROR, COPY_J2, COPY_J2, COPY_J2, COPY_J2, COPY_J2, ERROR, COPY_J2, ERROR }, |
/* J_ESC */ { ERROR, ERROR, NOOP, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR }, |
/* J_ESC_BR */{ ERROR, ERROR, ERROR, ERROR, MAKE_A, MAKE_A, ERROR, ERROR, ERROR }, |
}; |
/* we override the mbstate_t __count field for more complex encodings and use it store a state value */ |
#define __state __count |
#ifdef _MB_EXTENDED_CHARSETS_ISO |
int |
_DEFUN (__iso_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; |
if (n == 0) |
return -2; |
if (*t >= 0xa0) |
{ |
int iso_idx = __iso_8859_index (charset + 9); |
if (iso_idx >= 0) |
{ |
*pwc = __iso_8859_conv[iso_idx][*t - 0xa0]; |
if (*pwc == 0) /* Invalid character */ |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
return 1; |
} |
} |
*pwc = (wchar_t) *t; |
if (*t == '\0') |
return 0; |
return 1; |
} |
#endif /* _MB_EXTENDED_CHARSETS_ISO */ |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
int |
_DEFUN (__cp_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; |
if (n == 0) |
return -2; |
if (*t >= 0x80) |
{ |
int cp_idx = __cp_index (charset + 2); |
if (cp_idx >= 0) |
{ |
*pwc = __cp_conv[cp_idx][*t - 0x80]; |
if (*pwc == 0) /* Invalid character */ |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
return 1; |
} |
} |
*pwc = (wchar_t)*t; |
if (*t == '\0') |
return 0; |
return 1; |
} |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
int |
_DEFUN (__utf8_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
int ch; |
int i = 0; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; |
if (n == 0) |
return -2; |
if (state->__count == 0) |
ch = t[i++]; |
else |
ch = state->__value.__wchb[0]; |
if (ch == '\0') |
{ |
*pwc = 0; |
state->__count = 0; |
return 0; /* s points to the null character */ |
} |
if (ch <= 0x7f) |
{ |
/* single-byte sequence */ |
state->__count = 0; |
*pwc = ch; |
return 1; |
} |
if (ch >= 0xc0 && ch <= 0xdf) |
{ |
/* two-byte sequence */ |
state->__value.__wchb[0] = ch; |
if (state->__count == 0) |
state->__count = 1; |
else if (n < (size_t)-1) |
++n; |
if (n < 2) |
return -2; |
ch = t[i++]; |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
if (state->__value.__wchb[0] < 0xc2) |
{ |
/* overlong UTF-8 sequence */ |
r->_errno = EILSEQ; |
return -1; |
} |
state->__count = 0; |
*pwc = (wchar_t)((state->__value.__wchb[0] & 0x1f) << 6) |
| (wchar_t)(ch & 0x3f); |
return i; |
} |
if (ch >= 0xe0 && ch <= 0xef) |
{ |
/* three-byte sequence */ |
wchar_t tmp; |
state->__value.__wchb[0] = ch; |
if (state->__count == 0) |
state->__count = 1; |
else if (n < (size_t)-1) |
++n; |
if (n < 2) |
return -2; |
ch = (state->__count == 1) ? t[i++] : state->__value.__wchb[1]; |
if (state->__value.__wchb[0] == 0xe0 && ch < 0xa0) |
{ |
/* overlong UTF-8 sequence */ |
r->_errno = EILSEQ; |
return -1; |
} |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
state->__value.__wchb[1] = ch; |
if (state->__count == 1) |
state->__count = 2; |
else if (n < (size_t)-1) |
++n; |
if (n < 3) |
return -2; |
ch = t[i++]; |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
state->__count = 0; |
tmp = (wchar_t)((state->__value.__wchb[0] & 0x0f) << 12) |
| (wchar_t)((state->__value.__wchb[1] & 0x3f) << 6) |
| (wchar_t)(ch & 0x3f); |
*pwc = tmp; |
return i; |
} |
if (ch >= 0xf0 && ch <= 0xf4) |
{ |
/* four-byte sequence */ |
wint_t tmp; |
state->__value.__wchb[0] = ch; |
if (state->__count == 0) |
state->__count = 1; |
else if (n < (size_t)-1) |
++n; |
if (n < 2) |
return -2; |
ch = (state->__count == 1) ? t[i++] : state->__value.__wchb[1]; |
if ((state->__value.__wchb[0] == 0xf0 && ch < 0x90) |
|| (state->__value.__wchb[0] == 0xf4 && ch >= 0x90)) |
{ |
/* overlong UTF-8 sequence or result is > 0x10ffff */ |
r->_errno = EILSEQ; |
return -1; |
} |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
state->__value.__wchb[1] = ch; |
if (state->__count == 1) |
state->__count = 2; |
else if (n < (size_t)-1) |
++n; |
if (n < 3) |
return -2; |
ch = (state->__count == 2) ? t[i++] : state->__value.__wchb[2]; |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
state->__value.__wchb[2] = ch; |
if (state->__count == 2) |
state->__count = 3; |
else if (n < (size_t)-1) |
++n; |
if (state->__count == 3 && sizeof(wchar_t) == 2) |
{ |
/* On systems which have wchar_t being UTF-16 values, the value |
doesn't fit into a single wchar_t in this case. So what we |
do here is to store the state with a special value of __count |
and return the first half of a surrogate pair. The first |
three bytes of a UTF-8 sequence are enough to generate the |
first half of a UTF-16 surrogate pair. As return value we |
choose to return the number of bytes actually read up to |
here. |
The second half of the surrogate pair is returned in case we |
recognize the special __count value of four, and the next |
byte is actually a valid value. See below. */ |
tmp = (wint_t)((state->__value.__wchb[0] & 0x07) << 18) |
| (wint_t)((state->__value.__wchb[1] & 0x3f) << 12) |
| (wint_t)((state->__value.__wchb[2] & 0x3f) << 6); |
state->__count = 4; |
*pwc = 0xd800 | ((tmp - 0x10000) >> 10); |
return i; |
} |
if (n < 4) |
return -2; |
ch = t[i++]; |
if (ch < 0x80 || ch > 0xbf) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
tmp = (wint_t)((state->__value.__wchb[0] & 0x07) << 18) |
| (wint_t)((state->__value.__wchb[1] & 0x3f) << 12) |
| (wint_t)((state->__value.__wchb[2] & 0x3f) << 6) |
| (wint_t)(ch & 0x3f); |
if (state->__count == 4 && sizeof(wchar_t) == 2) |
/* Create the second half of the surrogate pair for systems with |
wchar_t == UTF-16 . */ |
*pwc = 0xdc00 | (tmp & 0x3ff); |
else |
*pwc = tmp; |
state->__count = 0; |
return i; |
} |
r->_errno = EILSEQ; |
return -1; |
} |
/* Cygwin defines its own doublebyte charset conversion functions |
because the underlying OS requires wchar_t == UTF-16. */ |
#ifndef __CYGWIN__ |
int |
_DEFUN (__sjis_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
int ch; |
int i = 0; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; /* not state-dependent */ |
if (n == 0) |
return -2; |
ch = t[i++]; |
if (state->__count == 0) |
{ |
if (_issjis1 (ch)) |
{ |
state->__value.__wchb[0] = ch; |
state->__count = 1; |
if (n <= 1) |
return -2; |
ch = t[i++]; |
} |
} |
if (state->__count == 1) |
{ |
if (_issjis2 (ch)) |
{ |
*pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)ch; |
state->__count = 0; |
return i; |
} |
else |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
} |
*pwc = (wchar_t)*t; |
if (*t == '\0') |
return 0; |
return 1; |
} |
int |
_DEFUN (__eucjp_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
int ch; |
int i = 0; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
return 0; |
if (n == 0) |
return -2; |
ch = t[i++]; |
if (state->__count == 0) |
{ |
if (_iseucjp1 (ch)) |
{ |
state->__value.__wchb[0] = ch; |
state->__count = 1; |
if (n <= 1) |
return -2; |
ch = t[i++]; |
} |
} |
if (state->__count == 1) |
{ |
if (_iseucjp2 (ch)) |
{ |
if (state->__value.__wchb[0] == 0x8f) |
{ |
state->__value.__wchb[1] = ch; |
state->__count = 2; |
if (n <= i) |
return -2; |
ch = t[i++]; |
} |
else |
{ |
*pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)ch; |
state->__count = 0; |
return i; |
} |
} |
else |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
} |
if (state->__count == 2) |
{ |
if (_iseucjp2 (ch)) |
{ |
*pwc = (((wchar_t)state->__value.__wchb[1]) << 8) |
+ (wchar_t)(ch & 0x7f); |
state->__count = 0; |
return i; |
} |
else |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
} |
*pwc = (wchar_t)*t; |
if (*t == '\0') |
return 0; |
return 1; |
} |
int |
_DEFUN (__jis_mbtowc, (r, pwc, s, n, charset, state), |
struct _reent *r _AND |
wchar_t *pwc _AND |
const char *s _AND |
size_t n _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wchar_t dummy; |
unsigned char *t = (unsigned char *)s; |
JIS_STATE curr_state; |
JIS_ACTION action; |
JIS_CHAR_TYPE ch; |
unsigned char *ptr; |
unsigned int i; |
int curr_ch; |
if (pwc == NULL) |
pwc = &dummy; |
if (s == NULL) |
{ |
state->__state = ASCII; |
return 1; /* state-dependent */ |
} |
if (n == 0) |
return -2; |
curr_state = state->__state; |
ptr = t; |
for (i = 0; i < n; ++i) |
{ |
curr_ch = t[i]; |
switch (curr_ch) |
{ |
case ESC_CHAR: |
ch = ESCAPE; |
break; |
case '$': |
ch = DOLLAR; |
break; |
case '@': |
ch = AT; |
break; |
case '(': |
ch = BRACKET; |
break; |
case 'B': |
ch = B; |
break; |
case 'J': |
ch = J; |
break; |
case '\0': |
ch = NUL; |
break; |
default: |
if (_isjis (curr_ch)) |
ch = JIS_CHAR; |
else |
ch = OTHER; |
} |
action = JIS_action_table[curr_state][ch]; |
curr_state = JIS_state_table[curr_state][ch]; |
switch (action) |
{ |
case NOOP: |
break; |
case EMPTY: |
state->__state = ASCII; |
*pwc = (wchar_t)0; |
return 0; |
case COPY_A: |
state->__state = ASCII; |
*pwc = (wchar_t)*ptr; |
return (i + 1); |
case COPY_J1: |
state->__value.__wchb[0] = t[i]; |
break; |
case COPY_J2: |
state->__state = JIS; |
*pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)(t[i]); |
return (i + 1); |
case MAKE_A: |
ptr = (unsigned char *)(t + i + 1); |
break; |
case ERROR: |
default: |
r->_errno = EILSEQ; |
return -1; |
} |
} |
state->__state = curr_state; |
return -2; /* n < bytes needed */ |
} |
#endif /* !__CYGWIN__*/ |
#endif /* _MB_CAPABLE */ |
/contrib/sdk/sources/libc/stdlib/mlock.c |
---|
0,0 → 1,56 |
/* |
FUNCTION |
<<__malloc_lock>>, <<__malloc_unlock>>---lock malloc pool |
INDEX |
__malloc_lock |
INDEX |
__malloc_unlock |
ANSI_SYNOPSIS |
#include <malloc.h> |
void __malloc_lock (struct _reent *<[reent]>); |
void __malloc_unlock (struct _reent *<[reent]>); |
TRAD_SYNOPSIS |
void __malloc_lock(<[reent]>) |
struct _reent *<[reent]>; |
void __malloc_unlock(<[reent]>) |
struct _reent *<[reent]>; |
DESCRIPTION |
The <<malloc>> family of routines call these functions when they need to lock |
the memory pool. The version of these routines supplied in the library use |
the lock API defined in sys/lock.h. If multiple threads of execution can |
call <<malloc>>, or if <<malloc>> can be called reentrantly, then you need to |
define your own versions of these functions in order to safely lock the |
memory pool during a call. If you do not, the memory pool may become |
corrupted. |
A call to <<malloc>> may call <<__malloc_lock>> recursively; that is, |
the sequence of calls may go <<__malloc_lock>>, <<__malloc_lock>>, |
<<__malloc_unlock>>, <<__malloc_unlock>>. Any implementation of these |
routines must be careful to avoid causing a thread to wait for a lock |
that it already holds. |
*/ |
#include <malloc.h> |
#include <sys/lock.h> |
__LOCK_INIT_RECURSIVE(static, __malloc_lock_object); |
void |
__malloc_lock (ptr) |
struct _reent *ptr; |
{ |
__lock_acquire_recursive (__malloc_lock_object); |
} |
void |
__malloc_unlock (ptr) |
struct _reent *ptr; |
{ |
__lock_release_recursive (__malloc_lock_object); |
} |
/contrib/sdk/sources/libc/stdlib/mprec.c |
---|
0,0 → 1,1049 |
/**************************************************************** |
* |
* The author of this software is David M. Gay. |
* |
* Copyright (c) 1991 by AT&T. |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software and in all copies of the supporting |
* documentation for such software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY |
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY |
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
***************************************************************/ |
/* Please send bug reports to |
David M. Gay |
AT&T Bell Laboratories, Room 2C-463 |
600 Mountain Avenue |
Murray Hill, NJ 07974-2070 |
U.S.A. |
dmg@research.att.com or research!dmg |
*/ |
/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. |
* |
* This strtod returns a nearest machine number to the input decimal |
* string (or sets errno to ERANGE). With IEEE arithmetic, ties are |
* broken by the IEEE round-even rule. Otherwise ties are broken by |
* biased rounding (add half and chop). |
* |
* Inspired loosely by William D. Clinger's paper "How to Read Floating |
* Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. |
* |
* Modifications: |
* |
* 1. We only require IEEE, IBM, or VAX double-precision |
* arithmetic (not IEEE double-extended). |
* 2. We get by with floating-point arithmetic in a case that |
* Clinger missed -- when we're computing d * 10^n |
* for a small integer d and the integer n is not too |
* much larger than 22 (the maximum integer k for which |
* we can represent 10^k exactly), we may be able to |
* compute (d*10^k) * 10^(e-k) with just one roundoff. |
* 3. Rather than a bit-at-a-time adjustment of the binary |
* result in the hard case, we use floating-point |
* arithmetic to determine the adjustment to within |
* one bit; only in really hard cases do we need to |
* compute a second residual. |
* 4. Because of 3., we don't need a large table of powers of 10 |
* for ten-to-e (just some small tables, e.g. of 10^k |
* for 0 <= k <= 22). |
*/ |
/* |
* #define IEEE_8087 for IEEE-arithmetic machines where the least |
* significant byte has the lowest address. |
* #define IEEE_MC68k for IEEE-arithmetic machines where the most |
* significant byte has the lowest address. |
* #define Sudden_Underflow for IEEE-format machines without gradual |
* underflow (i.e., that flush to zero on underflow). |
* #define IBM for IBM mainframe-style floating-point arithmetic. |
* #define VAX for VAX-style floating-point arithmetic. |
* #define Unsigned_Shifts if >> does treats its left operand as unsigned. |
* #define No_leftright to omit left-right logic in fast floating-point |
* computation of dtoa. |
* #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. |
* #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines |
* that use extended-precision instructions to compute rounded |
* products and quotients) with IBM. |
* #define ROUND_BIASED for IEEE-format with biased rounding. |
* #define Inaccurate_Divide for IEEE-format with correctly rounded |
* products but inaccurate quotients, e.g., for Intel i860. |
* #define Just_16 to store 16 bits per 32-bit long when doing high-precision |
* integer arithmetic. Whether this speeds things up or slows things |
* down depends on the machine and the number being converted. |
*/ |
#include <_ansi.h> |
#include <stdlib.h> |
#include <string.h> |
#include <reent.h> |
#include "mprec.h" |
/* This is defined in sys/reent.h as (sizeof (size_t) << 3) now, as in NetBSD. |
The old value of 15 was wrong and made newlib vulnerable against buffer |
overrun attacks (CVE-2009-0689), same as other implementations of gdtoa |
based on BSD code. |
#define _Kmax 15 |
*/ |
_Bigint * |
_DEFUN (Balloc, (ptr, k), struct _reent *ptr _AND int k) |
{ |
int x; |
_Bigint *rv ; |
_REENT_CHECK_MP(ptr); |
if (_REENT_MP_FREELIST(ptr) == NULL) |
{ |
/* Allocate a list of pointers to the mprec objects */ |
_REENT_MP_FREELIST(ptr) = (struct _Bigint **) _calloc_r (ptr, |
sizeof (struct _Bigint *), |
_Kmax + 1); |
if (_REENT_MP_FREELIST(ptr) == NULL) |
{ |
return NULL; |
} |
} |
if ((rv = _REENT_MP_FREELIST(ptr)[k]) != 0) |
{ |
_REENT_MP_FREELIST(ptr)[k] = rv->_next; |
} |
else |
{ |
x = 1 << k; |
/* Allocate an mprec Bigint and stick in in the freelist */ |
rv = (_Bigint *) _calloc_r (ptr, |
1, |
sizeof (_Bigint) + |
(x-1) * sizeof(rv->_x)); |
if (rv == NULL) return NULL; |
rv->_k = k; |
rv->_maxwds = x; |
} |
rv->_sign = rv->_wds = 0; |
return rv; |
} |
void |
_DEFUN (Bfree, (ptr, v), struct _reent *ptr _AND _Bigint * v) |
{ |
_REENT_CHECK_MP(ptr); |
if (v) |
{ |
v->_next = _REENT_MP_FREELIST(ptr)[v->_k]; |
_REENT_MP_FREELIST(ptr)[v->_k] = v; |
} |
} |
_Bigint * |
_DEFUN (multadd, (ptr, b, m, a), |
struct _reent *ptr _AND |
_Bigint * b _AND |
int m _AND |
int a) |
{ |
int i, wds; |
__ULong *x, y; |
#ifdef Pack_32 |
__ULong xi, z; |
#endif |
_Bigint *b1; |
wds = b->_wds; |
x = b->_x; |
i = 0; |
do |
{ |
#ifdef Pack_32 |
xi = *x; |
y = (xi & 0xffff) * m + a; |
z = (xi >> 16) * m + (y >> 16); |
a = (int) (z >> 16); |
*x++ = (z << 16) + (y & 0xffff); |
#else |
y = *x * m + a; |
a = (int) (y >> 16); |
*x++ = y & 0xffff; |
#endif |
} |
while (++i < wds); |
if (a) |
{ |
if (wds >= b->_maxwds) |
{ |
b1 = Balloc (ptr, b->_k + 1); |
Bcopy (b1, b); |
Bfree (ptr, b); |
b = b1; |
} |
b->_x[wds++] = a; |
b->_wds = wds; |
} |
return b; |
} |
_Bigint * |
_DEFUN (s2b, (ptr, s, nd0, nd, y9), |
struct _reent * ptr _AND |
_CONST char *s _AND |
int nd0 _AND |
int nd _AND |
__ULong y9) |
{ |
_Bigint *b; |
int i, k; |
__Long x, y; |
x = (nd + 8) / 9; |
for (k = 0, y = 1; x > y; y <<= 1, k++); |
#ifdef Pack_32 |
b = Balloc (ptr, k); |
b->_x[0] = y9; |
b->_wds = 1; |
#else |
b = Balloc (ptr, k + 1); |
b->_x[0] = y9 & 0xffff; |
b->_wds = (b->_x[1] = y9 >> 16) ? 2 : 1; |
#endif |
i = 9; |
if (9 < nd0) |
{ |
s += 9; |
do |
b = multadd (ptr, b, 10, *s++ - '0'); |
while (++i < nd0); |
s++; |
} |
else |
s += 10; |
for (; i < nd; i++) |
b = multadd (ptr, b, 10, *s++ - '0'); |
return b; |
} |
int |
_DEFUN (hi0bits, |
(x), register __ULong x) |
{ |
register int k = 0; |
if (!(x & 0xffff0000)) |
{ |
k = 16; |
x <<= 16; |
} |
if (!(x & 0xff000000)) |
{ |
k += 8; |
x <<= 8; |
} |
if (!(x & 0xf0000000)) |
{ |
k += 4; |
x <<= 4; |
} |
if (!(x & 0xc0000000)) |
{ |
k += 2; |
x <<= 2; |
} |
if (!(x & 0x80000000)) |
{ |
k++; |
if (!(x & 0x40000000)) |
return 32; |
} |
return k; |
} |
int |
_DEFUN (lo0bits, (y), __ULong *y) |
{ |
register int k; |
register __ULong x = *y; |
if (x & 7) |
{ |
if (x & 1) |
return 0; |
if (x & 2) |
{ |
*y = x >> 1; |
return 1; |
} |
*y = x >> 2; |
return 2; |
} |
k = 0; |
if (!(x & 0xffff)) |
{ |
k = 16; |
x >>= 16; |
} |
if (!(x & 0xff)) |
{ |
k += 8; |
x >>= 8; |
} |
if (!(x & 0xf)) |
{ |
k += 4; |
x >>= 4; |
} |
if (!(x & 0x3)) |
{ |
k += 2; |
x >>= 2; |
} |
if (!(x & 1)) |
{ |
k++; |
x >>= 1; |
if (!x & 1) |
return 32; |
} |
*y = x; |
return k; |
} |
_Bigint * |
_DEFUN (i2b, (ptr, i), struct _reent * ptr _AND int i) |
{ |
_Bigint *b; |
b = Balloc (ptr, 1); |
b->_x[0] = i; |
b->_wds = 1; |
return b; |
} |
_Bigint * |
_DEFUN (mult, (ptr, a, b), struct _reent * ptr _AND _Bigint * a _AND _Bigint * b) |
{ |
_Bigint *c; |
int k, wa, wb, wc; |
__ULong carry, y, z; |
__ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; |
#ifdef Pack_32 |
__ULong z2; |
#endif |
if (a->_wds < b->_wds) |
{ |
c = a; |
a = b; |
b = c; |
} |
k = a->_k; |
wa = a->_wds; |
wb = b->_wds; |
wc = wa + wb; |
if (wc > a->_maxwds) |
k++; |
c = Balloc (ptr, k); |
for (x = c->_x, xa = x + wc; x < xa; x++) |
*x = 0; |
xa = a->_x; |
xae = xa + wa; |
xb = b->_x; |
xbe = xb + wb; |
xc0 = c->_x; |
#ifdef Pack_32 |
for (; xb < xbe; xb++, xc0++) |
{ |
if ((y = *xb & 0xffff) != 0) |
{ |
x = xa; |
xc = xc0; |
carry = 0; |
do |
{ |
z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; |
carry = z >> 16; |
z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; |
carry = z2 >> 16; |
Storeinc (xc, z2, z); |
} |
while (x < xae); |
*xc = carry; |
} |
if ((y = *xb >> 16) != 0) |
{ |
x = xa; |
xc = xc0; |
carry = 0; |
z2 = *xc; |
do |
{ |
z = (*x & 0xffff) * y + (*xc >> 16) + carry; |
carry = z >> 16; |
Storeinc (xc, z, z2); |
z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; |
carry = z2 >> 16; |
} |
while (x < xae); |
*xc = z2; |
} |
} |
#else |
for (; xb < xbe; xc0++) |
{ |
if (y = *xb++) |
{ |
x = xa; |
xc = xc0; |
carry = 0; |
do |
{ |
z = *x++ * y + *xc + carry; |
carry = z >> 16; |
*xc++ = z & 0xffff; |
} |
while (x < xae); |
*xc = carry; |
} |
} |
#endif |
for (xc0 = c->_x, xc = xc0 + wc; wc > 0 && !*--xc; --wc); |
c->_wds = wc; |
return c; |
} |
_Bigint * |
_DEFUN (pow5mult, |
(ptr, b, k), struct _reent * ptr _AND _Bigint * b _AND int k) |
{ |
_Bigint *b1, *p5, *p51; |
int i; |
static _CONST int p05[3] = {5, 25, 125}; |
if ((i = k & 3) != 0) |
b = multadd (ptr, b, p05[i - 1], 0); |
if (!(k >>= 2)) |
return b; |
_REENT_CHECK_MP(ptr); |
if (!(p5 = _REENT_MP_P5S(ptr))) |
{ |
/* first time */ |
p5 = _REENT_MP_P5S(ptr) = i2b (ptr, 625); |
p5->_next = 0; |
} |
for (;;) |
{ |
if (k & 1) |
{ |
b1 = mult (ptr, b, p5); |
Bfree (ptr, b); |
b = b1; |
} |
if (!(k >>= 1)) |
break; |
if (!(p51 = p5->_next)) |
{ |
p51 = p5->_next = mult (ptr, p5, p5); |
p51->_next = 0; |
} |
p5 = p51; |
} |
return b; |
} |
_Bigint * |
_DEFUN (lshift, (ptr, b, k), struct _reent * ptr _AND _Bigint * b _AND int k) |
{ |
int i, k1, n, n1; |
_Bigint *b1; |
__ULong *x, *x1, *xe, z; |
#ifdef Pack_32 |
n = k >> 5; |
#else |
n = k >> 4; |
#endif |
k1 = b->_k; |
n1 = n + b->_wds + 1; |
for (i = b->_maxwds; n1 > i; i <<= 1) |
k1++; |
b1 = Balloc (ptr, k1); |
x1 = b1->_x; |
for (i = 0; i < n; i++) |
*x1++ = 0; |
x = b->_x; |
xe = x + b->_wds; |
#ifdef Pack_32 |
if (k &= 0x1f) |
{ |
k1 = 32 - k; |
z = 0; |
do |
{ |
*x1++ = *x << k | z; |
z = *x++ >> k1; |
} |
while (x < xe); |
if ((*x1 = z) != 0) |
++n1; |
} |
#else |
if (k &= 0xf) |
{ |
k1 = 16 - k; |
z = 0; |
do |
{ |
*x1++ = *x << k & 0xffff | z; |
z = *x++ >> k1; |
} |
while (x < xe); |
if (*x1 = z) |
++n1; |
} |
#endif |
else |
do |
*x1++ = *x++; |
while (x < xe); |
b1->_wds = n1 - 1; |
Bfree (ptr, b); |
return b1; |
} |
int |
_DEFUN (cmp, (a, b), _Bigint * a _AND _Bigint * b) |
{ |
__ULong *xa, *xa0, *xb, *xb0; |
int i, j; |
i = a->_wds; |
j = b->_wds; |
#ifdef DEBUG |
if (i > 1 && !a->_x[i - 1]) |
Bug ("cmp called with a->_x[a->_wds-1] == 0"); |
if (j > 1 && !b->_x[j - 1]) |
Bug ("cmp called with b->_x[b->_wds-1] == 0"); |
#endif |
if (i -= j) |
return i; |
xa0 = a->_x; |
xa = xa0 + j; |
xb0 = b->_x; |
xb = xb0 + j; |
for (;;) |
{ |
if (*--xa != *--xb) |
return *xa < *xb ? -1 : 1; |
if (xa <= xa0) |
break; |
} |
return 0; |
} |
_Bigint * |
_DEFUN (diff, (ptr, a, b), struct _reent * ptr _AND |
_Bigint * a _AND _Bigint * b) |
{ |
_Bigint *c; |
int i, wa, wb; |
__Long borrow, y; /* We need signed shifts here. */ |
__ULong *xa, *xae, *xb, *xbe, *xc; |
#ifdef Pack_32 |
__Long z; |
#endif |
i = cmp (a, b); |
if (!i) |
{ |
c = Balloc (ptr, 0); |
c->_wds = 1; |
c->_x[0] = 0; |
return c; |
} |
if (i < 0) |
{ |
c = a; |
a = b; |
b = c; |
i = 1; |
} |
else |
i = 0; |
c = Balloc (ptr, a->_k); |
c->_sign = i; |
wa = a->_wds; |
xa = a->_x; |
xae = xa + wa; |
wb = b->_wds; |
xb = b->_x; |
xbe = xb + wb; |
xc = c->_x; |
borrow = 0; |
#ifdef Pack_32 |
do |
{ |
y = (*xa & 0xffff) - (*xb & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
z = (*xa++ >> 16) - (*xb++ >> 16) + borrow; |
borrow = z >> 16; |
Sign_Extend (borrow, z); |
Storeinc (xc, z, y); |
} |
while (xb < xbe); |
while (xa < xae) |
{ |
y = (*xa & 0xffff) + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
z = (*xa++ >> 16) + borrow; |
borrow = z >> 16; |
Sign_Extend (borrow, z); |
Storeinc (xc, z, y); |
} |
#else |
do |
{ |
y = *xa++ - *xb++ + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
*xc++ = y & 0xffff; |
} |
while (xb < xbe); |
while (xa < xae) |
{ |
y = *xa++ + borrow; |
borrow = y >> 16; |
Sign_Extend (borrow, y); |
*xc++ = y & 0xffff; |
} |
#endif |
while (!*--xc) |
wa--; |
c->_wds = wa; |
return c; |
} |
double |
_DEFUN (ulp, (_x), double _x) |
{ |
union double_union x, a; |
register __Long L; |
x.d = _x; |
L = (word0 (x) & Exp_mask) - (P - 1) * Exp_msk1; |
#ifndef Sudden_Underflow |
if (L > 0) |
{ |
#endif |
#ifdef IBM |
L |= Exp_msk1 >> 4; |
#endif |
word0 (a) = L; |
#ifndef _DOUBLE_IS_32BITS |
word1 (a) = 0; |
#endif |
#ifndef Sudden_Underflow |
} |
else |
{ |
L = -L >> Exp_shift; |
if (L < Exp_shift) |
{ |
word0 (a) = 0x80000 >> L; |
#ifndef _DOUBLE_IS_32BITS |
word1 (a) = 0; |
#endif |
} |
else |
{ |
word0 (a) = 0; |
L -= Exp_shift; |
#ifndef _DOUBLE_IS_32BITS |
word1 (a) = L >= 31 ? 1 : 1 << (31 - L); |
#endif |
} |
} |
#endif |
return a.d; |
} |
double |
_DEFUN (b2d, (a, e), |
_Bigint * a _AND int *e) |
{ |
__ULong *xa, *xa0, w, y, z; |
int k; |
union double_union d; |
#ifdef VAX |
__ULong d0, d1; |
#else |
#define d0 word0(d) |
#define d1 word1(d) |
#endif |
xa0 = a->_x; |
xa = xa0 + a->_wds; |
y = *--xa; |
#ifdef DEBUG |
if (!y) |
Bug ("zero y in b2d"); |
#endif |
k = hi0bits (y); |
*e = 32 - k; |
#ifdef Pack_32 |
if (k < Ebits) |
{ |
d0 = Exp_1 | y >> (Ebits - k); |
w = xa > xa0 ? *--xa : 0; |
#ifndef _DOUBLE_IS_32BITS |
d1 = y << ((32 - Ebits) + k) | w >> (Ebits - k); |
#endif |
goto ret_d; |
} |
z = xa > xa0 ? *--xa : 0; |
if (k -= Ebits) |
{ |
d0 = Exp_1 | y << k | z >> (32 - k); |
y = xa > xa0 ? *--xa : 0; |
#ifndef _DOUBLE_IS_32BITS |
d1 = z << k | y >> (32 - k); |
#endif |
} |
else |
{ |
d0 = Exp_1 | y; |
#ifndef _DOUBLE_IS_32BITS |
d1 = z; |
#endif |
} |
#else |
if (k < Ebits + 16) |
{ |
z = xa > xa0 ? *--xa : 0; |
d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k; |
w = xa > xa0 ? *--xa : 0; |
y = xa > xa0 ? *--xa : 0; |
d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k; |
goto ret_d; |
} |
z = xa > xa0 ? *--xa : 0; |
w = xa > xa0 ? *--xa : 0; |
k -= Ebits + 16; |
d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k; |
y = xa > xa0 ? *--xa : 0; |
d1 = w << k + 16 | y << k; |
#endif |
ret_d: |
#ifdef VAX |
word0 (d) = d0 >> 16 | d0 << 16; |
word1 (d) = d1 >> 16 | d1 << 16; |
#else |
#undef d0 |
#undef d1 |
#endif |
return d.d; |
} |
_Bigint * |
_DEFUN (d2b, |
(ptr, _d, e, bits), |
struct _reent * ptr _AND |
double _d _AND |
int *e _AND |
int *bits) |
{ |
union double_union d; |
_Bigint *b; |
int de, i, k; |
__ULong *x, y, z; |
#ifdef VAX |
__ULong d0, d1; |
#endif |
d.d = _d; |
#ifdef VAX |
d0 = word0 (d) >> 16 | word0 (d) << 16; |
d1 = word1 (d) >> 16 | word1 (d) << 16; |
#else |
#define d0 word0(d) |
#define d1 word1(d) |
d.d = _d; |
#endif |
#ifdef Pack_32 |
b = Balloc (ptr, 1); |
#else |
b = Balloc (ptr, 2); |
#endif |
x = b->_x; |
z = d0 & Frac_mask; |
d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ |
#ifdef Sudden_Underflow |
de = (int) (d0 >> Exp_shift); |
#ifndef IBM |
z |= Exp_msk11; |
#endif |
#else |
if ((de = (int) (d0 >> Exp_shift)) != 0) |
z |= Exp_msk1; |
#endif |
#ifdef Pack_32 |
#ifndef _DOUBLE_IS_32BITS |
if (d1) |
{ |
y = d1; |
k = lo0bits (&y); |
if (k) |
{ |
x[0] = y | z << (32 - k); |
z >>= k; |
} |
else |
x[0] = y; |
i = b->_wds = (x[1] = z) ? 2 : 1; |
} |
else |
#endif |
{ |
#ifdef DEBUG |
if (!z) |
Bug ("Zero passed to d2b"); |
#endif |
k = lo0bits (&z); |
x[0] = z; |
i = b->_wds = 1; |
#ifndef _DOUBLE_IS_32BITS |
k += 32; |
#endif |
} |
#else |
if (d1) |
{ |
y = d1; |
k = lo0bits (&y); |
if (k) |
if (k >= 16) |
{ |
x[0] = y | z << 32 - k & 0xffff; |
x[1] = z >> k - 16 & 0xffff; |
x[2] = z >> k; |
i = 2; |
} |
else |
{ |
x[0] = y & 0xffff; |
x[1] = y >> 16 | z << 16 - k & 0xffff; |
x[2] = z >> k & 0xffff; |
x[3] = z >> k + 16; |
i = 3; |
} |
else |
{ |
x[0] = y & 0xffff; |
x[1] = y >> 16; |
x[2] = z & 0xffff; |
x[3] = z >> 16; |
i = 3; |
} |
} |
else |
{ |
#ifdef DEBUG |
if (!z) |
Bug ("Zero passed to d2b"); |
#endif |
k = lo0bits (&z); |
if (k >= 16) |
{ |
x[0] = z; |
i = 0; |
} |
else |
{ |
x[0] = z & 0xffff; |
x[1] = z >> 16; |
i = 1; |
} |
k += 32; |
} |
while (!x[i]) |
--i; |
b->_wds = i + 1; |
#endif |
#ifndef Sudden_Underflow |
if (de) |
{ |
#endif |
#ifdef IBM |
*e = (de - Bias - (P - 1) << 2) + k; |
*bits = 4 * P + 8 - k - hi0bits (word0 (d) & Frac_mask); |
#else |
*e = de - Bias - (P - 1) + k; |
*bits = P - k; |
#endif |
#ifndef Sudden_Underflow |
} |
else |
{ |
*e = de - Bias - (P - 1) + 1 + k; |
#ifdef Pack_32 |
*bits = 32 * i - hi0bits (x[i - 1]); |
#else |
*bits = (i + 2) * 16 - hi0bits (x[i]); |
#endif |
} |
#endif |
return b; |
} |
#undef d0 |
#undef d1 |
double |
_DEFUN (ratio, (a, b), _Bigint * a _AND _Bigint * b) |
{ |
union double_union da, db; |
int k, ka, kb; |
da.d = b2d (a, &ka); |
db.d = b2d (b, &kb); |
#ifdef Pack_32 |
k = ka - kb + 32 * (a->_wds - b->_wds); |
#else |
k = ka - kb + 16 * (a->_wds - b->_wds); |
#endif |
#ifdef IBM |
if (k > 0) |
{ |
word0 (da) += (k >> 2) * Exp_msk1; |
if (k &= 3) |
da.d *= 1 << k; |
} |
else |
{ |
k = -k; |
word0 (db) += (k >> 2) * Exp_msk1; |
if (k &= 3) |
db.d *= 1 << k; |
} |
#else |
if (k > 0) |
word0 (da) += k * Exp_msk1; |
else |
{ |
k = -k; |
word0 (db) += k * Exp_msk1; |
} |
#endif |
return da.d / db.d; |
} |
_CONST double |
tens[] = |
{ |
1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, |
1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, |
1e20, 1e21, 1e22, 1e23, 1e24 |
}; |
#if !defined(_DOUBLE_IS_32BITS) && !defined(__v800) |
_CONST double bigtens[] = |
{1e16, 1e32, 1e64, 1e128, 1e256}; |
_CONST double tinytens[] = |
{1e-16, 1e-32, 1e-64, 1e-128, 1e-256}; |
#else |
_CONST double bigtens[] = |
{1e16, 1e32}; |
_CONST double tinytens[] = |
{1e-16, 1e-32}; |
#endif |
double |
_DEFUN (_mprec_log10, (dig), |
int dig) |
{ |
double v = 1.0; |
if (dig < 24) |
return tens[dig]; |
while (dig > 0) |
{ |
v *= 10; |
dig--; |
} |
return v; |
} |
void |
_DEFUN (copybits, (c, n, b), |
__ULong *c _AND |
int n _AND |
_Bigint *b) |
{ |
__ULong *ce, *x, *xe; |
#ifdef Pack_16 |
int nw, nw1; |
#endif |
ce = c + ((n-1) >> kshift) + 1; |
x = b->_x; |
#ifdef Pack_32 |
xe = x + b->_wds; |
while(x < xe) |
*c++ = *x++; |
#else |
nw = b->_wds; |
nw1 = nw & 1; |
for(xe = x + (nw - nw1); x < xe; x += 2) |
Storeinc(c, x[1], x[0]); |
if (nw1) |
*c++ = *x; |
#endif |
while(c < ce) |
*c++ = 0; |
} |
__ULong |
_DEFUN (any_on, (b, k), |
_Bigint *b _AND |
int k) |
{ |
int n, nwds; |
__ULong *x, *x0, x1, x2; |
x = b->_x; |
nwds = b->_wds; |
n = k >> kshift; |
if (n > nwds) |
n = nwds; |
else if (n < nwds && (k &= kmask)) { |
x1 = x2 = x[n]; |
x1 >>= k; |
x1 <<= k; |
if (x1 != x2) |
return 1; |
} |
x0 = x; |
x += n; |
while(x > x0) |
if (*--x) |
return 1; |
return 0; |
} |
/contrib/sdk/sources/libc/stdlib/mprec.h |
---|
0,0 → 1,415 |
/**************************************************************** |
* |
* The author of this software is David M. Gay. |
* |
* Copyright (c) 1991 by AT&T. |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software and in all copies of the supporting |
* documentation for such software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY |
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY |
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
***************************************************************/ |
/* Please send bug reports to |
David M. Gay |
AT&T Bell Laboratories, Room 2C-463 |
600 Mountain Avenue |
Murray Hill, NJ 07974-2070 |
U.S.A. |
dmg@research.att.com or research!dmg |
*/ |
#include <ieeefp.h> |
#include <math.h> |
#include <float.h> |
#include <errno.h> |
#include <sys/config.h> |
#include <sys/types.h> |
#ifdef __IEEE_LITTLE_ENDIAN |
#define IEEE_8087 |
#endif |
#ifdef __IEEE_BIG_ENDIAN |
#define IEEE_MC68k |
#endif |
#ifdef __Z8000__ |
#define Just_16 |
#endif |
#ifdef DEBUG |
#include "stdio.h" |
#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} |
#endif |
#ifdef Unsigned_Shifts |
#define Sign_Extend(a,b) if (b < 0) a |= (__uint32_t)0xffff0000; |
#else |
#define Sign_Extend(a,b) /*no-op*/ |
#endif |
#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 |
Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. |
#endif |
/* If we are going to examine or modify specific bits in a double using |
the word0 and/or word1 macros, then we must wrap the double inside |
a union. This is necessary to avoid undefined behavior according to |
the ANSI C spec. */ |
union double_union |
{ |
double d; |
__uint32_t i[2]; |
}; |
#ifdef IEEE_8087 |
#define word0(x) (x.i[1]) |
#define word1(x) (x.i[0]) |
#else |
#define word0(x) (x.i[0]) |
#define word1(x) (x.i[1]) |
#endif |
/* The following is taken from gdtoaimp.h for use with new strtod, but |
adjusted to avoid invalid type-punning. */ |
typedef __int32_t Long; |
/* Unfortunately, because __ULong might be a different type than |
__uint32_t, we can't re-use union double_union as-is without |
further edits in strtod.c. */ |
typedef union { double d; __ULong i[2]; } U; |
#define dword0(x) word0(x) |
#define dword1(x) word1(x) |
#define dval(x) (x.d) |
#undef SI |
#ifdef Sudden_Underflow |
#define SI 1 |
#else |
#define SI 0 |
#endif |
#define Storeinc(a,b,c) (*(a)++ = (b) << 16 | (c) & 0xffff) |
/* #define P DBL_MANT_DIG */ |
/* Ten_pmax = floor(P*log(2)/log(5)) */ |
/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ |
/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ |
/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ |
#if defined(IEEE_8087) + defined(IEEE_MC68k) |
#if defined (_DOUBLE_IS_32BITS) |
#define Exp_shift 23 |
#define Exp_shift1 23 |
#define Exp_msk1 ((__uint32_t)0x00800000L) |
#define Exp_msk11 ((__uint32_t)0x00800000L) |
#define Exp_mask ((__uint32_t)0x7f800000L) |
#define P 24 |
#define Bias 127 |
#define NO_HEX_FP /* not supported in this case */ |
#define IEEE_Arith |
#define Emin (-126) |
#define Exp_1 ((__uint32_t)0x3f800000L) |
#define Exp_11 ((__uint32_t)0x3f800000L) |
#define Ebits 8 |
#define Frac_mask ((__uint32_t)0x007fffffL) |
#define Frac_mask1 ((__uint32_t)0x007fffffL) |
#define Ten_pmax 10 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Ten_pmax 10 |
#define Bletch 2 |
#define Bndry_mask ((__uint32_t)0x007fffffL) |
#define Bndry_mask1 ((__uint32_t)0x007fffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 1 |
#define Tiny0 0 |
#define Tiny1 1 |
#define Quick_max 5 |
#define Int_max 6 |
#define Infinite(x) (word0(x) == ((__uint32_t)0x7f800000L)) |
#undef word0 |
#undef word1 |
#undef dword0 |
#undef dword1 |
#define word0(x) (x.i[0]) |
#define word1(x) 0 |
#define dword0(x) word0(x) |
#define dword1(x) 0 |
#else |
#define Exp_shift 20 |
#define Exp_shift1 20 |
#define Exp_msk1 ((__uint32_t)0x100000L) |
#define Exp_msk11 ((__uint32_t)0x100000L) |
#define Exp_mask ((__uint32_t)0x7ff00000L) |
#define P 53 |
#define Bias 1023 |
#define IEEE_Arith |
#define Emin (-1022) |
#define Exp_1 ((__uint32_t)0x3ff00000L) |
#define Exp_11 ((__uint32_t)0x3ff00000L) |
#define Ebits 11 |
#define Frac_mask ((__uint32_t)0xfffffL) |
#define Frac_mask1 ((__uint32_t)0xfffffL) |
#define Ten_pmax 22 |
#define Bletch 0x10 |
#define Bndry_mask ((__uint32_t)0xfffffL) |
#define Bndry_mask1 ((__uint32_t)0xfffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 1 |
#define Tiny0 0 |
#define Tiny1 1 |
#define Quick_max 14 |
#define Int_max 14 |
#define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L)) /* sufficient test for here */ |
#endif /* !_DOUBLE_IS_32BITS */ |
#ifndef Flt_Rounds |
#ifdef FLT_ROUNDS |
#define Flt_Rounds FLT_ROUNDS |
#else |
#define Flt_Rounds 1 |
#endif |
#endif /*Flt_Rounds*/ |
#else /* !IEEE_8087 && !IEEE_MC68k */ |
#undef Sudden_Underflow |
#define Sudden_Underflow |
#ifdef IBM |
#define Flt_Rounds 0 |
#define Exp_shift 24 |
#define Exp_shift1 24 |
#define Exp_msk1 ((__uint32_t)0x1000000L) |
#define Exp_msk11 ((__uint32_t)0x1000000L) |
#define Exp_mask ((__uint32_t)0x7f000000L) |
#define P 14 |
#define Bias 65 |
#define Exp_1 ((__uint32_t)0x41000000L) |
#define Exp_11 ((__uint32_t)0x41000000L) |
#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ |
#define Frac_mask ((__uint32_t)0xffffffL) |
#define Frac_mask1 ((__uint32_t)0xffffffL) |
#define Bletch 4 |
#define Ten_pmax 22 |
#define Bndry_mask ((__uint32_t)0xefffffL) |
#define Bndry_mask1 ((__uint32_t)0xffffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 4 |
#define Tiny0 ((__uint32_t)0x100000L) |
#define Tiny1 0 |
#define Quick_max 14 |
#define Int_max 15 |
#else /* VAX */ |
#define Flt_Rounds 1 |
#define Exp_shift 23 |
#define Exp_shift1 7 |
#define Exp_msk1 0x80 |
#define Exp_msk11 ((__uint32_t)0x800000L) |
#define Exp_mask ((__uint32_t)0x7f80L) |
#define P 56 |
#define Bias 129 |
#define Exp_1 ((__uint32_t)0x40800000L) |
#define Exp_11 ((__uint32_t)0x4080L) |
#define Ebits 8 |
#define Frac_mask ((__uint32_t)0x7fffffL) |
#define Frac_mask1 ((__uint32_t)0xffff007fL) |
#define Ten_pmax 24 |
#define Bletch 2 |
#define Bndry_mask ((__uint32_t)0xffff007fL) |
#define Bndry_mask1 ((__uint32_t)0xffff007fL) |
#define LSB ((__uint32_t)0x10000L) |
#define Sign_bit ((__uint32_t)0x8000L) |
#define Log2P 1 |
#define Tiny0 0x80 |
#define Tiny1 0 |
#define Quick_max 15 |
#define Int_max 15 |
#endif |
#endif |
#ifndef IEEE_Arith |
#define ROUND_BIASED |
#else |
#define Scale_Bit 0x10 |
#if defined(_DOUBLE_IS_32BITS) && defined(__v800) |
#define n_bigtens 2 |
#else |
#define n_bigtens 5 |
#endif |
#endif |
#ifdef IBM |
#define n_bigtens 3 |
#endif |
#ifdef VAX |
#define n_bigtens 2 |
#endif |
#ifndef __NO_INFNAN_CHECK |
#define INFNAN_CHECK |
#endif |
/* |
* NAN_WORD0 and NAN_WORD1 are only referenced in strtod.c. Prior to |
* 20050115, they used to be hard-wired here (to 0x7ff80000 and 0, |
* respectively), but now are determined by compiling and running |
* qnan.c to generate gd_qnan.h, which specifies d_QNAN0 and d_QNAN1. |
* Formerly gdtoaimp.h recommended supplying suitable -DNAN_WORD0=... |
* and -DNAN_WORD1=... values if necessary. This should still work. |
* (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.) |
*/ |
#ifdef IEEE_Arith |
#ifdef IEEE_MC68k |
#define _0 0 |
#define _1 1 |
#ifndef NAN_WORD0 |
#define NAN_WORD0 d_QNAN0 |
#endif |
#ifndef NAN_WORD1 |
#define NAN_WORD1 d_QNAN1 |
#endif |
#else |
#define _0 1 |
#define _1 0 |
#ifndef NAN_WORD0 |
#define NAN_WORD0 d_QNAN1 |
#endif |
#ifndef NAN_WORD1 |
#define NAN_WORD1 d_QNAN0 |
#endif |
#endif |
#else |
#undef INFNAN_CHECK |
#endif |
#ifdef RND_PRODQUOT |
#define rounded_product(a,b) a = rnd_prod(a, b) |
#define rounded_quotient(a,b) a = rnd_quot(a, b) |
#ifdef KR_headers |
extern double rnd_prod(), rnd_quot(); |
#else |
extern double rnd_prod(double, double), rnd_quot(double, double); |
#endif |
#else |
#define rounded_product(a,b) a *= b |
#define rounded_quotient(a,b) a /= b |
#endif |
#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) |
#define Big1 ((__uint32_t)0xffffffffL) |
#ifndef Just_16 |
/* When Pack_32 is not defined, we store 16 bits per 32-bit long. |
* This makes some inner loops simpler and sometimes saves work |
* during multiplications, but it often seems to make things slightly |
* slower. Hence the default is now to store 32 bits per long. |
*/ |
#ifndef Pack_32 |
#define Pack_32 |
#endif |
#else /* Just_16 */ |
#ifndef Pack_16 |
#define Pack_16 |
#endif |
#endif /* Just_16 */ |
#ifdef Pack_32 |
#define ULbits 32 |
#define kshift 5 |
#define kmask 31 |
#define ALL_ON 0xffffffff |
#else |
#define ULbits 16 |
#define kshift 4 |
#define kmask 15 |
#define ALL_ON 0xffff |
#endif |
#ifdef __cplusplus |
extern "C" double strtod(const char *s00, char **se); |
extern "C" char *dtoa(double d, int mode, int ndigits, |
int *decpt, int *sign, char **rve); |
#endif |
typedef struct _Bigint _Bigint; |
#define Balloc _Balloc |
#define Bfree _Bfree |
#define multadd __multadd |
#define s2b __s2b |
#define lo0bits __lo0bits |
#define hi0bits __hi0bits |
#define i2b __i2b |
#define mult __multiply |
#define pow5mult __pow5mult |
#define lshift __lshift |
#define cmp __mcmp |
#define diff __mdiff |
#define ulp __ulp |
#define b2d __b2d |
#define d2b __d2b |
#define ratio __ratio |
#define any_on __any_on |
#define gethex __gethex |
#define copybits __copybits |
#define hexnan __hexnan |
#define hexdig_init __hexdig_init |
#define hexdig __hexdig |
#define tens __mprec_tens |
#define bigtens __mprec_bigtens |
#define tinytens __mprec_tinytens |
struct _reent ; |
struct FPI; |
double _EXFUN(ulp,(double x)); |
double _EXFUN(b2d,(_Bigint *a , int *e)); |
_Bigint * _EXFUN(Balloc,(struct _reent *p, int k)); |
void _EXFUN(Bfree,(struct _reent *p, _Bigint *v)); |
_Bigint * _EXFUN(multadd,(struct _reent *p, _Bigint *, int, int)); |
_Bigint * _EXFUN(s2b,(struct _reent *, const char*, int, int, __ULong)); |
_Bigint * _EXFUN(i2b,(struct _reent *,int)); |
_Bigint * _EXFUN(mult, (struct _reent *, _Bigint *, _Bigint *)); |
_Bigint * _EXFUN(pow5mult, (struct _reent *, _Bigint *, int k)); |
int _EXFUN(hi0bits,(__ULong)); |
int _EXFUN(lo0bits,(__ULong *)); |
_Bigint * _EXFUN(d2b,(struct _reent *p, double d, int *e, int *bits)); |
_Bigint * _EXFUN(lshift,(struct _reent *p, _Bigint *b, int k)); |
_Bigint * _EXFUN(diff,(struct _reent *p, _Bigint *a, _Bigint *b)); |
int _EXFUN(cmp,(_Bigint *a, _Bigint *b)); |
int _EXFUN(gethex,(struct _reent *p, _CONST char **sp, struct FPI *fpi, Long *exp, _Bigint **bp, int sign)); |
double _EXFUN(ratio,(_Bigint *a, _Bigint *b)); |
__ULong _EXFUN(any_on,(_Bigint *b, int k)); |
void _EXFUN(copybits,(__ULong *c, int n, _Bigint *b)); |
void _EXFUN(hexdig_init,(void)); |
#ifdef INFNAN_CHECK |
int _EXFUN(hexnan,(_CONST char **sp, struct FPI *fpi, __ULong *x0)); |
#endif |
#define Bcopy(x,y) memcpy((char *)&x->_sign, (char *)&y->_sign, y->_wds*sizeof(__Long) + 2*sizeof(int)) |
extern _CONST double tinytens[]; |
extern _CONST double bigtens[]; |
extern _CONST double tens[]; |
extern unsigned char hexdig[]; |
double _EXFUN(_mprec_log10,(int)); |
/contrib/sdk/sources/libc/stdlib/rand.c |
---|
0,0 → 1,91 |
/* |
FUNCTION |
<<rand>>, <<srand>>---pseudo-random numbers |
INDEX |
rand |
INDEX |
srand |
INDEX |
rand_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
int rand(void); |
void srand(unsigned int <[seed]>); |
int rand_r(unsigned int *<[seed]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
int rand(); |
void srand(<[seed]>) |
unsigned int <[seed]>; |
void rand_r(<[seed]>) |
unsigned int *<[seed]>; |
DESCRIPTION |
<<rand>> returns a different integer each time it is called; each |
integer is chosen by an algorithm designed to be unpredictable, so |
that you can use <<rand>> when you require a random number. |
The algorithm depends on a static variable called the ``random seed''; |
starting with a given value of the random seed always produces the |
same sequence of numbers in successive calls to <<rand>>. |
You can set the random seed using <<srand>>; it does nothing beyond |
storing its argument in the static variable used by <<rand>>. You can |
exploit this to make the pseudo-random sequence less predictable, if |
you wish, by using some other unpredictable value (often the least |
significant parts of a time-varying value) as the random seed before |
beginning a sequence of calls to <<rand>>; or, if you wish to ensure |
(for example, while debugging) that successive runs of your program |
use the same ``random'' numbers, you can use <<srand>> to set the same |
random seed at the outset. |
RETURNS |
<<rand>> returns the next pseudo-random integer in sequence; it is a |
number between <<0>> and <<RAND_MAX>> (inclusive). |
<<srand>> does not return a result. |
NOTES |
<<rand>> and <<srand>> are unsafe for multi-threaded applications. |
<<rand_r>> is thread-safe and should be used instead. |
PORTABILITY |
<<rand>> is required by ANSI, but the algorithm for pseudo-random |
number generation is not specified; therefore, even if you use |
the same random seed, you cannot expect the same sequence of results |
on two different systems. |
<<rand>> requires no supporting OS subroutines. |
*/ |
#ifndef _REENT_ONLY |
#include <stdlib.h> |
#include <reent.h> |
void |
_DEFUN (srand, (seed), unsigned int seed) |
{ |
_REENT_CHECK_RAND48(_REENT); |
_REENT_RAND_NEXT(_REENT) = seed; |
} |
int |
_DEFUN_VOID (rand) |
{ |
/* This multiplier was obtained from Knuth, D.E., "The Art of |
Computer Programming," Vol 2, Seminumerical Algorithms, Third |
Edition, Addison-Wesley, 1998, p. 106 (line 26) & p. 108 */ |
_REENT_CHECK_RAND48(_REENT); |
_REENT_RAND_NEXT(_REENT) = |
_REENT_RAND_NEXT(_REENT) * __extension__ 6364136223846793005LL + 1; |
return (int)((_REENT_RAND_NEXT(_REENT) >> 32) & RAND_MAX); |
} |
#endif /* _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdlib/rand48.c |
---|
0,0 → 1,179 |
/* |
* Copyright (c) 1993 Martin Birgmeier |
* All rights reserved. |
* |
* You may redistribute unmodified or modified versions of this source |
* code provided that the above copyright notice and this and the |
* following conditions are retained. |
* |
* This software is provided ``as is'', and comes with no warranties |
* of any kind. I shall in no event be liable for anything that happens |
* to anyone/anything when using this software. |
*/ |
/* |
FUNCTION |
<<rand48>>, <<drand48>>, <<erand48>>, <<lrand48>>, <<nrand48>>, <<mrand48>>, <<jrand48>>, <<srand48>>, <<seed48>>, <<lcong48>>---pseudo-random number generators and initialization routines |
INDEX |
rand48 |
INDEX |
drand48 |
INDEX |
erand48 |
INDEX |
lrand48 |
INDEX |
nrand48 |
INDEX |
mrand48 |
INDEX |
jrand48 |
INDEX |
srand48 |
INDEX |
seed48 |
INDEX |
lcong48 |
ANSI_SYNOPSIS |
#include <stdlib.h> |
double drand48(void); |
double erand48(unsigned short <[xseed]>[3]); |
long lrand48(void); |
long nrand48(unsigned short <[xseed]>[3]); |
long mrand48(void); |
long jrand48(unsigned short <[xseed]>[3]); |
void srand48(long <[seed]>); |
unsigned short *seed48(unsigned short <[xseed]>[3]); |
void lcong48(unsigned short <[p]>[7]); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
double drand48(); |
double erand48(<[xseed]>) |
unsigned short <[xseed]>[3]; |
long lrand48(); |
long nrand48(<[xseed]>) |
unsigned short <[xseed]>[3]; |
long mrand48(); |
long jrand48(<[xseed]>) |
unsigned short <[xseed]>[3]; |
void srand48(<[seed]>) |
long <[seed]>; |
unsigned short *seed48(<[xseed]>) |
unsigned short <[xseed]>[3]; |
void lcong48(<[p]>) |
unsigned short <[p]>[7]; |
DESCRIPTION |
The <<rand48>> family of functions generates pseudo-random numbers |
using a linear congruential algorithm working on integers 48 bits in size. |
The particular formula employed is |
r(n+1) = (a * r(n) + c) mod m |
where the default values are |
for the multiplicand a = 0xfdeece66d = 25214903917 and |
the addend c = 0xb = 11. The modulo is always fixed at m = 2 ** 48. |
r(n) is called the seed of the random number generator. |
For all the six generator routines described next, the first |
computational step is to perform a single iteration of the algorithm. |
<<drand48>> and <<erand48>> |
return values of type double. The full 48 bits of r(n+1) are |
loaded into the mantissa of the returned value, with the exponent set |
such that the values produced lie in the interval [0.0, 1.0]. |
<<lrand48>> and <<nrand48>> |
return values of type long in the range |
[0, 2**31-1]. The high-order (31) bits of |
r(n+1) are loaded into the lower bits of the returned value, with |
the topmost (sign) bit set to zero. |
<<mrand48>> and <<jrand48>> |
return values of type long in the range |
[-2**31, 2**31-1]. The high-order (32) bits of |
r(n+1) are loaded into the returned value. |
<<drand48>>, <<lrand48>>, and <<mrand48>> |
use an internal buffer to store r(n). For these functions |
the initial value of r(0) = 0x1234abcd330e = 20017429951246. |
On the other hand, <<erand48>>, <<nrand48>>, and <<jrand48>> |
use a user-supplied buffer to store the seed r(n), |
which consists of an array of 3 shorts, where the zeroth member |
holds the least significant bits. |
All functions share the same multiplicand and addend. |
<<srand48>> is used to initialize the internal buffer r(n) of |
<<drand48>>, <<lrand48>>, and <<mrand48>> |
such that the 32 bits of the seed value are copied into the upper 32 bits |
of r(n), with the lower 16 bits of r(n) arbitrarily being set to 0x330e. |
Additionally, the constant multiplicand and addend of the algorithm are |
reset to the default values given above. |
<<seed48>> also initializes the internal buffer r(n) of |
<<drand48>>, <<lrand48>>, and <<mrand48>>, |
but here all 48 bits of the seed can be specified in an array of 3 shorts, |
where the zeroth member specifies the lowest bits. Again, |
the constant multiplicand and addend of the algorithm are |
reset to the default values given above. |
<<seed48>> returns a pointer to an array of 3 shorts which contains |
the old seed. |
This array is statically allocated, thus its contents are lost after |
each new call to <<seed48>>. |
Finally, <<lcong48>> allows full control over the multiplicand and |
addend used in <<drand48>>, <<erand48>>, <<lrand48>>, <<nrand48>>, |
<<mrand48>>, and <<jrand48>>, |
and the seed used in <<drand48>>, <<lrand48>>, and <<mrand48>>. |
An array of 7 shorts is passed as parameter; the first three shorts are |
used to initialize the seed; the second three are used to initialize the |
multiplicand; and the last short is used to initialize the addend. |
It is thus not possible to use values greater than 0xffff as the addend. |
Note that all three methods of seeding the random number generator |
always also set the multiplicand and addend for any of the six |
generator calls. |
For a more powerful random number generator, see <<random>>. |
PORTABILITY |
SUS requires these functions. |
No supporting OS subroutines are required. |
*/ |
#include "rand48.h" |
void |
_DEFUN (__dorand48, (r, xseed), |
struct _reent *r _AND |
unsigned short xseed[3]) |
{ |
unsigned long accu; |
unsigned short temp[2]; |
_REENT_CHECK_RAND48(r); |
accu = (unsigned long) __rand48_mult[0] * (unsigned long) xseed[0] + |
(unsigned long) __rand48_add; |
temp[0] = (unsigned short) accu; /* lower 16 bits */ |
accu >>= sizeof(unsigned short) * 8; |
accu += (unsigned long) __rand48_mult[0] * (unsigned long) xseed[1] + |
(unsigned long) __rand48_mult[1] * (unsigned long) xseed[0]; |
temp[1] = (unsigned short) accu; /* middle 16 bits */ |
accu >>= sizeof(unsigned short) * 8; |
accu += __rand48_mult[0] * xseed[2] + __rand48_mult[1] * xseed[1] + __rand48_mult[2] * xseed[0]; |
xseed[0] = temp[0]; |
xseed[1] = temp[1]; |
xseed[2] = (unsigned short) accu; |
} |
/contrib/sdk/sources/libc/stdlib/rand48.h |
---|
0,0 → 1,36 |
/* |
* Copyright (c) 1993 Martin Birgmeier |
* All rights reserved. |
* |
* You may redistribute unmodified or modified versions of this source |
* code provided that the above copyright notice and this and the |
* following conditions are retained. |
* |
* This software is provided ``as is'', and comes with no warranties |
* of any kind. I shall in no event be liable for anything that happens |
* to anyone/anything when using this software. |
*/ |
#ifndef _RAND48_H_ |
#define _RAND48_H_ |
#include <math.h> |
#include <stdlib.h> |
extern void _EXFUN(__dorand48,(struct _reent *r, unsigned short[3])); |
#define __rand48_seed _REENT_RAND48_SEED(r) |
#define __rand48_mult _REENT_RAND48_MULT(r) |
#define __rand48_add _REENT_RAND48_ADD(r) |
#if 0 |
/* following values are defined in <sys/reent.h> */ |
#define RAND48_SEED_0 (0x330e) |
#define RAND48_SEED_1 (0xabcd) |
#define RAND48_SEED_2 (0x1234) |
#define RAND48_MULT_0 (0xe66d) |
#define RAND48_MULT_1 (0xdeec) |
#define RAND48_MULT_2 (0x0005) |
#define RAND48_ADD (0x000b) |
#endif |
#endif /* _RAND48_H_ */ |
/contrib/sdk/sources/libc/stdlib/rand_r.c |
---|
0,0 → 1,37 |
#include <stdlib.h> |
/* Pseudo-random generator based on Minimal Standard by |
Lewis, Goodman, and Miller in 1969. |
I[j+1] = a*I[j] (mod m) |
where a = 16807 |
m = 2147483647 |
Using Schrage's algorithm, a*I[j] (mod m) can be rewritten as: |
a*(I[j] mod q) - r*{I[j]/q} if >= 0 |
a*(I[j] mod q) - r*{I[j]/q} + m otherwise |
where: {} denotes integer division |
q = {m/a} = 127773 |
r = m (mod a) = 2836 |
note that the seed value of 0 cannot be used in the calculation as |
it results in 0 itself |
*/ |
int |
_DEFUN (rand_r, (seed), unsigned int *seed) |
{ |
long k; |
long s = (long)(*seed); |
if (s == 0) |
s = 0x12345987; |
k = s / 127773; |
s = 16807 * (s - k * 127773) - 2836 * k; |
if (s < 0) |
s += 2147483647; |
(*seed) = (unsigned int)s; |
return (int)(s & RAND_MAX); |
} |
/contrib/sdk/sources/libc/stdlib/realloc.c |
---|
0,0 → 1,22 |
#ifdef MALLOC_PROVIDED |
int _dummy_calloc = 1; |
#else |
/* realloc.c -- a wrapper for realloc_r. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdlib.h> |
#include <malloc.h> |
#ifndef _REENT_ONLY |
_PTR |
_DEFUN (realloc, (ap, nbytes), |
_PTR ap _AND |
size_t nbytes) |
{ |
return _realloc_r (_REENT, ap, nbytes); |
} |
#endif |
#endif /* MALLOC_PROVIDED */ |
/contrib/sdk/sources/libc/stdlib/seed48.c |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 1993 Martin Birgmeier |
* All rights reserved. |
* |
* You may redistribute unmodified or modified versions of this source |
* code provided that the above copyright notice and this and the |
* following conditions are retained. |
* |
* This software is provided ``as is'', and comes with no warranties |
* of any kind. I shall in no event be liable for anything that happens |
* to anyone/anything when using this software. |
*/ |
#include "rand48.h" |
unsigned short * |
_DEFUN (_seed48_r, (r, xseed), |
struct _reent *r _AND |
unsigned short xseed[3]) |
{ |
static unsigned short sseed[3]; |
_REENT_CHECK_RAND48(r); |
sseed[0] = __rand48_seed[0]; |
sseed[1] = __rand48_seed[1]; |
sseed[2] = __rand48_seed[2]; |
__rand48_seed[0] = xseed[0]; |
__rand48_seed[1] = xseed[1]; |
__rand48_seed[2] = xseed[2]; |
__rand48_mult[0] = _RAND48_MULT_0; |
__rand48_mult[1] = _RAND48_MULT_1; |
__rand48_mult[2] = _RAND48_MULT_2; |
__rand48_add = _RAND48_ADD; |
return sseed; |
} |
#ifndef _REENT_ONLY |
unsigned short * |
_DEFUN (seed48, (xseed), |
unsigned short xseed[3]) |
{ |
return _seed48_r (_REENT, xseed); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdlib/srand48.c |
---|
0,0 → 1,38 |
/* |
* Copyright (c) 1993 Martin Birgmeier |
* All rights reserved. |
* |
* You may redistribute unmodified or modified versions of this source |
* code provided that the above copyright notice and this and the |
* following conditions are retained. |
* |
* This software is provided ``as is'', and comes with no warranties |
* of any kind. I shall in no event be liable for anything that happens |
* to anyone/anything when using this software. |
*/ |
#include "rand48.h" |
_VOID |
_DEFUN (_srand48_r, (r, seed), |
struct _reent *r _AND |
long seed) |
{ |
_REENT_CHECK_RAND48(r); |
__rand48_seed[0] = _RAND48_SEED_0; |
__rand48_seed[1] = (unsigned short) seed; |
__rand48_seed[2] = (unsigned short) ((unsigned long)seed >> 16); |
__rand48_mult[0] = _RAND48_MULT_0; |
__rand48_mult[1] = _RAND48_MULT_1; |
__rand48_mult[2] = _RAND48_MULT_2; |
__rand48_add = _RAND48_ADD; |
} |
#ifndef _REENT_ONLY |
_VOID |
_DEFUN (srand48, (seed), |
long seed) |
{ |
_srand48_r (_REENT, seed); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdlib/std.h |
---|
0,0 → 1,33 |
#include <stdlib.h> |
#include <stdio.h> |
#include <errno.h> |
#include <limits.h> |
#include <math.h> |
#ifndef CYGNUS_NEC |
#include <ctype.h> |
#endif |
#define Ise(c) ((c == 'e') || (c == 'E') || (c == 'd') || (c == 'D')) |
#define Isdigit(c) ((c <= '9') && (c >= '0')) |
#define Isspace(c) ((c == ' ') || (c == '\t') || (c=='\n') || (c=='\v') \ |
|| (c == '\r') || (c == '\f')) |
#define Issign(c) ((c == '-') || (c == '+')) |
#define Val(c) ((c - '0')) |
#define MAXE 308 |
#define MINE (-308) |
/* flags */ |
#define SIGN 0x01 |
#define ESIGN 0x02 |
#define DECP 0x04 |
#ifdef _HAVE_STDC |
int __ten_mul(double *acc, int digit); |
double __adjust(struct _reent *ptr, double *acc, int dexp, int sign); |
double __exp10(unsigned x); |
#else |
int __ten_mul(); |
double __adjust(); |
double __exp10(); |
#endif |
/contrib/sdk/sources/libc/stdlib/strtod.c |
---|
0,0 → 1,1197 |
/* |
FUNCTION |
<<strtod>>, <<strtof>>---string to double or float |
INDEX |
strtod |
INDEX |
_strtod_r |
INDEX |
strtof |
ANSI_SYNOPSIS |
#include <stdlib.h> |
double strtod(const char *<[str]>, char **<[tail]>); |
float strtof(const char *<[str]>, char **<[tail]>); |
double _strtod_r(void *<[reent]>, |
const char *<[str]>, char **<[tail]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
double strtod(<[str]>,<[tail]>) |
char *<[str]>; |
char **<[tail]>; |
float strtof(<[str]>,<[tail]>) |
char *<[str]>; |
char **<[tail]>; |
double _strtod_r(<[reent]>,<[str]>,<[tail]>) |
char *<[reent]>; |
char *<[str]>; |
char **<[tail]>; |
DESCRIPTION |
The function <<strtod>> parses the character string <[str]>, |
producing a substring which can be converted to a double |
value. The substring converted is the longest initial |
subsequence of <[str]>, beginning with the first |
non-whitespace character, that has one of these formats: |
.[+|-]<[digits]>[.[<[digits]>]][(e|E)[+|-]<[digits]>] |
.[+|-].<[digits]>[(e|E)[+|-]<[digits]>] |
.[+|-](i|I)(n|N)(f|F)[(i|I)(n|N)(i|I)(t|T)(y|Y)] |
.[+|-](n|N)(a|A)(n|N)[<(>[<[hexdigits]>]<)>] |
.[+|-]0(x|X)<[hexdigits]>[.[<[hexdigits]>]][(p|P)[+|-]<[digits]>] |
.[+|-]0(x|X).<[hexdigits]>[(p|P)[+|-]<[digits]>] |
The substring contains no characters if <[str]> is empty, consists |
entirely of whitespace, or if the first non-whitespace |
character is something other than <<+>>, <<->>, <<.>>, or a |
digit, and cannot be parsed as infinity or NaN. If the platform |
does not support NaN, then NaN is treated as an empty substring. |
If the substring is empty, no conversion is done, and |
the value of <[str]> is stored in <<*<[tail]>>>. Otherwise, |
the substring is converted, and a pointer to the final string |
(which will contain at least the terminating null character of |
<[str]>) is stored in <<*<[tail]>>>. If you want no |
assignment to <<*<[tail]>>>, pass a null pointer as <[tail]>. |
<<strtof>> is identical to <<strtod>> except for its return type. |
This implementation returns the nearest machine number to the |
input decimal string. Ties are broken by using the IEEE |
round-even rule. However, <<strtof>> is currently subject to |
double rounding errors. |
The alternate function <<_strtod_r>> is a reentrant version. |
The extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<strtod>> returns the converted substring value, if any. If |
no conversion could be performed, 0 is returned. If the |
correct value is out of the range of representable values, |
plus or minus <<HUGE_VAL>> is returned, and <<ERANGE>> is |
stored in errno. If the correct value would cause underflow, 0 |
is returned and <<ERANGE>> is stored in errno. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
/**************************************************************** |
The author of this software is David M. Gay. |
Copyright (C) 1998-2001 by Lucent Technologies |
All Rights Reserved |
Permission to use, copy, modify, and distribute this software and |
its documentation for any purpose and without fee is hereby |
granted, provided that the above copyright notice appear in all |
copies and that both that the copyright notice and this |
permission notice and warranty disclaimer appear in supporting |
documentation, and that the name of Lucent or any of its entities |
not be used in advertising or publicity pertaining to |
distribution of the software without specific, written prior |
permission. |
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. |
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY |
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER |
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF |
THIS SOFTWARE. |
****************************************************************/ |
/* Please send bug reports to David M. Gay (dmg at acm dot org, |
* with " at " changed at "@" and " dot " changed to "."). */ |
/* Original file gdtoa-strtod.c Modified 06-21-2006 by Jeff Johnston to work within newlib. */ |
#include <_ansi.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <string.h> |
#include "mprec.h" |
#include "gdtoa.h" |
#include "gd_qnan.h" |
/* #ifndef NO_FENV_H */ |
/* #include <fenv.h> */ |
/* #endif */ |
#include "locale.h" |
#ifdef IEEE_Arith |
#ifndef NO_IEEE_Scale |
#define Avoid_Underflow |
#undef tinytens |
/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */ |
/* flag unnecessarily. It leads to a song and dance at the end of strtod. */ |
static _CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, |
9007199254740992.e-256 |
}; |
#endif |
#endif |
#ifdef Honor_FLT_ROUNDS |
#define Rounding rounding |
#undef Check_FLT_ROUNDS |
#define Check_FLT_ROUNDS |
#else |
#define Rounding Flt_Rounds |
#endif |
#ifndef NO_HEX_FP |
static void |
_DEFUN (ULtod, (L, bits, exp, k), |
__ULong *L _AND |
__ULong *bits _AND |
Long exp _AND |
int k) |
{ |
switch(k & STRTOG_Retmask) { |
case STRTOG_NoNumber: |
case STRTOG_Zero: |
L[0] = L[1] = 0; |
break; |
case STRTOG_Denormal: |
L[_1] = bits[0]; |
L[_0] = bits[1]; |
break; |
case STRTOG_Normal: |
case STRTOG_NaNbits: |
L[_1] = bits[0]; |
L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20); |
break; |
case STRTOG_Infinite: |
L[_0] = 0x7ff00000; |
L[_1] = 0; |
break; |
case STRTOG_NaN: |
L[_0] = 0x7fffffff; |
L[_1] = (__ULong)-1; |
} |
if (k & STRTOG_Neg) |
L[_0] |= 0x80000000L; |
} |
#endif /* !NO_HEX_FP */ |
#ifdef INFNAN_CHECK |
static int |
_DEFUN (match, (sp, t), |
_CONST char **sp _AND |
char *t) |
{ |
int c, d; |
_CONST char *s = *sp; |
while( (d = *t++) !=0) { |
if ((c = *++s) >= 'A' && c <= 'Z') |
c += 'a' - 'A'; |
if (c != d) |
return 0; |
} |
*sp = s + 1; |
return 1; |
} |
#endif /* INFNAN_CHECK */ |
double |
_DEFUN (_strtod_r, (ptr, s00, se), |
struct _reent *ptr _AND |
_CONST char *s00 _AND |
char **se) |
{ |
#ifdef Avoid_Underflow |
int scale; |
#endif |
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, dsign, |
e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; |
_CONST char *s, *s0, *s1; |
double aadj, adj; |
U aadj1, rv, rv0; |
Long L; |
__ULong y, z; |
_Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; |
#ifdef SET_INEXACT |
int inexact, oldinexact; |
#endif |
#ifdef Honor_FLT_ROUNDS |
int rounding; |
#endif |
delta = bs = bd = NULL; |
sign = nz0 = nz = decpt = 0; |
dval(rv) = 0.; |
for(s = s00;;s++) switch(*s) { |
case '-': |
sign = 1; |
/* no break */ |
case '+': |
if (*++s) |
goto break2; |
/* no break */ |
case 0: |
goto ret0; |
case '\t': |
case '\n': |
case '\v': |
case '\f': |
case '\r': |
case ' ': |
continue; |
default: |
goto break2; |
} |
break2: |
if (*s == '0') { |
#ifndef NO_HEX_FP |
{ |
static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; |
Long exp; |
__ULong bits[2]; |
switch(s[1]) { |
case 'x': |
case 'X': |
/* If the number is not hex, then the parse of |
0 is still valid. */ |
s00 = s + 1; |
{ |
#if defined(FE_DOWNWARD) && defined(FE_TONEAREST) && defined(FE_TOWARDZERO) && defined(FE_UPWARD) |
FPI fpi1 = fpi; |
switch(fegetround()) { |
case FE_TOWARDZERO: fpi1.rounding = 0; break; |
case FE_UPWARD: fpi1.rounding = 2; break; |
case FE_DOWNWARD: fpi1.rounding = 3; |
} |
#else |
#define fpi1 fpi |
#endif |
switch((i = gethex(ptr, &s, &fpi1, &exp, &bb, sign)) & STRTOG_Retmask) { |
case STRTOG_NoNumber: |
s = s00; |
case STRTOG_Zero: |
break; |
default: |
if (bb) { |
copybits(bits, fpi.nbits, bb); |
Bfree(ptr,bb); |
} |
ULtod(rv.i, bits, exp, i); |
}} |
goto ret; |
} |
} |
#endif |
nz0 = 1; |
while(*++s == '0') ; |
if (!*s) |
goto ret; |
} |
s0 = s; |
y = z = 0; |
for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) { |
if (nd < DBL_DIG + 1) { |
if (nd < 9) |
y = 10*y + c - '0'; |
else |
z = 10*z + c - '0'; |
} |
} |
nd0 = nd; |
if (strncmp (s, _localeconv_r (ptr)->decimal_point, |
strlen (_localeconv_r (ptr)->decimal_point)) == 0) { |
decpt = 1; |
c = *(s += strlen (_localeconv_r (ptr)->decimal_point)); |
if (!nd) { |
for(; c == '0'; c = *++s) |
nz++; |
if (c > '0' && c <= '9') { |
s0 = s; |
nf += nz; |
nz = 0; |
goto have_dig; |
} |
goto dig_done; |
} |
for(; c >= '0' && c <= '9'; c = *++s) { |
have_dig: |
nz++; |
if (c -= '0') { |
for(i = 1; i < nz; i++) { |
if (nd <= DBL_DIG + 1) { |
if (nd + i < 10) |
y *= 10; |
else |
z *= 10; |
} |
} |
if (nd <= DBL_DIG + 1) { |
if (nd + i < 10) |
y = 10*y + c; |
else |
z = 10*z + c; |
} |
if (nd <= DBL_DIG + 1) { |
nf += nz; |
nd += nz; |
} |
nz = 0; |
} |
} |
} |
dig_done: |
e = 0; |
if (c == 'e' || c == 'E') { |
if (!nd && !nz && !nz0) { |
goto ret0; |
} |
s00 = s; |
esign = 0; |
switch(c = *++s) { |
case '-': |
esign = 1; |
case '+': |
c = *++s; |
} |
if (c >= '0' && c <= '9') { |
while(c == '0') |
c = *++s; |
if (c > '0' && c <= '9') { |
L = c - '0'; |
s1 = s; |
while((c = *++s) >= '0' && c <= '9') |
L = 10*L + c - '0'; |
if (s - s1 > 8 || L > 19999) |
/* Avoid confusion from exponents |
* so large that e might overflow. |
*/ |
e = 19999; /* safe for 16 bit ints */ |
else |
e = (int)L; |
if (esign) |
e = -e; |
} |
else |
e = 0; |
} |
else |
s = s00; |
} |
if (!nd) { |
if (!nz && !nz0) { |
#ifdef INFNAN_CHECK |
/* Check for Nan and Infinity */ |
__ULong bits[2]; |
static FPI fpinan = /* only 52 explicit bits */ |
{ 52, 1-1023-53+1, 2046-1023-53+1, 1, SI }; |
if (!decpt) |
switch(c) { |
case 'i': |
case 'I': |
if (match(&s,"nf")) { |
--s; |
if (!match(&s,"inity")) |
++s; |
dword0(rv) = 0x7ff00000; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
goto ret; |
} |
break; |
case 'n': |
case 'N': |
if (match(&s, "an")) { |
#ifndef No_Hex_NaN |
if (*s == '(' /*)*/ |
&& hexnan(&s, &fpinan, bits) |
== STRTOG_NaNbits) { |
dword0(rv) = 0x7ff00000 | bits[1]; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = bits[0]; |
#endif /*!_DOUBLE_IS_32BITS*/ |
} |
else { |
#endif |
dword0(rv) = NAN_WORD0; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = NAN_WORD1; |
#endif /*!_DOUBLE_IS_32BITS*/ |
#ifndef No_Hex_NaN |
} |
#endif |
goto ret; |
} |
} |
#endif /* INFNAN_CHECK */ |
ret0: |
s = s00; |
sign = 0; |
} |
goto ret; |
} |
e1 = e -= nf; |
/* Now we have nd0 digits, starting at s0, followed by a |
* decimal point, followed by nd-nd0 digits. The number we're |
* after is the integer represented by those digits times |
* 10**e */ |
if (!nd0) |
nd0 = nd; |
k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; |
dval(rv) = y; |
if (k > 9) { |
#ifdef SET_INEXACT |
if (k > DBL_DIG) |
oldinexact = get_inexact(); |
#endif |
dval(rv) = tens[k - 9] * dval(rv) + z; |
} |
bd0 = 0; |
if (nd <= DBL_DIG |
#ifndef RND_PRODQUOT |
#ifndef Honor_FLT_ROUNDS |
&& Flt_Rounds == 1 |
#endif |
#endif |
) { |
if (!e) |
goto ret; |
if (e > 0) { |
if (e <= Ten_pmax) { |
#ifdef VAX |
goto vax_ovfl_check; |
#else |
#ifdef Honor_FLT_ROUNDS |
/* round correctly FLT_ROUNDS = 2 or 3 */ |
if (sign) { |
dval(rv) = -dval(rv); |
sign = 0; |
} |
#endif |
/* rv = */ rounded_product(dval(rv), tens[e]); |
goto ret; |
#endif |
} |
i = DBL_DIG - nd; |
if (e <= Ten_pmax + i) { |
/* A fancier test would sometimes let us do |
* this for larger i values. |
*/ |
#ifdef Honor_FLT_ROUNDS |
/* round correctly FLT_ROUNDS = 2 or 3 */ |
if (sign) { |
dval(rv) = -dval(rv); |
sign = 0; |
} |
#endif |
e -= i; |
dval(rv) *= tens[i]; |
#ifdef VAX |
/* VAX exponent range is so narrow we must |
* worry about overflow here... |
*/ |
vax_ovfl_check: |
dword0(rv) -= P*Exp_msk1; |
/* rv = */ rounded_product(dval(rv), tens[e]); |
if ((dword0(rv) & Exp_mask) |
> Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) |
goto ovfl; |
dword0(rv) += P*Exp_msk1; |
#else |
/* rv = */ rounded_product(dval(rv), tens[e]); |
#endif |
goto ret; |
} |
} |
#ifndef Inaccurate_Divide |
else if (e >= -Ten_pmax) { |
#ifdef Honor_FLT_ROUNDS |
/* round correctly FLT_ROUNDS = 2 or 3 */ |
if (sign) { |
dval(rv) = -dval(rv); |
sign = 0; |
} |
#endif |
/* rv = */ rounded_quotient(dval(rv), tens[-e]); |
goto ret; |
} |
#endif |
} |
e1 += nd - k; |
#ifdef IEEE_Arith |
#ifdef SET_INEXACT |
inexact = 1; |
if (k <= DBL_DIG) |
oldinexact = get_inexact(); |
#endif |
#ifdef Avoid_Underflow |
scale = 0; |
#endif |
#ifdef Honor_FLT_ROUNDS |
if ((rounding = Flt_Rounds) >= 2) { |
if (sign) |
rounding = rounding == 2 ? 0 : 2; |
else |
if (rounding != 2) |
rounding = 0; |
} |
#endif |
#endif /*IEEE_Arith*/ |
/* Get starting approximation = rv * 10**e1 */ |
if (e1 > 0) { |
if ( (i = e1 & 15) !=0) |
dval(rv) *= tens[i]; |
if (e1 &= ~15) { |
if (e1 > DBL_MAX_10_EXP) { |
ovfl: |
#ifndef NO_ERRNO |
ptr->_errno = ERANGE; |
#endif |
/* Can't trust HUGE_VAL */ |
#ifdef IEEE_Arith |
#ifdef Honor_FLT_ROUNDS |
switch(rounding) { |
case 0: /* toward 0 */ |
case 3: /* toward -infinity */ |
dword0(rv) = Big0; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = Big1; |
#endif /*!_DOUBLE_IS_32BITS*/ |
break; |
default: |
dword0(rv) = Exp_mask; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
} |
#else /*Honor_FLT_ROUNDS*/ |
dword0(rv) = Exp_mask; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
#endif /*Honor_FLT_ROUNDS*/ |
#ifdef SET_INEXACT |
/* set overflow bit */ |
dval(rv0) = 1e300; |
dval(rv0) *= dval(rv0); |
#endif |
#else /*IEEE_Arith*/ |
dword0(rv) = Big0; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = Big1; |
#endif /*!_DOUBLE_IS_32BITS*/ |
#endif /*IEEE_Arith*/ |
if (bd0) |
goto retfree; |
goto ret; |
} |
e1 >>= 4; |
for(j = 0; e1 > 1; j++, e1 >>= 1) |
if (e1 & 1) |
dval(rv) *= bigtens[j]; |
/* The last multiplication could overflow. */ |
dword0(rv) -= P*Exp_msk1; |
dval(rv) *= bigtens[j]; |
if ((z = dword0(rv) & Exp_mask) |
> Exp_msk1*(DBL_MAX_EXP+Bias-P)) |
goto ovfl; |
if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { |
/* set to largest number */ |
/* (Can't trust DBL_MAX) */ |
dword0(rv) = Big0; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = Big1; |
#endif /*!_DOUBLE_IS_32BITS*/ |
} |
else |
dword0(rv) += P*Exp_msk1; |
} |
} |
else if (e1 < 0) { |
e1 = -e1; |
if ( (i = e1 & 15) !=0) |
dval(rv) /= tens[i]; |
if (e1 >>= 4) { |
if (e1 >= 1 << n_bigtens) |
goto undfl; |
#ifdef Avoid_Underflow |
if (e1 & Scale_Bit) |
scale = 2*P; |
for(j = 0; e1 > 0; j++, e1 >>= 1) |
if (e1 & 1) |
dval(rv) *= tinytens[j]; |
if (scale && (j = 2*P + 1 - ((dword0(rv) & Exp_mask) |
>> Exp_shift)) > 0) { |
/* scaled rv is denormal; zap j low bits */ |
if (j >= 32) { |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
if (j >= 53) |
dword0(rv) = (P+2)*Exp_msk1; |
else |
dword0(rv) &= 0xffffffff << (j-32); |
} |
#ifndef _DOUBLE_IS_32BITS |
else |
dword1(rv) &= 0xffffffff << j; |
#endif /*!_DOUBLE_IS_32BITS*/ |
} |
#else |
for(j = 0; e1 > 1; j++, e1 >>= 1) |
if (e1 & 1) |
dval(rv) *= tinytens[j]; |
/* The last multiplication could underflow. */ |
dval(rv0) = dval(rv); |
dval(rv) *= tinytens[j]; |
if (!dval(rv)) { |
dval(rv) = 2.*dval(rv0); |
dval(rv) *= tinytens[j]; |
#endif |
if (!dval(rv)) { |
undfl: |
dval(rv) = 0.; |
#ifndef NO_ERRNO |
ptr->_errno = ERANGE; |
#endif |
if (bd0) |
goto retfree; |
goto ret; |
} |
#ifndef Avoid_Underflow |
#ifndef _DOUBLE_IS_32BITS |
dword0(rv) = Tiny0; |
dword1(rv) = Tiny1; |
#else |
dword0(rv) = Tiny1; |
#endif /*_DOUBLE_IS_32BITS*/ |
/* The refinement below will clean |
* this approximation up. |
*/ |
} |
#endif |
} |
} |
/* Now the hard part -- adjusting rv to the correct value.*/ |
/* Put digits into bd: true value = bd * 10^e */ |
bd0 = s2b(ptr, s0, nd0, nd, y); |
for(;;) { |
bd = Balloc(ptr,bd0->_k); |
Bcopy(bd, bd0); |
bb = d2b(ptr,dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */ |
bs = i2b(ptr,1); |
if (e >= 0) { |
bb2 = bb5 = 0; |
bd2 = bd5 = e; |
} |
else { |
bb2 = bb5 = -e; |
bd2 = bd5 = 0; |
} |
if (bbe >= 0) |
bb2 += bbe; |
else |
bd2 -= bbe; |
bs2 = bb2; |
#ifdef Honor_FLT_ROUNDS |
if (rounding != 1) |
bs2++; |
#endif |
#ifdef Avoid_Underflow |
j = bbe - scale; |
i = j + bbbits - 1; /* logb(rv) */ |
if (i < Emin) /* denormal */ |
j += P - Emin; |
else |
j = P + 1 - bbbits; |
#else /*Avoid_Underflow*/ |
#ifdef Sudden_Underflow |
#ifdef IBM |
j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); |
#else |
j = P + 1 - bbbits; |
#endif |
#else /*Sudden_Underflow*/ |
j = bbe; |
i = j + bbbits - 1; /* logb(rv) */ |
if (i < Emin) /* denormal */ |
j += P - Emin; |
else |
j = P + 1 - bbbits; |
#endif /*Sudden_Underflow*/ |
#endif /*Avoid_Underflow*/ |
bb2 += j; |
bd2 += j; |
#ifdef Avoid_Underflow |
bd2 += scale; |
#endif |
i = bb2 < bd2 ? bb2 : bd2; |
if (i > bs2) |
i = bs2; |
if (i > 0) { |
bb2 -= i; |
bd2 -= i; |
bs2 -= i; |
} |
if (bb5 > 0) { |
bs = pow5mult(ptr, bs, bb5); |
bb1 = mult(ptr, bs, bb); |
Bfree(ptr, bb); |
bb = bb1; |
} |
if (bb2 > 0) |
bb = lshift(ptr, bb, bb2); |
if (bd5 > 0) |
bd = pow5mult(ptr, bd, bd5); |
if (bd2 > 0) |
bd = lshift(ptr, bd, bd2); |
if (bs2 > 0) |
bs = lshift(ptr, bs, bs2); |
delta = diff(ptr, bb, bd); |
dsign = delta->_sign; |
delta->_sign = 0; |
i = cmp(delta, bs); |
#ifdef Honor_FLT_ROUNDS |
if (rounding != 1) { |
if (i < 0) { |
/* Error is less than an ulp */ |
if (!delta->_x[0] && delta->_wds <= 1) { |
/* exact */ |
#ifdef SET_INEXACT |
inexact = 0; |
#endif |
break; |
} |
if (rounding) { |
if (dsign) { |
adj = 1.; |
goto apply_adj; |
} |
} |
else if (!dsign) { |
adj = -1.; |
if (!dword1(rv) |
&& !(dword0(rv) & Frac_mask)) { |
y = dword0(rv) & Exp_mask; |
#ifdef Avoid_Underflow |
if (!scale || y > 2*P*Exp_msk1) |
#else |
if (y) |
#endif |
{ |
delta = lshift(ptr, delta,Log2P); |
if (cmp(delta, bs) <= 0) |
adj = -0.5; |
} |
} |
apply_adj: |
#ifdef Avoid_Underflow |
if (scale && (y = dword0(rv) & Exp_mask) |
<= 2*P*Exp_msk1) |
dword0(adj) += (2*P+1)*Exp_msk1 - y; |
#else |
#ifdef Sudden_Underflow |
if ((dword0(rv) & Exp_mask) <= |
P*Exp_msk1) { |
dword0(rv) += P*Exp_msk1; |
dval(rv) += adj*ulp(dval(rv)); |
dword0(rv) -= P*Exp_msk1; |
} |
else |
#endif /*Sudden_Underflow*/ |
#endif /*Avoid_Underflow*/ |
dval(rv) += adj*ulp(dval(rv)); |
} |
break; |
} |
adj = ratio(delta, bs); |
if (adj < 1.) |
adj = 1.; |
if (adj <= 0x7ffffffe) { |
/* adj = rounding ? ceil(adj) : floor(adj); */ |
y = adj; |
if (y != adj) { |
if (!((rounding>>1) ^ dsign)) |
y++; |
adj = y; |
} |
} |
#ifdef Avoid_Underflow |
if (scale && (y = dword0(rv) & Exp_mask) <= 2*P*Exp_msk1) |
dword0(adj) += (2*P+1)*Exp_msk1 - y; |
#else |
#ifdef Sudden_Underflow |
if ((dword0(rv) & Exp_mask) <= P*Exp_msk1) { |
dword0(rv) += P*Exp_msk1; |
adj *= ulp(dval(rv)); |
if (dsign) |
dval(rv) += adj; |
else |
dval(rv) -= adj; |
dword0(rv) -= P*Exp_msk1; |
goto cont; |
} |
#endif /*Sudden_Underflow*/ |
#endif /*Avoid_Underflow*/ |
adj *= ulp(dval(rv)); |
if (dsign) |
dval(rv) += adj; |
else |
dval(rv) -= adj; |
goto cont; |
} |
#endif /*Honor_FLT_ROUNDS*/ |
if (i < 0) { |
/* Error is less than half an ulp -- check for |
* special case of mantissa a power of two. |
*/ |
if (dsign || dword1(rv) || dword0(rv) & Bndry_mask |
#ifdef IEEE_Arith |
#ifdef Avoid_Underflow |
|| (dword0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1 |
#else |
|| (dword0(rv) & Exp_mask) <= Exp_msk1 |
#endif |
#endif |
) { |
#ifdef SET_INEXACT |
if (!delta->x[0] && delta->wds <= 1) |
inexact = 0; |
#endif |
break; |
} |
if (!delta->_x[0] && delta->_wds <= 1) { |
/* exact result */ |
#ifdef SET_INEXACT |
inexact = 0; |
#endif |
break; |
} |
delta = lshift(ptr,delta,Log2P); |
if (cmp(delta, bs) > 0) |
goto drop_down; |
break; |
} |
if (i == 0) { |
/* exactly half-way between */ |
if (dsign) { |
if ((dword0(rv) & Bndry_mask1) == Bndry_mask1 |
&& dword1(rv) == ( |
#ifdef Avoid_Underflow |
(scale && (y = dword0(rv) & Exp_mask) <= 2*P*Exp_msk1) |
? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) : |
#endif |
0xffffffff)) { |
/*boundary case -- increment exponent*/ |
dword0(rv) = (dword0(rv) & Exp_mask) |
+ Exp_msk1 |
#ifdef IBM |
| Exp_msk1 >> 4 |
#endif |
; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
#ifdef Avoid_Underflow |
dsign = 0; |
#endif |
break; |
} |
} |
else if (!(dword0(rv) & Bndry_mask) && !dword1(rv)) { |
drop_down: |
/* boundary case -- decrement exponent */ |
#ifdef Sudden_Underflow /*{{*/ |
L = dword0(rv) & Exp_mask; |
#ifdef IBM |
if (L < Exp_msk1) |
#else |
#ifdef Avoid_Underflow |
if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1)) |
#else |
if (L <= Exp_msk1) |
#endif /*Avoid_Underflow*/ |
#endif /*IBM*/ |
goto undfl; |
L -= Exp_msk1; |
#else /*Sudden_Underflow}{*/ |
#ifdef Avoid_Underflow |
if (scale) { |
L = dword0(rv) & Exp_mask; |
if (L <= (2*P+1)*Exp_msk1) { |
if (L > (P+2)*Exp_msk1) |
/* round even ==> */ |
/* accept rv */ |
break; |
/* rv = smallest denormal */ |
goto undfl; |
} |
} |
#endif /*Avoid_Underflow*/ |
L = (dword0(rv) & Exp_mask) - Exp_msk1; |
#endif /*Sudden_Underflow}*/ |
dword0(rv) = L | Bndry_mask1; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = 0xffffffff; |
#endif /*!_DOUBLE_IS_32BITS*/ |
#ifdef IBM |
goto cont; |
#else |
break; |
#endif |
} |
#ifndef ROUND_BIASED |
if (!(dword1(rv) & LSB)) |
break; |
#endif |
if (dsign) |
dval(rv) += ulp(dval(rv)); |
#ifndef ROUND_BIASED |
else { |
dval(rv) -= ulp(dval(rv)); |
#ifndef Sudden_Underflow |
if (!dval(rv)) |
goto undfl; |
#endif |
} |
#ifdef Avoid_Underflow |
dsign = 1 - dsign; |
#endif |
#endif |
break; |
} |
if ((aadj = ratio(delta, bs)) <= 2.) { |
if (dsign) |
aadj = dval(aadj1) = 1.; |
else if (dword1(rv) || dword0(rv) & Bndry_mask) { |
#ifndef Sudden_Underflow |
if (dword1(rv) == Tiny1 && !dword0(rv)) |
goto undfl; |
#endif |
aadj = 1.; |
dval(aadj1) = -1.; |
} |
else { |
/* special case -- power of FLT_RADIX to be */ |
/* rounded down... */ |
if (aadj < 2./FLT_RADIX) |
aadj = 1./FLT_RADIX; |
else |
aadj *= 0.5; |
dval(aadj1) = -aadj; |
} |
} |
else { |
aadj *= 0.5; |
dval(aadj1) = dsign ? aadj : -aadj; |
#ifdef Check_FLT_ROUNDS |
switch(Rounding) { |
case 2: /* towards +infinity */ |
dval(aadj1) -= 0.5; |
break; |
case 0: /* towards 0 */ |
case 3: /* towards -infinity */ |
dval(aadj1) += 0.5; |
} |
#else |
if (Flt_Rounds == 0) |
dval(aadj1) += 0.5; |
#endif /*Check_FLT_ROUNDS*/ |
} |
y = dword0(rv) & Exp_mask; |
/* Check for overflow */ |
if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { |
dval(rv0) = dval(rv); |
dword0(rv) -= P*Exp_msk1; |
adj = dval(aadj1) * ulp(dval(rv)); |
dval(rv) += adj; |
if ((dword0(rv) & Exp_mask) >= |
Exp_msk1*(DBL_MAX_EXP+Bias-P)) { |
if (dword0(rv0) == Big0 && dword1(rv0) == Big1) |
goto ovfl; |
dword0(rv) = Big0; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv) = Big1; |
#endif /*!_DOUBLE_IS_32BITS*/ |
goto cont; |
} |
else |
dword0(rv) += P*Exp_msk1; |
} |
else { |
#ifdef Avoid_Underflow |
if (scale && y <= 2*P*Exp_msk1) { |
if (aadj <= 0x7fffffff) { |
if ((z = aadj) <= 0) |
z = 1; |
aadj = z; |
dval(aadj1) = dsign ? aadj : -aadj; |
} |
dword0(aadj1) += (2*P+1)*Exp_msk1 - y; |
} |
adj = dval(aadj1) * ulp(dval(rv)); |
dval(rv) += adj; |
#else |
#ifdef Sudden_Underflow |
if ((dword0(rv) & Exp_mask) <= P*Exp_msk1) { |
dval(rv0) = dval(rv); |
dword0(rv) += P*Exp_msk1; |
adj = dval(aadj1) * ulp(dval(rv)); |
dval(rv) += adj; |
#ifdef IBM |
if ((dword0(rv) & Exp_mask) < P*Exp_msk1) |
#else |
if ((dword0(rv) & Exp_mask) <= P*Exp_msk1) |
#endif |
{ |
if (dword0(rv0) == Tiny0 |
&& dword1(rv0) == Tiny1) |
goto undfl; |
#ifndef _DOUBLE_IS_32BITS |
dword0(rv) = Tiny0; |
dword1(rv) = Tiny1; |
#else |
dword0(rv) = Tiny1; |
#endif /*_DOUBLE_IS_32BITS*/ |
goto cont; |
} |
else |
dword0(rv) -= P*Exp_msk1; |
} |
else { |
adj = dval(aadj1) * ulp(dval(rv)); |
dval(rv) += adj; |
} |
#else /*Sudden_Underflow*/ |
/* Compute adj so that the IEEE rounding rules will |
* correctly round rv + adj in some half-way cases. |
* If rv * ulp(rv) is denormalized (i.e., |
* y <= (P-1)*Exp_msk1), we must adjust aadj to avoid |
* trouble from bits lost to denormalization; |
* example: 1.2e-307 . |
*/ |
if (y <= (P-1)*Exp_msk1 && aadj > 1.) { |
dval(aadj1) = (double)(int)(aadj + 0.5); |
if (!dsign) |
dval(aadj1) = -dval(aadj1); |
} |
adj = dval(aadj1) * ulp(dval(rv)); |
dval(rv) += adj; |
#endif /*Sudden_Underflow*/ |
#endif /*Avoid_Underflow*/ |
} |
z = dword0(rv) & Exp_mask; |
#ifndef SET_INEXACT |
#ifdef Avoid_Underflow |
if (!scale) |
#endif |
if (y == z) { |
/* Can we stop now? */ |
L = (Long)aadj; |
aadj -= L; |
/* The tolerances below are conservative. */ |
if (dsign || dword1(rv) || dword0(rv) & Bndry_mask) { |
if (aadj < .4999999 || aadj > .5000001) |
break; |
} |
else if (aadj < .4999999/FLT_RADIX) |
break; |
} |
#endif |
cont: |
Bfree(ptr,bb); |
Bfree(ptr,bd); |
Bfree(ptr,bs); |
Bfree(ptr,delta); |
} |
#ifdef SET_INEXACT |
if (inexact) { |
if (!oldinexact) { |
dword0(rv0) = Exp_1 + (70 << Exp_shift); |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv0) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
dval(rv0) += 1.; |
} |
} |
else if (!oldinexact) |
clear_inexact(); |
#endif |
#ifdef Avoid_Underflow |
if (scale) { |
dword0(rv0) = Exp_1 - 2*P*Exp_msk1; |
#ifndef _DOUBLE_IS_32BITS |
dword1(rv0) = 0; |
#endif /*!_DOUBLE_IS_32BITS*/ |
dval(rv) *= dval(rv0); |
#ifndef NO_ERRNO |
/* try to avoid the bug of testing an 8087 register value */ |
if (dword0(rv) == 0 && dword1(rv) == 0) |
ptr->_errno = ERANGE; |
#endif |
} |
#endif /* Avoid_Underflow */ |
#ifdef SET_INEXACT |
if (inexact && !(dword0(rv) & Exp_mask)) { |
/* set underflow bit */ |
dval(rv0) = 1e-300; |
dval(rv0) *= dval(rv0); |
} |
#endif |
retfree: |
Bfree(ptr,bb); |
Bfree(ptr,bd); |
Bfree(ptr,bs); |
Bfree(ptr,bd0); |
Bfree(ptr,delta); |
ret: |
if (se) |
*se = (char *)s; |
return sign ? -dval(rv) : dval(rv); |
} |
#ifndef _REENT_ONLY |
double |
_DEFUN (strtod, (s00, se), |
_CONST char *s00 _AND char **se) |
{ |
return _strtod_r (_REENT, s00, se); |
} |
float |
_DEFUN (strtof, (s00, se), |
_CONST char *s00 _AND |
char **se) |
{ |
double retval = _strtod_r (_REENT, s00, se); |
if (isnan (retval)) |
return nanf (NULL); |
return (float)retval; |
} |
#endif |
/contrib/sdk/sources/libc/stdlib/strtol.c |
---|
0,0 → 1,226 |
/* |
FUNCTION |
<<strtol>>---string to long |
INDEX |
strtol |
INDEX |
_strtol_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
long strtol(const char *<[s]>, char **<[ptr]>,int <[base]>); |
long _strtol_r(void *<[reent]>, |
const char *<[s]>, char **<[ptr]>,int <[base]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
long strtol (<[s]>, <[ptr]>, <[base]>) |
char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
long _strtol_r (<[reent]>, <[s]>, <[ptr]>, <[base]>) |
char *<[reent]>; |
char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
DESCRIPTION |
The function <<strtol>> converts the string <<*<[s]>>> to |
a <<long>>. First, it breaks down the string into three parts: |
leading whitespace, which is ignored; a subject string consisting |
of characters resembling an integer in the radix specified by <[base]>; |
and a trailing portion consisting of zero or more unparseable characters, |
and always including the terminating null character. Then, it attempts |
to convert the subject string into a <<long>> and returns the |
result. |
If the value of <[base]> is 0, the subject string is expected to look |
like a normal C integer constant: an optional sign, a possible `<<0x>>' |
indicating a hexadecimal base, and a number. If <[base]> is between |
2 and 36, the expected form of the subject is a sequence of letters |
and digits representing an integer in the radix specified by <[base]>, |
with an optional plus or minus sign. The letters <<a>>--<<z>> (or, |
equivalently, <<A>>--<<Z>>) are used to signify values from 10 to 35; |
only letters whose ascribed values are less than <[base]> are |
permitted. If <[base]> is 16, a leading <<0x>> is permitted. |
The subject sequence is the longest initial sequence of the input |
string that has the expected form, starting with the first |
non-whitespace character. If the string is empty or consists entirely |
of whitespace, or if the first non-whitespace character is not a |
permissible letter or digit, the subject string is empty. |
If the subject string is acceptable, and the value of <[base]> is zero, |
<<strtol>> attempts to determine the radix from the input string. A |
string with a leading <<0x>> is treated as a hexadecimal value; a string with |
a leading 0 and no <<x>> is treated as octal; all other strings are |
treated as decimal. If <[base]> is between 2 and 36, it is used as the |
conversion radix, as described above. If the subject string begins with |
a minus sign, the value is negated. Finally, a pointer to the first |
character past the converted subject string is stored in <[ptr]>, if |
<[ptr]> is not <<NULL>>. |
If the subject string is empty (or not in acceptable form), no conversion |
is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is |
not <<NULL>>). |
The alternate function <<_strtol_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<strtol>> returns the converted value, if any. If no conversion was |
made, 0 is returned. |
<<strtol>> returns <<LONG_MAX>> or <<LONG_MIN>> if the magnitude of |
the converted value is too large, and sets <<errno>> to <<ERANGE>>. |
PORTABILITY |
<<strtol>> is ANSI. |
No supporting OS subroutines are required. |
*/ |
/*- |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <_ansi.h> |
#include <limits.h> |
#include <ctype.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <reent.h> |
/* |
* Convert a string to a long integer. |
* |
* Ignores `locale' stuff. Assumes that the upper and lower case |
* alphabets and digits are each contiguous. |
*/ |
long |
_DEFUN (_strtol_r, (rptr, nptr, endptr, base), |
struct _reent *rptr _AND |
_CONST char *nptr _AND |
char **endptr _AND |
int base) |
{ |
register const unsigned char *s = (const unsigned char *)nptr; |
register unsigned long acc; |
register int c; |
register unsigned long cutoff; |
register int neg = 0, any, cutlim; |
/* |
* Skip white space and pick up leading +/- sign if any. |
* If base is 0, allow 0x for hex and 0 for octal, else |
* assume decimal; if base is already 16, allow 0x. |
*/ |
do { |
c = *s++; |
} while (isspace(c)); |
if (c == '-') { |
neg = 1; |
c = *s++; |
} else if (c == '+') |
c = *s++; |
if ((base == 0 || base == 16) && |
c == '0' && (*s == 'x' || *s == 'X')) { |
c = s[1]; |
s += 2; |
base = 16; |
} |
if (base == 0) |
base = c == '0' ? 8 : 10; |
/* |
* Compute the cutoff value between legal numbers and illegal |
* numbers. That is the largest legal value, divided by the |
* base. An input number that is greater than this value, if |
* followed by a legal input character, is too big. One that |
* is equal to this value may be valid or not; the limit |
* between valid and invalid numbers is then based on the last |
* digit. For instance, if the range for longs is |
* [-2147483648..2147483647] and the input base is 10, |
* cutoff will be set to 214748364 and cutlim to either |
* 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated |
* a value > 214748364, or equal but the next digit is > 7 (or 8), |
* the number is too big, and we will return a range error. |
* |
* Set any if any `digits' consumed; make it negative to indicate |
* overflow. |
*/ |
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; |
cutlim = cutoff % (unsigned long)base; |
cutoff /= (unsigned long)base; |
for (acc = 0, any = 0;; c = *s++) { |
if (isdigit(c)) |
c -= '0'; |
else if (isalpha(c)) |
c -= isupper(c) ? 'A' - 10 : 'a' - 10; |
else |
break; |
if (c >= base) |
break; |
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) |
any = -1; |
else { |
any = 1; |
acc *= base; |
acc += c; |
} |
} |
if (any < 0) { |
acc = neg ? LONG_MIN : LONG_MAX; |
rptr->_errno = ERANGE; |
} else if (neg) |
acc = -acc; |
if (endptr != 0) |
*endptr = (char *) (any ? (char *)s - 1 : nptr); |
return (acc); |
} |
#ifndef _REENT_ONLY |
long |
_DEFUN (strtol, (s, ptr, base), |
_CONST char *s _AND |
char **ptr _AND |
int base) |
{ |
return _strtol_r (_REENT, s, ptr, base); |
} |
#endif |
/contrib/sdk/sources/libc/stdlib/strtold.c |
---|
0,0 → 1,42 |
/* |
(C) Copyright IBM Corp. 2009 |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
* Redistributions of source code must retain the above copyright notice, |
this list of conditions and the following disclaimer. |
* Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
* Neither the name of IBM nor the names of its contributors may be |
used to endorse or promote products derived from this software without |
specific prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <stdlib.h> |
#include "local.h" |
/* On platforms where long double is as wide as double. */ |
#ifdef _LDBL_EQ_DBL |
long double |
strtold (const char *s00, char **se) |
{ |
return strtod(s00, se); |
} |
#endif /* _LDBL_EQ_DBL */ |
/contrib/sdk/sources/libc/stdlib/strtoll.c |
---|
0,0 → 1,138 |
/* |
FUNCTION |
<<strtoll>>---string to long long |
INDEX |
strtoll |
INDEX |
_strtoll_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
long long strtoll(const char *<[s]>, char **<[ptr]>,int <[base]>); |
long long _strtoll_r(void *<[reent]>, |
const char *<[s]>, char **<[ptr]>,int <[base]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
long long strtoll (<[s]>, <[ptr]>, <[base]>) |
const char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
long long _strtoll_r (<[reent]>, <[s]>, <[ptr]>, <[base]>) |
char *<[reent]>; |
const char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
DESCRIPTION |
The function <<strtoll>> converts the string <<*<[s]>>> to |
a <<long long>>. First, it breaks down the string into three parts: |
leading whitespace, which is ignored; a subject string consisting |
of characters resembling an integer in the radix specified by <[base]>; |
and a trailing portion consisting of zero or more unparseable characters, |
and always including the terminating null character. Then, it attempts |
to convert the subject string into a <<long long>> and returns the |
result. |
If the value of <[base]> is 0, the subject string is expected to look |
like a normal C integer constant: an optional sign, a possible `<<0x>>' |
indicating a hexadecimal base, and a number. If <[base]> is between |
2 and 36, the expected form of the subject is a sequence of letters |
and digits representing an integer in the radix specified by <[base]>, |
with an optional plus or minus sign. The letters <<a>>--<<z>> (or, |
equivalently, <<A>>--<<Z>>) are used to signify values from 10 to 35; |
only letters whose ascribed values are less than <[base]> are |
permitted. If <[base]> is 16, a leading <<0x>> is permitted. |
The subject sequence is the longest initial sequence of the input |
string that has the expected form, starting with the first |
non-whitespace character. If the string is empty or consists entirely |
of whitespace, or if the first non-whitespace character is not a |
permissible letter or digit, the subject string is empty. |
If the subject string is acceptable, and the value of <[base]> is zero, |
<<strtoll>> attempts to determine the radix from the input string. A |
string with a leading <<0x>> is treated as a hexadecimal value; a string with |
a leading 0 and no <<x>> is treated as octal; all other strings are |
treated as decimal. If <[base]> is between 2 and 36, it is used as the |
conversion radix, as described above. If the subject string begins with |
a minus sign, the value is negated. Finally, a pointer to the first |
character past the converted subject string is stored in <[ptr]>, if |
<[ptr]> is not <<NULL>>. |
If the subject string is empty (or not in acceptable form), no conversion |
is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is |
not <<NULL>>). |
The alternate function <<_strtoll_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<strtoll>> returns the converted value, if any. If no conversion was |
made, 0 is returned. |
<<strtoll>> returns <<LONG_LONG_MAX>> or <<LONG_LONG_MIN>> if the magnitude of |
the converted value is too large, and sets <<errno>> to <<ERANGE>>. |
PORTABILITY |
<<strtoll>> is ANSI. |
No supporting OS subroutines are required. |
*/ |
/*- |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <_ansi.h> |
#include <limits.h> |
#include <ctype.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <reent.h> |
#ifndef _REENT_ONLY |
long long |
_DEFUN (strtoll, (s, ptr, base), |
_CONST char *s _AND |
char **ptr _AND |
int base) |
{ |
return _strtoll_r (_REENT, s, ptr, base); |
} |
#endif |
/contrib/sdk/sources/libc/stdlib/strtoll_r.c |
---|
0,0 → 1,140 |
/* |
This code is based on strtoul.c which has the following copyright. |
It is used to convert a string into a signed long long. |
long long _strtoll_r (struct _reent *rptr, const char *s, |
char **ptr, int base); |
*/ |
/*- |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#ifdef __GNUC__ |
#define _GNU_SOURCE |
#include <_ansi.h> |
#include <limits.h> |
#include <ctype.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <reent.h> |
/* |
* Convert a string to a long long integer. |
* |
* Ignores `locale' stuff. Assumes that the upper and lower case |
* alphabets and digits are each contiguous. |
*/ |
long long |
_DEFUN (_strtoll_r, (rptr, nptr, endptr, base), |
struct _reent *rptr _AND |
_CONST char *nptr _AND |
char **endptr _AND |
int base) |
{ |
register const unsigned char *s = (const unsigned char *)nptr; |
register unsigned long long acc; |
register int c; |
register unsigned long long cutoff; |
register int neg = 0, any, cutlim; |
/* |
* Skip white space and pick up leading +/- sign if any. |
* If base is 0, allow 0x for hex and 0 for octal, else |
* assume decimal; if base is already 16, allow 0x. |
*/ |
do { |
c = *s++; |
} while (isspace(c)); |
if (c == '-') { |
neg = 1; |
c = *s++; |
} else if (c == '+') |
c = *s++; |
if ((base == 0 || base == 16) && |
c == '0' && (*s == 'x' || *s == 'X')) { |
c = s[1]; |
s += 2; |
base = 16; |
} |
if (base == 0) |
base = c == '0' ? 8 : 10; |
/* |
* Compute the cutoff value between legal numbers and illegal |
* numbers. That is the largest legal value, divided by the |
* base. An input number that is greater than this value, if |
* followed by a legal input character, is too big. One that |
* is equal to this value may be valid or not; the limit |
* between valid and invalid numbers is then based on the last |
* digit. For instance, if the range for longs is |
* [-2147483648..2147483647] and the input base is 10, |
* cutoff will be set to 214748364 and cutlim to either |
* 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated |
* a value > 214748364, or equal but the next digit is > 7 (or 8), |
* the number is too big, and we will return a range error. |
* |
* Set any if any `digits' consumed; make it negative to indicate |
* overflow. |
*/ |
cutoff = neg ? -(unsigned long long)LONG_LONG_MIN : LONG_LONG_MAX; |
cutlim = cutoff % (unsigned long long)base; |
cutoff /= (unsigned long long)base; |
for (acc = 0, any = 0;; c = *s++) { |
if (isdigit(c)) |
c -= '0'; |
else if (isalpha(c)) |
c -= isupper(c) ? 'A' - 10 : 'a' - 10; |
else |
break; |
if (c >= base) |
break; |
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) |
any = -1; |
else { |
any = 1; |
acc *= base; |
acc += c; |
} |
} |
if (any < 0) { |
acc = neg ? LONG_LONG_MIN : LONG_LONG_MAX; |
rptr->_errno = ERANGE; |
} else if (neg) |
acc = -acc; |
if (endptr != 0) |
*endptr = (char *) (any ? (char *)s - 1 : nptr); |
return (acc); |
} |
#endif /* __GNUC__ */ |
/contrib/sdk/sources/libc/stdlib/strtoul.c |
---|
0,0 → 1,206 |
/* |
FUNCTION |
<<strtoul>>---string to unsigned long |
INDEX |
strtoul |
INDEX |
_strtoul_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
unsigned long strtoul(const char *<[s]>, char **<[ptr]>, |
int <[base]>); |
unsigned long _strtoul_r(void *<[reent]>, const char *<[s]>, |
char **<[ptr]>, int <[base]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
unsigned long strtoul(<[s]>, <[ptr]>, <[base]>) |
char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
unsigned long _strtoul_r(<[reent]>, <[s]>, <[ptr]>, <[base]>) |
char *<[reent]>; |
char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
DESCRIPTION |
The function <<strtoul>> converts the string <<*<[s]>>> to |
an <<unsigned long>>. First, it breaks down the string into three parts: |
leading whitespace, which is ignored; a subject string consisting |
of the digits meaningful in the radix specified by <[base]> |
(for example, <<0>> through <<7>> if the value of <[base]> is 8); |
and a trailing portion consisting of one or more unparseable characters, |
which always includes the terminating null character. Then, it attempts |
to convert the subject string into an unsigned long integer, and returns the |
result. |
If the value of <[base]> is zero, the subject string is expected to look |
like a normal C integer constant (save that no optional sign is permitted): |
a possible <<0x>> indicating hexadecimal radix, and a number. |
If <[base]> is between 2 and 36, the expected form of the subject is a |
sequence of digits (which may include letters, depending on the |
base) representing an integer in the radix specified by <[base]>. |
The letters <<a>>--<<z>> (or <<A>>--<<Z>>) are used as digits valued from |
10 to 35. If <[base]> is 16, a leading <<0x>> is permitted. |
The subject sequence is the longest initial sequence of the input |
string that has the expected form, starting with the first |
non-whitespace character. If the string is empty or consists entirely |
of whitespace, or if the first non-whitespace character is not a |
permissible digit, the subject string is empty. |
If the subject string is acceptable, and the value of <[base]> is zero, |
<<strtoul>> attempts to determine the radix from the input string. A |
string with a leading <<0x>> is treated as a hexadecimal value; a string with |
a leading <<0>> and no <<x>> is treated as octal; all other strings are |
treated as decimal. If <[base]> is between 2 and 36, it is used as the |
conversion radix, as described above. Finally, a pointer to the first |
character past the converted subject string is stored in <[ptr]>, if |
<[ptr]> is not <<NULL>>. |
If the subject string is empty (that is, if <<*>><[s]> does not start |
with a substring in acceptable form), no conversion |
is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is |
not <<NULL>>). |
The alternate function <<_strtoul_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<strtoul>> returns the converted value, if any. If no conversion was |
made, <<0>> is returned. |
<<strtoul>> returns <<ULONG_MAX>> if the magnitude of the converted |
value is too large, and sets <<errno>> to <<ERANGE>>. |
PORTABILITY |
<<strtoul>> is ANSI. |
<<strtoul>> requires no supporting OS subroutines. |
*/ |
/* |
* Copyright (c) 1990 Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <_ansi.h> |
#include <limits.h> |
#include <ctype.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <reent.h> |
/* |
* Convert a string to an unsigned long integer. |
* |
* Ignores `locale' stuff. Assumes that the upper and lower case |
* alphabets and digits are each contiguous. |
*/ |
unsigned long |
_DEFUN (_strtoul_r, (rptr, nptr, endptr, base), |
struct _reent *rptr _AND |
_CONST char *nptr _AND |
char **endptr _AND |
int base) |
{ |
register const unsigned char *s = (const unsigned char *)nptr; |
register unsigned long acc; |
register int c; |
register unsigned long cutoff; |
register int neg = 0, any, cutlim; |
/* |
* See strtol for comments as to the logic used. |
*/ |
do { |
c = *s++; |
} while (isspace(c)); |
if (c == '-') { |
neg = 1; |
c = *s++; |
} else if (c == '+') |
c = *s++; |
if ((base == 0 || base == 16) && |
c == '0' && (*s == 'x' || *s == 'X')) { |
c = s[1]; |
s += 2; |
base = 16; |
} |
if (base == 0) |
base = c == '0' ? 8 : 10; |
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; |
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; |
for (acc = 0, any = 0;; c = *s++) { |
if (isdigit(c)) |
c -= '0'; |
else if (isalpha(c)) |
c -= isupper(c) ? 'A' - 10 : 'a' - 10; |
else |
break; |
if (c >= base) |
break; |
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) |
any = -1; |
else { |
any = 1; |
acc *= base; |
acc += c; |
} |
} |
if (any < 0) { |
acc = ULONG_MAX; |
rptr->_errno = ERANGE; |
} else if (neg) |
acc = -acc; |
if (endptr != 0) |
*endptr = (char *) (any ? (char *)s - 1 : nptr); |
return (acc); |
} |
#ifndef _REENT_ONLY |
unsigned long |
_DEFUN (strtoul, (s, ptr, base), |
_CONST char *s _AND |
char **ptr _AND |
int base) |
{ |
return _strtoul_r (_REENT, s, ptr, base); |
} |
#endif |
/contrib/sdk/sources/libc/stdlib/strtoull.c |
---|
0,0 → 1,139 |
/* |
FUNCTION |
<<strtoull>>---string to unsigned long long |
INDEX |
strtoull |
INDEX |
_strtoull_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
unsigned long long strtoull(const char *<[s]>, char **<[ptr]>, |
int <[base]>); |
unsigned long long _strtoull_r(void *<[reent]>, const char *<[s]>, |
char **<[ptr]>, int <[base]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
unsigned long long strtoull(<[s]>, <[ptr]>, <[base]>) |
char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
unsigned long long _strtoull_r(<[reent]>, <[s]>, <[ptr]>, <[base]>) |
char *<[reent]>; |
char *<[s]>; |
char **<[ptr]>; |
int <[base]>; |
DESCRIPTION |
The function <<strtoull>> converts the string <<*<[s]>>> to |
an <<unsigned long long>>. First, it breaks down the string into three parts: |
leading whitespace, which is ignored; a subject string consisting |
of the digits meaningful in the radix specified by <[base]> |
(for example, <<0>> through <<7>> if the value of <[base]> is 8); |
and a trailing portion consisting of one or more unparseable characters, |
which always includes the terminating null character. Then, it attempts |
to convert the subject string into an unsigned long long integer, and returns the |
result. |
If the value of <[base]> is zero, the subject string is expected to look |
like a normal C integer constant (save that no optional sign is permitted): |
a possible <<0x>> indicating hexadecimal radix, and a number. |
If <[base]> is between 2 and 36, the expected form of the subject is a |
sequence of digits (which may include letters, depending on the |
base) representing an integer in the radix specified by <[base]>. |
The letters <<a>>--<<z>> (or <<A>>--<<Z>>) are used as digits valued from |
10 to 35. If <[base]> is 16, a leading <<0x>> is permitted. |
The subject sequence is the longest initial sequence of the input |
string that has the expected form, starting with the first |
non-whitespace character. If the string is empty or consists entirely |
of whitespace, or if the first non-whitespace character is not a |
permissible digit, the subject string is empty. |
If the subject string is acceptable, and the value of <[base]> is zero, |
<<strtoull>> attempts to determine the radix from the input string. A |
string with a leading <<0x>> is treated as a hexadecimal value; a string with |
a leading <<0>> and no <<x>> is treated as octal; all other strings are |
treated as decimal. If <[base]> is between 2 and 36, it is used as the |
conversion radix, as described above. Finally, a pointer to the first |
character past the converted subject string is stored in <[ptr]>, if |
<[ptr]> is not <<NULL>>. |
If the subject string is empty (that is, if <<*>><[s]> does not start |
with a substring in acceptable form), no conversion |
is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is |
not <<NULL>>). |
The alternate function <<_strtoull_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<strtoull>> returns the converted value, if any. If no conversion was |
made, <<0>> is returned. |
<<strtoull>> returns <<ULONG_LONG_MAX>> if the magnitude of the converted |
value is too large, and sets <<errno>> to <<ERANGE>>. |
PORTABILITY |
<<strtoull>> is ANSI. |
<<strtoull>> requires no supporting OS subroutines. |
*/ |
/* |
* Copyright (c) 1990 Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <_ansi.h> |
#include <limits.h> |
#include <ctype.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <reent.h> |
#ifndef _REENT_ONLY |
unsigned long long |
_DEFUN (strtoull, (s, ptr, base), |
_CONST char *s _AND |
char **ptr _AND |
int base) |
{ |
return _strtoull_r (_REENT, s, ptr, base); |
} |
#endif |
/contrib/sdk/sources/libc/stdlib/strtoull_r.c |
---|
0,0 → 1,120 |
/* |
This code is based on strtoul.c which has the following copyright. |
It is used to convert a string into an unsigned long long. |
long long _strtoull_r (struct _reent *rptr, const char *s, |
char **ptr, int base); |
*/ |
/* |
* Copyright (c) 1990 Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#ifdef __GNUC__ |
#define _GNU_SOURCE |
#include <_ansi.h> |
#include <limits.h> |
#include <ctype.h> |
#include <errno.h> |
#include <stdlib.h> |
#include <reent.h> |
/* |
* Convert a string to an unsigned long long integer. |
* |
* Ignores `locale' stuff. Assumes that the upper and lower case |
* alphabets and digits are each contiguous. |
*/ |
unsigned long long |
_DEFUN (_strtoull_r, (rptr, nptr, endptr, base), |
struct _reent *rptr _AND |
_CONST char *nptr _AND |
char **endptr _AND |
int base) |
{ |
register const unsigned char *s = (const unsigned char *)nptr; |
register unsigned long long acc; |
register int c; |
register unsigned long long cutoff; |
register int neg = 0, any, cutlim; |
/* |
* See strtol for comments as to the logic used. |
*/ |
do { |
c = *s++; |
} while (isspace(c)); |
if (c == '-') { |
neg = 1; |
c = *s++; |
} else if (c == '+') |
c = *s++; |
if ((base == 0 || base == 16) && |
c == '0' && (*s == 'x' || *s == 'X')) { |
c = s[1]; |
s += 2; |
base = 16; |
} |
if (base == 0) |
base = c == '0' ? 8 : 10; |
cutoff = (unsigned long long)ULONG_LONG_MAX / (unsigned long long)base; |
cutlim = (unsigned long long)ULONG_LONG_MAX % (unsigned long long)base; |
for (acc = 0, any = 0;; c = *s++) { |
if (isdigit(c)) |
c -= '0'; |
else if (isalpha(c)) |
c -= isupper(c) ? 'A' - 10 : 'a' - 10; |
else |
break; |
if (c >= base) |
break; |
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) |
any = -1; |
else { |
any = 1; |
acc *= base; |
acc += c; |
} |
} |
if (any < 0) { |
acc = ULONG_LONG_MAX; |
rptr->_errno = ERANGE; |
} else if (neg) |
acc = -acc; |
if (endptr != 0) |
*endptr = (char *) (any ? (char *)s - 1 : nptr); |
return (acc); |
} |
#endif /* __GNUC__ */ |
/contrib/sdk/sources/libc/stdlib/system.c |
---|
0,0 → 1,85 |
/* |
FUNCTION |
<<system>>---execute command string |
INDEX |
system |
INDEX |
_system_r |
ANSI_SYNOPSIS |
#include <stdlib.h> |
int system(char *<[s]>); |
int _system_r(void *<[reent]>, char *<[s]>); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
int system(<[s]>) |
char *<[s]>; |
int _system_r(<[reent]>, <[s]>) |
char *<[reent]>; |
char *<[s]>; |
DESCRIPTION |
Use <<system>> to pass a command string <<*<[s]>>> to <</bin/sh>> on |
your system, and wait for it to finish executing. |
Use ``<<system(NULL)>>'' to test whether your system has <</bin/sh>> |
available. |
The alternate function <<_system_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<system(NULL)>> returns a non-zero value if <</bin/sh>> is available, and |
<<0>> if it is not. |
With a command argument, the result of <<system>> is the exit status |
returned by <</bin/sh>>. |
PORTABILITY |
ANSI C requires <<system>>, but leaves the nature and effects of a |
command processor undefined. ANSI C does, however, specify that |
<<system(NULL)>> return zero or nonzero to report on the existence of |
a command processor. |
POSIX.2 requires <<system>>, and requires that it invoke a <<sh>>. |
Where <<sh>> is found is left unspecified. |
Supporting OS subroutines required: <<_exit>>, <<_execve>>, <<_fork_r>>, |
<<_wait_r>>. |
*/ |
#include <_ansi.h> |
#include <errno.h> |
#include <stddef.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <reent.h> |
int |
_DEFUN(_system_r, (ptr, s), |
struct _reent *ptr _AND |
_CONST char *s) |
{ |
if (s == NULL) |
return 0; |
errno = ENOSYS; |
return -1; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(system, (s), |
_CONST char *s) |
{ |
return _system_r (_REENT, s); |
} |
#endif |
/contrib/sdk/sources/libc/stdlib/wcrtomb.c |
---|
0,0 → 1,78 |
#include <reent.h> |
#include <newlib.h> |
#include <wchar.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <errno.h> |
#include "local.h" |
size_t |
_DEFUN (_wcrtomb_r, (ptr, s, wc, ps), |
struct _reent *ptr _AND |
char *s _AND |
wchar_t wc _AND |
mbstate_t *ps) |
{ |
int retval = 0; |
char buf[10]; |
#ifdef _MB_CAPABLE |
if (ps == NULL) |
{ |
_REENT_CHECK_MISC(ptr); |
ps = &(_REENT_WCRTOMB_STATE(ptr)); |
} |
#endif |
if (s == NULL) |
retval = __wctomb (ptr, buf, L'\0', __locale_charset (), ps); |
else |
retval = __wctomb (ptr, s, wc, __locale_charset (), ps); |
if (retval == -1) |
{ |
ps->__count = 0; |
ptr->_errno = EILSEQ; |
return (size_t)(-1); |
} |
else |
return (size_t)retval; |
} |
#ifndef _REENT_ONLY |
size_t |
_DEFUN (wcrtomb, (s, wc, ps), |
char *s _AND |
wchar_t wc _AND |
mbstate_t *ps) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
return _wcrtomb_r (_REENT, s, wc, ps); |
#else |
int retval = 0; |
char buf[10]; |
#ifdef _MB_CAPABLE |
if (ps == NULL) |
{ |
_REENT_CHECK_MISC(_REENT); |
ps = &(_REENT_WCRTOMB_STATE(_REENT)); |
} |
#endif |
if (s == NULL) |
retval = __wctomb (_REENT, buf, L'\0', __locale_charset (), ps); |
else |
retval = __wctomb (_REENT, s, wc, __locale_charset (), ps); |
if (retval == -1) |
{ |
ps->__count = 0; |
_REENT->_errno = EILSEQ; |
return (size_t)(-1); |
} |
else |
return (size_t)retval; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdlib/wctomb_r.c |
---|
0,0 → 1,376 |
#include <errno.h> |
#include <stdlib.h> |
#include <string.h> |
#include <wchar.h> |
#include <locale.h> |
#include "mbctype.h" |
#include "local.h" |
int (*__wctomb) (struct _reent *, char *, wchar_t, const char *charset, |
mbstate_t *) |
#ifdef __CYGWIN__ |
/* Cygwin starts up in UTF-8 mode. */ |
= __utf8_wctomb; |
#else |
= __ascii_wctomb; |
#endif |
int |
_DEFUN (_wctomb_r, (r, s, wchar, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
mbstate_t *state) |
{ |
return __wctomb (r, s, _wchar, __locale_charset (), state); |
} |
int |
_DEFUN (__ascii_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
/* Avoids compiler warnings about comparisons that are always false |
due to limited range when sizeof(wchar_t) is 2 but sizeof(wint_t) |
is 4, as is the case on cygwin. */ |
wint_t wchar = _wchar; |
if (s == NULL) |
return 0; |
#ifdef __CYGWIN__ |
if ((size_t)wchar >= 0x80) |
#else |
if ((size_t)wchar >= 0x100) |
#endif |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
*s = (char) wchar; |
return 1; |
} |
#ifdef _MB_CAPABLE |
/* for some conversions, we use the __count field as a place to store a state value */ |
#define __state __count |
int |
_DEFUN (__utf8_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
int ret = 0; |
if (s == NULL) |
return 0; /* UTF-8 encoding is not state-dependent */ |
if (sizeof (wchar_t) == 2 && state->__count == -4 |
&& (wchar < 0xdc00 || wchar >= 0xdfff)) |
{ |
/* There's a leftover lone high surrogate. Write out the CESU-8 value |
of the surrogate and proceed to convert the given character. Note |
to return extra 3 bytes. */ |
wchar_t tmp; |
tmp = (state->__value.__wchb[0] << 16 | state->__value.__wchb[1] << 8) |
- 0x10000 >> 10 | 0xd80d; |
*s++ = 0xe0 | ((tmp & 0xf000) >> 12); |
*s++ = 0x80 | ((tmp & 0xfc0) >> 6); |
*s++ = 0x80 | (tmp & 0x3f); |
state->__count = 0; |
ret = 3; |
} |
if (wchar <= 0x7f) |
{ |
*s = wchar; |
return ret + 1; |
} |
if (wchar >= 0x80 && wchar <= 0x7ff) |
{ |
*s++ = 0xc0 | ((wchar & 0x7c0) >> 6); |
*s = 0x80 | (wchar & 0x3f); |
return ret + 2; |
} |
if (wchar >= 0x800 && wchar <= 0xffff) |
{ |
/* No UTF-16 surrogate handling in UCS-4 */ |
if (sizeof (wchar_t) == 2 && wchar >= 0xd800 && wchar <= 0xdfff) |
{ |
wint_t tmp; |
if (wchar <= 0xdbff) |
{ |
/* First half of a surrogate pair. Store the state and |
return ret + 0. */ |
tmp = ((wchar & 0x3ff) << 10) + 0x10000; |
state->__value.__wchb[0] = (tmp >> 16) & 0xff; |
state->__value.__wchb[1] = (tmp >> 8) & 0xff; |
state->__count = -4; |
*s = (0xf0 | ((tmp & 0x1c0000) >> 18)); |
return ret; |
} |
if (state->__count == -4) |
{ |
/* Second half of a surrogate pair. Reconstruct the full |
Unicode value and return the trailing three bytes of the |
UTF-8 character. */ |
tmp = (state->__value.__wchb[0] << 16) |
| (state->__value.__wchb[1] << 8) |
| (wchar & 0x3ff); |
state->__count = 0; |
*s++ = 0xf0 | ((tmp & 0x1c0000) >> 18); |
*s++ = 0x80 | ((tmp & 0x3f000) >> 12); |
*s++ = 0x80 | ((tmp & 0xfc0) >> 6); |
*s = 0x80 | (tmp & 0x3f); |
return 4; |
} |
/* Otherwise translate into CESU-8 value. */ |
} |
*s++ = 0xe0 | ((wchar & 0xf000) >> 12); |
*s++ = 0x80 | ((wchar & 0xfc0) >> 6); |
*s = 0x80 | (wchar & 0x3f); |
return ret + 3; |
} |
if (wchar >= 0x10000 && wchar <= 0x10ffff) |
{ |
*s++ = 0xf0 | ((wchar & 0x1c0000) >> 18); |
*s++ = 0x80 | ((wchar & 0x3f000) >> 12); |
*s++ = 0x80 | ((wchar & 0xfc0) >> 6); |
*s = 0x80 | (wchar & 0x3f); |
return 4; |
} |
r->_errno = EILSEQ; |
return -1; |
} |
/* Cygwin defines its own doublebyte charset conversion functions |
because the underlying OS requires wchar_t == UTF-16. */ |
#ifndef __CYGWIN__ |
int |
_DEFUN (__sjis_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
unsigned char char2 = (unsigned char)wchar; |
unsigned char char1 = (unsigned char)(wchar >> 8); |
if (s == NULL) |
return 0; /* not state-dependent */ |
if (char1 != 0x00) |
{ |
/* first byte is non-zero..validate multi-byte char */ |
if (_issjis1(char1) && _issjis2(char2)) |
{ |
*s++ = (char)char1; |
*s = (char)char2; |
return 2; |
} |
else |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
} |
*s = (char) wchar; |
return 1; |
} |
int |
_DEFUN (__eucjp_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
unsigned char char2 = (unsigned char)wchar; |
unsigned char char1 = (unsigned char)(wchar >> 8); |
if (s == NULL) |
return 0; /* not state-dependent */ |
if (char1 != 0x00) |
{ |
/* first byte is non-zero..validate multi-byte char */ |
if (_iseucjp1 (char1) && _iseucjp2 (char2)) |
{ |
*s++ = (char)char1; |
*s = (char)char2; |
return 2; |
} |
else if (_iseucjp2 (char1) && _iseucjp2 (char2 | 0x80)) |
{ |
*s++ = (char)0x8f; |
*s++ = (char)char1; |
*s = (char)(char2 | 0x80); |
return 3; |
} |
else |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
} |
*s = (char) wchar; |
return 1; |
} |
int |
_DEFUN (__jis_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
int cnt = 0; |
unsigned char char2 = (unsigned char)wchar; |
unsigned char char1 = (unsigned char)(wchar >> 8); |
if (s == NULL) |
return 1; /* state-dependent */ |
if (char1 != 0x00) |
{ |
/* first byte is non-zero..validate multi-byte char */ |
if (_isjis (char1) && _isjis (char2)) |
{ |
if (state->__state == 0) |
{ |
/* must switch from ASCII to JIS state */ |
state->__state = 1; |
*s++ = ESC_CHAR; |
*s++ = '$'; |
*s++ = 'B'; |
cnt = 3; |
} |
*s++ = (char)char1; |
*s = (char)char2; |
return cnt + 2; |
} |
r->_errno = EILSEQ; |
return -1; |
} |
if (state->__state != 0) |
{ |
/* must switch from JIS to ASCII state */ |
state->__state = 0; |
*s++ = ESC_CHAR; |
*s++ = '('; |
*s++ = 'B'; |
cnt = 3; |
} |
*s = (char)char2; |
return cnt + 1; |
} |
#endif /* !__CYGWIN__ */ |
#ifdef _MB_EXTENDED_CHARSETS_ISO |
int |
_DEFUN (__iso_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
if (s == NULL) |
return 0; |
/* wchars <= 0x9f translate to all ISO charsets directly. */ |
if (wchar >= 0xa0) |
{ |
int iso_idx = __iso_8859_index (charset + 9); |
if (iso_idx >= 0) |
{ |
unsigned char mb; |
if (s == NULL) |
return 0; |
for (mb = 0; mb < 0x60; ++mb) |
if (__iso_8859_conv[iso_idx][mb] == wchar) |
{ |
*s = (char) (mb + 0xa0); |
return 1; |
} |
r->_errno = EILSEQ; |
return -1; |
} |
} |
if ((size_t)wchar >= 0x100) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
*s = (char) wchar; |
return 1; |
} |
#endif /* _MB_EXTENDED_CHARSETS_ISO */ |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
int |
_DEFUN (__cp_wctomb, (r, s, wchar, charset, state), |
struct _reent *r _AND |
char *s _AND |
wchar_t _wchar _AND |
const char *charset _AND |
mbstate_t *state) |
{ |
wint_t wchar = _wchar; |
if (s == NULL) |
return 0; |
if (wchar >= 0x80) |
{ |
int cp_idx = __cp_index (charset + 2); |
if (cp_idx >= 0) |
{ |
unsigned char mb; |
if (s == NULL) |
return 0; |
for (mb = 0; mb < 0x80; ++mb) |
if (__cp_conv[cp_idx][mb] == wchar) |
{ |
*s = (char) (mb + 0x80); |
return 1; |
} |
r->_errno = EILSEQ; |
return -1; |
} |
} |
if ((size_t)wchar >= 0x100) |
{ |
r->_errno = EILSEQ; |
return -1; |
} |
*s = (char) wchar; |
return 1; |
} |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
#endif /* _MB_CAPABLE */ |
/contrib/sdk/sources/libc/include/sys/kos_io.h |
---|
0,0 → 1,88 |
#ifndef __KOS_IO_H__ |
#define __KOS_IO_H__ |
#pragma pack(push, 1) |
typedef struct |
{ |
char sec; |
char min; |
char hour; |
char rsv; |
}detime_t; |
typedef struct |
{ |
char day; |
char month; |
short year; |
}dedate_t; |
typedef struct |
{ |
unsigned attr; |
unsigned flags; |
union |
{ |
detime_t ctime; |
unsigned cr_time; |
}; |
union |
{ |
dedate_t cdate; |
unsigned cr_date; |
}; |
union |
{ |
detime_t atime; |
unsigned acc_time; |
}; |
union |
{ |
dedate_t adate; |
unsigned acc_date; |
}; |
union |
{ |
detime_t mtime; |
unsigned mod_time; |
}; |
union |
{ |
dedate_t mdate; |
unsigned mod_date; |
}; |
unsigned size; |
unsigned size_high; |
} fileinfo_t; |
#pragma pack(pop) |
int create_file(const char *path); |
int get_fileinfo(const char *path, fileinfo_t *info); |
int read_file(const char *path, void *buff, |
size_t offset, size_t count, size_t *reads); |
int write_file(const char *path,const void *buff, |
size_t offset, size_t count, size_t *writes); |
int set_file_size(const char *path, unsigned size); |
void *load_file(const char *path, size_t *len); |
void unpack(void* packed_data, void* unpacked_data) __attribute__((stdcall)) ; |
static inline int user_free(void *mem) |
{ |
int val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(12),"c"(mem)); |
return val; |
} |
static inline void set_cwd(const char* cwd) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(30),"b"(1),"c"(cwd)); |
}; |
#endif |
/contrib/sdk/sources/libc/include/sys/_default_fcntl.h |
---|
0,0 → 1,213 |
#ifndef _SYS__DEFAULT_FCNTL_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _SYS__DEFAULT_FCNTL_H_ |
#include <_ansi.h> |
#define _FOPEN (-1) /* from sys/file.h, kernel use only */ |
#define _FREAD 0x0001 /* read enabled */ |
#define _FWRITE 0x0002 /* write enabled */ |
#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */ |
#define _FMARK 0x0010 /* internal; mark during gc() */ |
#define _FDEFER 0x0020 /* internal; defer for next gc pass */ |
#define _FASYNC 0x0040 /* signal pgrp when data ready */ |
#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */ |
#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */ |
#define _FCREAT 0x0200 /* open with file create */ |
#define _FTRUNC 0x0400 /* open with truncation */ |
#define _FEXCL 0x0800 /* error on open if file exists */ |
#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */ |
#define _FSYNC 0x2000 /* do all writes synchronously */ |
#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ |
#define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */ |
#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */ |
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) |
/* |
* Flag values for open(2) and fcntl(2) |
* The kernel adds 1 to the open modes to turn it into some |
* combination of FREAD and FWRITE. |
*/ |
#define O_RDONLY 0 /* +1 == FREAD */ |
#define O_WRONLY 1 /* +1 == FWRITE */ |
#define O_RDWR 2 /* +1 == FREAD|FWRITE */ |
#define O_APPEND _FAPPEND |
#define O_CREAT _FCREAT |
#define O_TRUNC _FTRUNC |
#define O_EXCL _FEXCL |
#define O_SYNC _FSYNC |
/* O_NDELAY _FNDELAY set in include/fcntl.h */ |
/* O_NDELAY _FNBIO set in include/fcntl.h */ |
#define O_NONBLOCK _FNONBLOCK |
#define O_NOCTTY _FNOCTTY |
#define _FBINARY 0x10000 |
#define _FTEXT 0x20000 |
#define _FNOINHERIT 0x40000 |
#define O_BINARY _FBINARY |
#define O_TEXT _FTEXT |
#define O_NOINHERIT _FNOINHERIT |
/* For machines which care - */ |
#if defined (_WIN32) || defined (__CYGWIN__) |
#define _FBINARY 0x10000 |
#define _FTEXT 0x20000 |
#define _FNOINHERIT 0x40000 |
#define O_BINARY _FBINARY |
#define O_TEXT _FTEXT |
#define O_NOINHERIT _FNOINHERIT |
/* O_CLOEXEC is the Linux equivalent to O_NOINHERIT */ |
#define O_CLOEXEC _FNOINHERIT |
/* The windows header files define versions with a leading underscore. */ |
#define _O_RDONLY O_RDONLY |
#define _O_WRONLY O_WRONLY |
#define _O_RDWR O_RDWR |
#define _O_APPEND O_APPEND |
#define _O_CREAT O_CREAT |
#define _O_TRUNC O_TRUNC |
#define _O_EXCL O_EXCL |
#define _O_TEXT O_TEXT |
#define _O_BINARY O_BINARY |
#define _O_RAW O_BINARY |
#define _O_NOINHERIT O_NOINHERIT |
#endif |
#ifndef _POSIX_SOURCE |
/* |
* Flags that work for fcntl(fd, F_SETFL, FXXXX) |
*/ |
#define FAPPEND _FAPPEND |
#define FSYNC _FSYNC |
#define FASYNC _FASYNC |
#define FNBIO _FNBIO |
#define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */ |
#define FNDELAY _FNDELAY |
/* |
* Flags that are disallowed for fcntl's (FCNTLCANT); |
* used for opens, internal state, or locking. |
*/ |
#define FREAD _FREAD |
#define FWRITE _FWRITE |
#define FMARK _FMARK |
#define FDEFER _FDEFER |
#define FSHLOCK _FSHLOCK |
#define FEXLOCK _FEXLOCK |
/* |
* The rest of the flags, used only for opens |
*/ |
#define FOPEN _FOPEN |
#define FCREAT _FCREAT |
#define FTRUNC _FTRUNC |
#define FEXCL _FEXCL |
#define FNOCTTY _FNOCTTY |
#endif /* !_POSIX_SOURCE */ |
/* XXX close on exec request; must match UF_EXCLOSE in user.h */ |
#define FD_CLOEXEC 1 /* posix */ |
/* fcntl(2) requests */ |
#define F_DUPFD 0 /* Duplicate fildes */ |
#define F_GETFD 1 /* Get fildes flags (close on exec) */ |
#define F_SETFD 2 /* Set fildes flags (close on exec) */ |
#define F_GETFL 3 /* Get file flags */ |
#define F_SETFL 4 /* Set file flags */ |
#ifndef _POSIX_SOURCE |
#define F_GETOWN 5 /* Get owner - for ASYNC */ |
#define F_SETOWN 6 /* Set owner - for ASYNC */ |
#endif /* !_POSIX_SOURCE */ |
#define F_GETLK 7 /* Get record-locking information */ |
#define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */ |
#define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */ |
#ifndef _POSIX_SOURCE |
#define F_RGETLK 10 /* Test a remote lock to see if it is blocked */ |
#define F_RSETLK 11 /* Set or unlock a remote lock */ |
#define F_CNVT 12 /* Convert a fhandle to an open fd */ |
#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */ |
#endif /* !_POSIX_SOURCE */ |
#ifdef __CYGWIN__ |
#define F_DUPFD_CLOEXEC 14 /* As F_DUPFD, but set close-on-exec flag */ |
#endif |
/* fcntl(2) flags (l_type field of flock structure) */ |
#define F_RDLCK 1 /* read lock */ |
#define F_WRLCK 2 /* write lock */ |
#define F_UNLCK 3 /* remove lock(s) */ |
#ifndef _POSIX_SOURCE |
#define F_UNLKSYS 4 /* remove remote locks for a given system */ |
#endif /* !_POSIX_SOURCE */ |
#ifdef __CYGWIN__ |
/* Special descriptor value to denote the cwd in calls to openat(2) etc. */ |
#define AT_FDCWD -2 |
/* Flag values for faccessat2) et al. */ |
#define AT_EACCESS 1 |
#define AT_SYMLINK_NOFOLLOW 2 |
#define AT_SYMLINK_FOLLOW 4 |
#define AT_REMOVEDIR 8 |
#endif |
/*#include <sys/stdtypes.h>*/ |
#ifndef __CYGWIN__ |
/* file segment locking set data type - information passed to system by user */ |
struct flock { |
short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ |
short l_whence; /* flag to choose starting offset */ |
long l_start; /* relative offset, in bytes */ |
long l_len; /* length, in bytes; 0 means lock to EOF */ |
short l_pid; /* returned with F_GETLK */ |
short l_xxx; /* reserved for future use */ |
}; |
#endif /* __CYGWIN__ */ |
#ifndef _POSIX_SOURCE |
/* extended file segment locking set data type */ |
struct eflock { |
short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ |
short l_whence; /* flag to choose starting offset */ |
long l_start; /* relative offset, in bytes */ |
long l_len; /* length, in bytes; 0 means lock to EOF */ |
short l_pid; /* returned with F_GETLK */ |
short l_xxx; /* reserved for future use */ |
long l_rpid; /* Remote process id wanting this lock */ |
long l_rsys; /* Remote system id wanting this lock */ |
}; |
#endif /* !_POSIX_SOURCE */ |
#include <sys/types.h> |
#include <sys/stat.h> /* sigh. for the mode bits for open/creat */ |
extern int open _PARAMS ((const char *, int, ...)); |
extern int creat _PARAMS ((const char *, mode_t)); |
extern int fcntl _PARAMS ((int, int, ...)); |
#ifdef __CYGWIN__ |
#include <sys/time.h> |
extern int futimesat _PARAMS ((int, const char *, const struct timeval *)); |
extern int openat _PARAMS ((int, const char *, int, ...)); |
#endif |
/* Provide _<systemcall> prototypes for functions provided by some versions |
of newlib. */ |
#ifdef _COMPILING_NEWLIB |
extern int _open _PARAMS ((const char *, int, ...)); |
extern int _fcntl _PARAMS ((int, int, ...)); |
#ifdef __LARGE64_FILES |
extern int _open64 _PARAMS ((const char *, int, ...)); |
#endif |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* !_SYS__DEFAULT_FCNTL_H_ */ |
/contrib/sdk/sources/libc/include/sys/_types.h |
---|
0,0 → 1,87 |
/* ANSI C namespace clean utility typedefs */ |
/* This file defines various typedefs needed by the system calls that support |
the C library. Basically, they're just the POSIX versions with an '_' |
prepended. This file lives in the `sys' directory so targets can provide |
their own if desired (or they can put target dependant conditionals here). |
*/ |
#ifndef _SYS__TYPES_H |
#define _SYS__TYPES_H |
#include <machine/_types.h> |
#include <sys/lock.h> |
#ifndef __off_t_defined |
typedef long _off_t; |
#endif |
#if defined(__rtems__) |
/* device numbers are 32-bit major and and 32-bit minor */ |
typedef unsigned long long __dev_t; |
#else |
#ifndef __dev_t_defined |
typedef short __dev_t; |
#endif |
#endif |
#ifndef __uid_t_defined |
typedef unsigned short __uid_t; |
#endif |
#ifndef __gid_t_defined |
typedef unsigned short __gid_t; |
#endif |
#ifndef __off64_t_defined |
__extension__ typedef long long _off64_t; |
#endif |
/* |
* We need fpos_t for the following, but it doesn't have a leading "_", |
* so we use _fpos_t instead. |
*/ |
#ifndef __fpos_t_defined |
typedef long _fpos_t; /* XXX must match off_t in <sys/types.h> */ |
/* (and must be `long' for now) */ |
#endif |
#ifdef __LARGE64_FILES |
#ifndef __fpos64_t_defined |
typedef _off64_t _fpos64_t; |
#endif |
#endif |
#ifndef __ssize_t_defined |
#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647 |
typedef int _ssize_t; |
#else |
typedef long _ssize_t; |
#endif |
#endif |
#define __need_wint_t |
#include <stddef.h> |
#ifndef __mbstate_t_defined |
/* Conversion state information. */ |
typedef struct |
{ |
int __count; |
union |
{ |
wint_t __wch; |
unsigned char __wchb[4]; |
} __value; /* Value so far. */ |
} _mbstate_t; |
#endif |
#ifndef __flock_t_defined |
typedef _LOCK_RECURSIVE_T _flock_t; |
#endif |
#ifndef __iconv_t_defined |
/* Iconv descriptor type */ |
typedef void *_iconv_t; |
#endif |
#endif /* _SYS__TYPES_H */ |
/contrib/sdk/sources/libc/include/sys/cdefs.h |
---|
0,0 → 1,144 |
/* libc/sys/linux/sys/cdefs.h - Helper macros for K&R vs. ANSI C compat. */ |
/* Written 2000 by Werner Almesberger */ |
/* |
* Copyright (c) 1991, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Berkeley Software Design, Inc. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)cdefs.h 8.8 (Berkeley) 1/9/95 |
* $FreeBSD: src/sys/sys/cdefs.h,v 1.54 2002/05/11 03:58:24 alfred Exp $ |
*/ |
#ifndef _SYS_CDEFS_H |
#define _SYS_CDEFS_H |
#define __FBSDID(x) /* nothing */ |
/* |
* Note: the goal here is not compatibility to K&R C. Since we know that we |
* have GCC which understands ANSI C perfectly well, we make use of this. |
*/ |
#define __P(args) args |
#define __PMT(args) args |
#define __const const |
#define __signed signed |
#define __volatile volatile |
#define __DOTS , ... |
#define __THROW |
/* |
* The __CONCAT macro is used to concatenate parts of symbol names, e.g. |
* with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. |
* The __CONCAT macro is a bit tricky to use if it must work in non-ANSI |
* mode -- there must be no spaces between its arguments, and for nested |
* __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also |
* concatenate double-quoted strings produced by the __STRING macro, but |
* this only works with ANSI C. |
* |
* __XSTRING is like __STRING, but it expands any macros in its argument |
* first. It is only available with ANSI C. |
*/ |
#define __CONCAT1(x,y) x ## y |
#define __CONCAT(x,y) __CONCAT1(x,y) |
#define __STRING(x) #x /* stringify without expanding x */ |
#define __XSTRING(x) __STRING(x) /* expand x, then stringify */ |
#ifdef __GNUC__ |
# define __ASMNAME(cname) __XSTRING (__USER_LABEL_PREFIX__) cname |
#endif |
#define __ptr_t void * |
#define __long_double_t long double |
#define __attribute_malloc__ |
#define __attribute_pure__ |
#define __attribute_format_strfmon__(a,b) |
#define __flexarr [0] |
#ifdef __cplusplus |
# define __BEGIN_DECLS extern "C" { |
# define __END_DECLS } |
#else |
# define __BEGIN_DECLS |
# define __END_DECLS |
#endif |
#ifndef __BOUNDED_POINTERS__ |
# define __bounded /* nothing */ |
# define __unbounded /* nothing */ |
# define __ptrvalue /* nothing */ |
#endif |
#ifdef __GNUC__ |
#define __strong_reference(sym,aliassym) \ |
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))); |
#ifdef __ELF__ |
#ifdef __STDC__ |
#define __weak_reference(sym,alias) \ |
__asm__(".weak " #alias); \ |
__asm__(".equ " #alias ", " #sym) |
#define __warn_references(sym,msg) \ |
__asm__(".section .gnu.warning." #sym); \ |
__asm__(".asciz \"" msg "\""); \ |
__asm__(".previous") |
#else |
#define __weak_reference(sym,alias) \ |
__asm__(".weak alias"); \ |
__asm__(".equ alias, sym") |
#define __warn_references(sym,msg) \ |
__asm__(".section .gnu.warning.sym"); \ |
__asm__(".asciz \"msg\""); \ |
__asm__(".previous") |
#endif /* __STDC__ */ |
#else /* !__ELF__ */ |
#ifdef __STDC__ |
#define __weak_reference(sym,alias) \ |
__asm__(".stabs \"_" #alias "\",11,0,0,0"); \ |
__asm__(".stabs \"_" #sym "\",1,0,0,0") |
#define __warn_references(sym,msg) \ |
__asm__(".stabs \"" msg "\",30,0,0,0"); \ |
__asm__(".stabs \"_" #sym "\",1,0,0,0") |
#else |
#define __weak_reference(sym,alias) \ |
__asm__(".stabs \"_/**/alias\",11,0,0,0"); \ |
__asm__(".stabs \"_/**/sym\",1,0,0,0") |
#define __warn_references(sym,msg) \ |
__asm__(".stabs msg,30,0,0,0"); \ |
__asm__(".stabs \"_/**/sym\",1,0,0,0") |
#endif /* __STDC__ */ |
#endif /* __ELF__ */ |
#endif /* __GNUC__ */ |
#endif /* _SYS_CDEFS_H */ |
/contrib/sdk/sources/libc/include/sys/config.h |
---|
0,0 → 1,255 |
#ifndef __SYS_CONFIG_H__ |
#define __SYS_CONFIG_H__ |
#include <machine/ieeefp.h> /* floating point macros */ |
#include <sys/features.h> /* POSIX defs */ |
/* exceptions first */ |
#if defined(__H8500__) || defined(__W65__) |
#define __SMALL_BITFIELDS |
/* ??? This conditional is true for the h8500 and the w65, defining H8300 |
in those cases probably isn't the right thing to do. */ |
#define H8300 1 |
#endif |
/* 16 bit integer machines */ |
#if defined(__Z8001__) || defined(__Z8002__) || defined(__H8500__) || defined(__W65__) || defined (__mn10200__) || defined (__AVR__) |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX 32767 |
#define UINT_MAX 65535 |
#endif |
#if defined (__H8300__) || defined (__H8300H__) || defined(__H8300S__) || defined (__H8300SX__) |
#define __SMALL_BITFIELDS |
#define H8300 1 |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX __INT_MAX__ |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#endif |
#if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__)) |
#ifndef __INT32__ |
#define __SMALL_BITFIELDS |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX 32767 |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#else /* INT32 */ |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX 2147483647 |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#endif /* INT32 */ |
#endif /* CR16C */ |
#if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__) |
#define __SMALL_BITFIELDS |
#endif |
#ifdef __W65__ |
#define __SMALL_BITFIELDS |
#endif |
#if defined(__D10V__) |
#define __SMALL_BITFIELDS |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX __INT_MAX__ |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#define _POINTER_INT short |
#endif |
#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__) |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX __INT_MAX__ |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#define _POINTER_INT short |
#endif |
#ifdef ___AM29K__ |
#define _FLOAT_RET double |
#endif |
#ifdef __i386__ |
#ifndef __unix__ |
/* in other words, go32 */ |
#define _FLOAT_RET double |
#endif |
#if defined(__linux__) || defined(__RDOS__) |
/* we want the reentrancy structure to be returned by a function */ |
#define __DYNAMIC_REENT__ |
#define HAVE_GETDATE |
#define _HAVE_SYSTYPES |
#define _READ_WRITE_RETURN_TYPE _ssize_t |
#define __LARGE64_FILES 1 |
/* we use some glibc header files so turn on glibc large file feature */ |
#define _LARGEFILE64_SOURCE 1 |
#endif |
#endif |
#ifdef __mn10200__ |
#define __SMALL_BITFIELDS |
#endif |
#ifdef __AVR__ |
#define __SMALL_BITFIELDS |
#define _POINTER_INT short |
#endif |
#ifdef __v850 |
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__sda__)) |
#endif |
/* For the PowerPC eabi, force the _impure_ptr to be in .sdata */ |
#if defined(__PPC__) |
#if defined(_CALL_SYSV) |
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata"))) |
#endif |
#ifdef __SPE__ |
#define _LONG_DOUBLE double |
#endif |
#endif |
/* Configure small REENT structure for Xilinx MicroBlaze platforms */ |
#if defined (__MICROBLAZE__) |
#ifndef _REENT_SMALL |
#define _REENT_SMALL |
#endif |
/* Xilinx XMK uses Unix98 mutex */ |
#ifdef __XMK__ |
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES |
#endif |
#endif |
#if defined(__mips__) && !defined(__rtems__) |
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata"))) |
#endif |
#ifdef __xstormy16__ |
#define __SMALL_BITFIELDS |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX __INT_MAX__ |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#define MALLOC_ALIGNMENT 8 |
#define _POINTER_INT short |
#define __BUFSIZ__ 16 |
#define _REENT_SMALL |
#endif |
#ifdef __m32c__ |
#define __SMALL_BITFIELDS |
#undef INT_MAX |
#undef UINT_MAX |
#define INT_MAX __INT_MAX__ |
#define UINT_MAX (__INT_MAX__ * 2U + 1) |
#define MALLOC_ALIGNMENT 8 |
#if defined(__r8c_cpu__) || defined(__m16c_cpu__) |
#define _POINTER_INT short |
#else |
#define _POINTER_INT long |
#endif |
#define __BUFSIZ__ 16 |
#define _REENT_SMALL |
#endif /* __m32c__ */ |
#ifdef __SPU__ |
#define MALLOC_ALIGNMENT 16 |
#define __CUSTOM_FILE_IO__ |
#endif |
/* This block should be kept in sync with GCC's limits.h. The point |
of having these definitions here is to not include limits.h, which |
would pollute the user namespace, while still using types of the |
the correct widths when deciding how to define __int32_t and |
__int64_t. */ |
#ifndef __INT_MAX__ |
# ifdef INT_MAX |
# define __INT_MAX__ INT_MAX |
# else |
# define __INT_MAX__ 2147483647 |
# endif |
#endif |
#ifndef __LONG_MAX__ |
# ifdef LONG_MAX |
# define __LONG_MAX__ LONG_MAX |
# else |
# if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) \ |
|| defined (__sparcv9) |
# define __LONG_MAX__ 9223372036854775807L |
# else |
# define __LONG_MAX__ 2147483647L |
# endif /* __alpha__ || sparc64 */ |
# endif |
#endif |
/* End of block that should be kept in sync with GCC's limits.h. */ |
#ifndef _POINTER_INT |
#define _POINTER_INT long |
#endif |
#ifdef __frv__ |
#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata"))) |
#endif |
#undef __RAND_MAX |
#if __INT_MAX__ == 32767 |
#define __RAND_MAX 32767 |
#else |
#define __RAND_MAX 0x7fffffff |
#endif |
#if defined(__CYGWIN__) |
#include <cygwin/config.h> |
#if !defined (__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) |
#define __USE_XOPEN2K 1 |
#endif |
#endif |
#if defined(__rtems__) |
#define __FILENAME_MAX__ 255 |
#define _READ_WRITE_RETURN_TYPE _ssize_t |
#endif |
#ifndef __EXPORT |
#define __EXPORT |
#endif |
#ifndef __IMPORT |
#define __IMPORT |
#endif |
/* Define return type of read/write routines. In POSIX, the return type |
for read()/write() is "ssize_t" but legacy newlib code has been using |
"int" for some time. If not specified, "int" is defaulted. */ |
#ifndef _READ_WRITE_RETURN_TYPE |
#define _READ_WRITE_RETURN_TYPE int |
#endif |
#ifndef __WCHAR_MAX__ |
#if __INT_MAX__ == 32767 || defined (_WIN32) |
#define __WCHAR_MAX__ 0xffffu |
#endif |
#endif |
/* See if small reent asked for at configuration time and |
is not chosen by the platform by default. */ |
#ifdef _WANT_REENT_SMALL |
#ifndef _REENT_SMALL |
#define _REENT_SMALL |
#endif |
#endif |
/* If _MB_EXTENDED_CHARSETS_ALL is set, we want all of the extended |
charsets. The extended charsets add a few functions and a couple |
of tables of a few K each. */ |
#ifdef _MB_EXTENDED_CHARSETS_ALL |
#define _MB_EXTENDED_CHARSETS_ISO 1 |
#define _MB_EXTENDED_CHARSETS_WINDOWS 1 |
#endif |
#endif /* __SYS_CONFIG_H__ */ |
/contrib/sdk/sources/libc/include/sys/custom_file.h |
---|
0,0 → 1,2 |
#error System-specific custom_file.h is missing. |
/contrib/sdk/sources/libc/include/sys/dir.h |
---|
0,0 → 1,10 |
/* BSD predecessor of POSIX.1 <dirent.h> and struct dirent */ |
#ifndef _SYS_DIR_H_ |
#define _SYS_DIR_H_ |
#include <dirent.h> |
#define direct dirent |
#endif /*_SYS_DIR_H_*/ |
/contrib/sdk/sources/libc/include/sys/dirent.h |
---|
0,0 → 1,13 |
/* <dirent.h> includes <sys/dirent.h>, which is this file. On a |
system which supports <dirent.h>, this file is overridden by |
dirent.h in the libc/sys/.../sys directory. On a system which does |
not support <dirent.h>, we will get this file which uses #error to force |
an error. */ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#error "<dirent.h> not supported" |
#ifdef __cplusplus |
} |
#endif |
/contrib/sdk/sources/libc/include/sys/errno.h |
---|
0,0 → 1,192 |
/* errno is not a global variable, because that would make using it |
non-reentrant. Instead, its address is returned by the function |
__errno. */ |
#ifndef _SYS_ERRNO_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _SYS_ERRNO_H_ |
#include <sys/reent.h> |
#ifndef _REENT_ONLY |
#define errno (*__errno()) |
extern int *__errno _PARAMS ((void)); |
#endif |
/* Please don't use these variables directly. |
Use strerror instead. */ |
extern __IMPORT _CONST char * _CONST _sys_errlist[]; |
extern __IMPORT int _sys_nerr; |
#ifdef __CYGWIN__ |
extern __IMPORT const char * const sys_errlist[]; |
extern __IMPORT int sys_nerr; |
extern __IMPORT char *program_invocation_name; |
extern __IMPORT char *program_invocation_short_name; |
#endif |
#define __errno_r(ptr) ((ptr)->_errno) |
#define EPERM 1 /* Not super-user */ |
#define ENOENT 2 /* No such file or directory */ |
#define ESRCH 3 /* No such process */ |
#define EINTR 4 /* Interrupted system call */ |
#define EIO 5 /* I/O error */ |
#define ENXIO 6 /* No such device or address */ |
#define E2BIG 7 /* Arg list too long */ |
#define ENOEXEC 8 /* Exec format error */ |
#define EBADF 9 /* Bad file number */ |
#define ECHILD 10 /* No children */ |
#define EAGAIN 11 /* No more processes */ |
#define ENOMEM 12 /* Not enough core */ |
#define EACCES 13 /* Permission denied */ |
#define EFAULT 14 /* Bad address */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ENOTBLK 15 /* Block device required */ |
#endif |
#define EBUSY 16 /* Mount device busy */ |
#define EEXIST 17 /* File exists */ |
#define EXDEV 18 /* Cross-device link */ |
#define ENODEV 19 /* No such device */ |
#define ENOTDIR 20 /* Not a directory */ |
#define EISDIR 21 /* Is a directory */ |
#define EINVAL 22 /* Invalid argument */ |
#define ENFILE 23 /* Too many open files in system */ |
#define EMFILE 24 /* Too many open files */ |
#define ENOTTY 25 /* Not a typewriter */ |
#define ETXTBSY 26 /* Text file busy */ |
#define EFBIG 27 /* File too large */ |
#define ENOSPC 28 /* No space left on device */ |
#define ESPIPE 29 /* Illegal seek */ |
#define EROFS 30 /* Read only file system */ |
#define EMLINK 31 /* Too many links */ |
#define EPIPE 32 /* Broken pipe */ |
#define EDOM 33 /* Math arg out of domain of func */ |
#define ERANGE 34 /* Math result not representable */ |
#define ENOMSG 35 /* No message of desired type */ |
#define EIDRM 36 /* Identifier removed */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ECHRNG 37 /* Channel number out of range */ |
#define EL2NSYNC 38 /* Level 2 not synchronized */ |
#define EL3HLT 39 /* Level 3 halted */ |
#define EL3RST 40 /* Level 3 reset */ |
#define ELNRNG 41 /* Link number out of range */ |
#define EUNATCH 42 /* Protocol driver not attached */ |
#define ENOCSI 43 /* No CSI structure available */ |
#define EL2HLT 44 /* Level 2 halted */ |
#endif |
#define EDEADLK 45 /* Deadlock condition */ |
#define ENOLCK 46 /* No record locks available */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define EBADE 50 /* Invalid exchange */ |
#define EBADR 51 /* Invalid request descriptor */ |
#define EXFULL 52 /* Exchange full */ |
#define ENOANO 53 /* No anode */ |
#define EBADRQC 54 /* Invalid request code */ |
#define EBADSLT 55 /* Invalid slot */ |
#define EDEADLOCK 56 /* File locking deadlock error */ |
#define EBFONT 57 /* Bad font file fmt */ |
#endif |
#define ENOSTR 60 /* Device not a stream */ |
#define ENODATA 61 /* No data (for no delay io) */ |
#define ETIME 62 /* Timer expired */ |
#define ENOSR 63 /* Out of streams resources */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ENONET 64 /* Machine is not on the network */ |
#define ENOPKG 65 /* Package not installed */ |
#define EREMOTE 66 /* The object is remote */ |
#endif |
#define ENOLINK 67 /* The link has been severed */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define EADV 68 /* Advertise error */ |
#define ESRMNT 69 /* Srmount error */ |
#define ECOMM 70 /* Communication error on send */ |
#endif |
#define EPROTO 71 /* Protocol error */ |
#define EMULTIHOP 74 /* Multihop attempted */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ELBIN 75 /* Inode is remote (not really error) */ |
#define EDOTDOT 76 /* Cross mount point (not really error) */ |
#endif |
#define EBADMSG 77 /* Trying to read unreadable message */ |
#define EFTYPE 79 /* Inappropriate file type or format */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ENOTUNIQ 80 /* Given log. name not unique */ |
#define EBADFD 81 /* f.d. invalid for this operation */ |
#define EREMCHG 82 /* Remote address changed */ |
#define ELIBACC 83 /* Can't access a needed shared lib */ |
#define ELIBBAD 84 /* Accessing a corrupted shared lib */ |
#define ELIBSCN 85 /* .lib section in a.out corrupted */ |
#define ELIBMAX 86 /* Attempting to link in too many libs */ |
#define ELIBEXEC 87 /* Attempting to exec a shared library */ |
#endif |
#define ENOSYS 88 /* Function not implemented */ |
#ifdef __CYGWIN__ |
#define ENMFILE 89 /* No more files */ |
#endif |
#define ENOTEMPTY 90 /* Directory not empty */ |
#define ENAMETOOLONG 91 /* File or path name too long */ |
#define ELOOP 92 /* Too many symbolic links */ |
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ |
#define EPFNOSUPPORT 96 /* Protocol family not supported */ |
#define ECONNRESET 104 /* Connection reset by peer */ |
#define ENOBUFS 105 /* No buffer space available */ |
#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */ |
#define EPROTOTYPE 107 /* Protocol wrong type for socket */ |
#define ENOTSOCK 108 /* Socket operation on non-socket */ |
#define ENOPROTOOPT 109 /* Protocol not available */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ESHUTDOWN 110 /* Can't send after socket shutdown */ |
#endif |
#define ECONNREFUSED 111 /* Connection refused */ |
#define EADDRINUSE 112 /* Address already in use */ |
#define ECONNABORTED 113 /* Connection aborted */ |
#define ENETUNREACH 114 /* Network is unreachable */ |
#define ENETDOWN 115 /* Network interface is not configured */ |
#define ETIMEDOUT 116 /* Connection timed out */ |
#define EHOSTDOWN 117 /* Host is down */ |
#define EHOSTUNREACH 118 /* Host is unreachable */ |
#define EINPROGRESS 119 /* Connection already in progress */ |
#define EALREADY 120 /* Socket already connected */ |
#define EDESTADDRREQ 121 /* Destination address required */ |
#define EMSGSIZE 122 /* Message too long */ |
#define EPROTONOSUPPORT 123 /* Unknown protocol */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ESOCKTNOSUPPORT 124 /* Socket type not supported */ |
#endif |
#define EADDRNOTAVAIL 125 /* Address not available */ |
#define ENETRESET 126 |
#define EISCONN 127 /* Socket is already connected */ |
#define ENOTCONN 128 /* Socket is not connected */ |
#define ETOOMANYREFS 129 |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define EPROCLIM 130 |
#define EUSERS 131 |
#endif |
#define EDQUOT 132 |
#define ESTALE 133 |
#define ENOTSUP 134 /* Not supported */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ENOMEDIUM 135 /* No medium (in tape drive) */ |
#endif |
#ifdef __CYGWIN__ |
#define ENOSHARE 136 /* No such host or network path */ |
#define ECASECLASH 137 /* Filename exists with different case */ |
#endif |
#define EILSEQ 138 |
#define EOVERFLOW 139 /* Value too large for defined data type */ |
#define ECANCELED 140 /* Operation canceled */ |
#define ENOTRECOVERABLE 141 /* State not recoverable */ |
#define EOWNERDEAD 142 /* Previous owner died */ |
#ifdef __LINUX_ERRNO_EXTENSIONS__ |
#define ESTRPIPE 143 /* Streams pipe error */ |
#endif |
#define EWOULDBLOCK EAGAIN /* Operation would block */ |
#define __ELASTERROR 2000 /* Users can add values starting here */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_ERRNO_H */ |
/contrib/sdk/sources/libc/include/sys/fcntl.h |
---|
0,0 → 1,4 |
#ifndef _SYS_FCNTL_H_ |
#define _SYS_FCNTL_H_ |
#include <sys/_default_fcntl.h> |
#endif |
/contrib/sdk/sources/libc/include/sys/features.h |
---|
0,0 → 1,211 |
/* |
* Written by Joel Sherrill <joel@OARcorp.com>. |
* |
* COPYRIGHT (c) 1989-2000. |
* |
* On-Line Applications Research Corporation (OAR). |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION |
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS |
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
* $Id: features.h,v 1.27 2011/07/20 19:41:15 yselkowitz Exp $ |
*/ |
#ifndef _SYS_FEATURES_H |
#define _SYS_FEATURES_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* RTEMS adheres to POSIX -- 1003.1b with some features from annexes. */ |
#ifdef __rtems__ |
#define _POSIX_JOB_CONTROL 1 |
#define _POSIX_SAVED_IDS 1 |
#define _POSIX_VERSION 199309L |
#define _POSIX_ASYNCHRONOUS_IO 1 |
#define _POSIX_FSYNC 1 |
#define _POSIX_MAPPED_FILES 1 |
#define _POSIX_MEMLOCK 1 |
#define _POSIX_MEMLOCK_RANGE 1 |
#define _POSIX_MEMORY_PROTECTION 1 |
#define _POSIX_MESSAGE_PASSING 1 |
#define _POSIX_MONOTONIC_CLOCK 200112L |
#define _POSIX_PRIORITIZED_IO 1 |
#define _POSIX_PRIORITY_SCHEDULING 1 |
#define _POSIX_REALTIME_SIGNALS 1 |
#define _POSIX_SEMAPHORES 1 |
/* #define _POSIX_SHARED_MEMORY_OBJECTS 1 */ |
#define _POSIX_SYNCHRONIZED_IO 1 |
#define _POSIX_TIMERS 1 |
#define _POSIX_BARRIERS 200112L |
#define _POSIX_READER_WRITER_LOCKS 200112L |
#define _POSIX_SPIN_LOCKS 200112L |
/* In P1003.1b but defined by drafts at least as early as P1003.1c/D10 */ |
#define _POSIX_THREADS 1 |
#define _POSIX_THREAD_ATTR_STACKADDR 1 |
#define _POSIX_THREAD_ATTR_STACKSIZE 1 |
#define _POSIX_THREAD_PRIORITY_SCHEDULING 1 |
#define _POSIX_THREAD_PRIO_INHERIT 1 |
#define _POSIX_THREAD_PRIO_PROTECT 1 |
#define _POSIX_THREAD_PROCESS_SHARED 1 |
#define _POSIX_THREAD_SAFE_FUNCTIONS 1 |
/* P1003.4b/D8 defines the constants below this comment. */ |
#define _POSIX_SPAWN 1 |
#define _POSIX_TIMEOUTS 1 |
#define _POSIX_CPUTIME 1 |
#define _POSIX_THREAD_CPUTIME 1 |
#define _POSIX_SPORADIC_SERVER 1 |
#define _POSIX_THREAD_SPORADIC_SERVER 1 |
#define _POSIX_DEVICE_CONTROL 1 |
#define _POSIX_DEVCTL_DIRECTION 1 |
#define _POSIX_INTERRUPT_CONTROL 1 |
#define _POSIX_ADVISORY_INFO 1 |
/* UNIX98 added some new pthread mutex attributes */ |
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1 |
#endif |
/* XMK loosely adheres to POSIX -- 1003.1 */ |
#ifdef __XMK__ |
#define _POSIX_THREADS 1 |
#define _POSIX_THREAD_PRIORITY_SCHEDULING 1 |
#endif |
#ifdef __svr4__ |
# define _POSIX_JOB_CONTROL 1 |
# define _POSIX_SAVED_IDS 1 |
# define _POSIX_VERSION 199009L |
#endif |
#ifdef __CYGWIN__ |
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L |
#define _POSIX_VERSION 200112L |
#define _POSIX2_VERSION 200112L |
#define _XOPEN_VERSION 600 |
#define _POSIX_ADVISORY_INFO 200112L |
/* #define _POSIX_ASYNCHRONOUS_IO -1 */ |
/* #define _POSIX_BARRIERS -1 */ |
#define _POSIX_CHOWN_RESTRICTED 1 |
#define _POSIX_CLOCK_SELECTION 200112L |
#define _POSIX_CPUTIME 200112L |
#define _POSIX_FSYNC 200112L |
#define _POSIX_IPV6 200112L |
#define _POSIX_JOB_CONTROL 1 |
#define _POSIX_MAPPED_FILES 200112L |
/* #define _POSIX_MEMLOCK -1 */ |
#define _POSIX_MEMLOCK_RANGE 200112L |
#define _POSIX_MEMORY_PROTECTION 200112L |
#define _POSIX_MESSAGE_PASSING 200112L |
#define _POSIX_MONOTONIC_CLOCK 200112L |
#define _POSIX_NO_TRUNC 1 |
/* #define _POSIX_PRIORITIZED_IO -1 */ |
#define _POSIX_PRIORITY_SCHEDULING 200112L |
#define _POSIX_RAW_SOCKETS 200112L |
#define _POSIX_READER_WRITER_LOCKS 200112L |
#define _POSIX_REALTIME_SIGNALS 200112L |
#define _POSIX_REGEXP 1 |
#define _POSIX_SAVED_IDS 1 |
#define _POSIX_SEMAPHORES 200112L |
#define _POSIX_SHARED_MEMORY_OBJECTS 200112L |
#define _POSIX_SHELL 1 |
/* #define _POSIX_SPAWN -1 */ |
#define _POSIX_SPIN_LOCKS 200112L |
/* #define _POSIX_SPORADIC_SERVER -1 */ |
#define _POSIX_SYNCHRONIZED_IO 200112L |
#define _POSIX_THREAD_ATTR_STACKADDR 200112L |
#define _POSIX_THREAD_ATTR_STACKSIZE 200112L |
#define _POSIX_THREAD_CPUTIME 200112L |
/* #define _POSIX_THREAD_PRIO_INHERIT -1 */ |
/* #define _POSIX_THREAD_PRIO_PROTECT -1 */ |
#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L |
#define _POSIX_THREAD_PROCESS_SHARED 200112L |
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L |
/* #define _POSIX_THREAD_SPORADIC_SERVER -1 */ |
#define _POSIX_THREADS 200112L |
/* #define _POSIX_TIMEOUTS -1 */ |
#define _POSIX_TIMERS 1 |
/* #define _POSIX_TRACE -1 */ |
/* #define _POSIX_TRACE_EVENT_FILTER -1 */ |
/* #define _POSIX_TRACE_INHERIT -1 */ |
/* #define _POSIX_TRACE_LOG -1 */ |
/* #define _POSIX_TYPED_MEMORY_OBJECTS -1 */ |
#define _POSIX_VDISABLE '\0' |
#define _POSIX2_C_BIND 200112L |
#define _POSIX2_C_DEV 200112L |
#define _POSIX2_CHAR_TERM 200112L |
/* #define _POSIX2_FORT_DEV -1 */ |
/* #define _POSIX2_FORT_RUN -1 */ |
/* #define _POSIX2_LOCALEDEF -1 */ |
/* #define _POSIX2_PBS -1 */ |
/* #define _POSIX2_PBS_ACCOUNTING -1 */ |
/* #define _POSIX2_PBS_CHECKPOINT -1 */ |
/* #define _POSIX2_PBS_LOCATE -1 */ |
/* #define _POSIX2_PBS_MESSAGE -1 */ |
/* #define _POSIX2_PBS_TRACK -1 */ |
#define _POSIX2_SW_DEV 200112L |
#define _POSIX2_UPE 200112L |
#define _POSIX_V6_ILP32_OFF32 -1 |
#define _XBS5_ILP32_OFF32 _POSIX_V6_ILP32_OFF32 |
#define _POSIX_V6_ILP32_OFFBIG 1 |
#define _XBS5_ILP32_OFFBIG _POSIX_V6_ILP32_OFFBIG |
#define _POSIX_V6_LP64_OFF64 -1 |
#define _XBS5_LP64_OFF64 _POSIX_V6_LP64_OFF64 |
#define _POSIX_V6_LPBIG_OFFBIG -1 |
#define _XBS5_LPBIG_OFFBIG _POSIX_V6_LPBIG_OFFBIG |
#define _XOPEN_CRYPT 1 |
#define _XOPEN_ENH_I18N 1 |
/* #define _XOPEN_LEGACY -1 */ |
/* #define _XOPEN_REALTIME -1 */ |
/* #define _XOPEN_REALTIME_THREADS -1 */ |
#define _XOPEN_SHM 1 |
/* #define _XOPEN_STREAMS -1 */ |
/* #define _XOPEN_UNIX -1 */ |
#endif /* !__STRICT_ANSI__ || __cplusplus || __STDC_VERSION__ >= 199901L */ |
/* The value corresponds to UNICODE version 4.0, which is the version |
supported by XP. Newlib supports 5.2 (2011) but so far Cygwin needs |
the MS conversions for double-byte charsets. */ |
#define __STDC_ISO_10646__ 200305L |
#endif /* __CYGWIN__ */ |
/* Per the permission given in POSIX.1-2008 section 2.2.1, define |
* _POSIX_C_SOURCE if _XOPEN_SOURCE is defined and _POSIX_C_SOURCE is not. |
* (_XOPEN_SOURCE indicates that XSI extensions are desired by an application.) |
* This permission is first granted in 2008, but use it for older ones, also. |
* Allow for _XOPEN_SOURCE to be empty (from the earliest form of it, before it |
* was required to have specific values). |
*/ |
#if !defined(_POSIX_C_SOURCE) && defined(_XOPEN_SOURCE) |
#if (_XOPEN_SOURCE - 0) == 700 /* POSIX.1-2008 */ |
#define _POSIX_C_SOURCE 200809L |
#elif (_XOPEN_SOURCE - 0) == 600 /* POSIX.1-2001 or 2004 */ |
#define _POSIX_C_SOURCE 200112L |
#elif (_XOPEN_SOURCE - 0) == 500 /* POSIX.1-1995 */ |
#define _POSIX_C_SOURCE 199506L |
#elif (_XOPEN_SOURCE - 0) < 500 /* really old */ |
#define _POSIX_C_SOURCE 2 |
#endif |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_FEATURES_H */ |
/contrib/sdk/sources/libc/include/sys/file.h |
---|
0,0 → 1,2 |
#include <sys/fcntl.h> |
/contrib/sdk/sources/libc/include/sys/iconvnls.h |
---|
0,0 → 1,77 |
/* |
* Copyright (c) 2003-2004, Artem B. Bityuckiy. |
* Rights transferred to Franklin Electronic Publishers. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
/* |
* Funtions, macros, etc implimented in iconv library but used by other |
* NLS-related subsystems too. |
*/ |
#ifndef __SYS_ICONVNLS_H__ |
#define __SYS_ICONVNLS_H__ |
#include <_ansi.h> |
#include <reent.h> |
#include <wchar.h> |
#include <iconv.h> |
/* Iconv data path environment variable name */ |
#define NLS_ENVVAR_NAME "NLSPATH" |
/* Default NLSPATH value */ |
#define ICONV_DEFAULT_NLSPATH "/usr/locale" |
/* Direction markers */ |
#define ICONV_NLS_FROM 0 |
#define ICONV_NLS_TO 1 |
_VOID |
_EXFUN(_iconv_nls_get_state, (iconv_t cd, mbstate_t *ps, int direction)); |
int |
_EXFUN(_iconv_nls_set_state, (iconv_t cd, mbstate_t *ps, int direction)); |
int |
_EXFUN(_iconv_nls_is_stateful, (iconv_t cd, int direction)); |
int |
_EXFUN(_iconv_nls_get_mb_cur_max, (iconv_t cd, int direction)); |
size_t |
_EXFUN(_iconv_nls_conv, (struct _reent *rptr, iconv_t cd, |
_CONST char **inbuf, size_t *inbytesleft, |
char **outbuf, size_t *outbytesleft)); |
_CONST char * |
_EXFUN(_iconv_nls_construct_filename, (struct _reent *rptr, _CONST char *file, |
_CONST char *dir, _CONST char *ext)); |
int |
_EXFUN(_iconv_nls_open, (struct _reent *rptr, _CONST char *encoding, |
iconv_t *towc, iconv_t *fromwc, int flag)); |
char * |
_EXFUN(_iconv_resolve_encoding_name, (struct _reent *rptr, _CONST char *ca)); |
#endif /* __SYS_ICONVNLS_H__ */ |
/contrib/sdk/sources/libc/include/sys/lock.h |
---|
0,0 → 1,69 |
#ifndef __SYS_LOCK_H__ |
#define __SYS_LOCK_H__ |
#define _LIBC 1 |
#define NOT_IN_libc 1 |
#ifndef __USE_GNU |
#define __USE_GNU 1 |
#endif |
void __mutex_lock(volatile int *val); |
typedef volatile int __libc_lock_t; |
typedef struct { volatile int mutex; } __libc_lock_recursive_t; |
#define __libc_lock_define(CLASS,NAME) \ |
CLASS __libc_lock_t NAME; |
#define __libc_rwlock_define(CLASS,NAME) \ |
CLASS __libc_rwlock_t NAME; |
#define __libc_lock_define_recursive(CLASS,NAME) \ |
CLASS __libc_lock_recursive_t NAME; |
#define __rtld_lock_define_recursive(CLASS,NAME) \ |
CLASS __rtld_lock_recursive_t NAME; |
typedef __libc_lock_t _LOCK_T; |
typedef __libc_lock_recursive_t _LOCK_RECURSIVE_T; |
#define __LOCK_INIT(class,lock) \ |
__libc_lock_define_initialized(class, lock) |
#define __LOCK_INIT_RECURSIVE(class, lock) \ |
__libc_lock_define_initialized_recursive(class, lock) |
#define __libc_lock_define_initialized(CLASS,NAME) \ |
CLASS __libc_lock_t NAME; |
#define __libc_lock_define_initialized_recursive(CLASS,NAME) \ |
CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER; |
#define _LIBC_LOCK_RECURSIVE_INITIALIZER {0} |
#define __lock_init(__lock) __libc_lock_init(__lock) |
#define __lock_init_recursive(__lock) __libc_lock_init_recursive(__lock) |
#define __lock_acquire(__lock) __libc_lock_lock(__lock) |
#define __lock_acquire_recursive(__lock) __libc_lock_lock_recursive(__lock) |
#define __lock_release(__lock) __libc_lock_unlock(__lock) |
#define __lock_release_recursive(__lock) __libc_lock_unlock_recursive(__lock) |
#define __lock_try_acquire(__lock) __libc_lock_trylock(__lock) |
#define __lock_try_acquire_recursive(__lock) \ |
__libc_lock_trylock_recursive(__lock) |
#define __lock_close(__lock) __libc_lock_fini(__lock) |
#define __lock_close_recursive(__lock) __libc_lock_fini_recursive(__lock) |
#define __libc_lock_init_recursive(NAME) ((NAME).mutex=0) |
#define __libc_lock_fini(NAME) |
#define __libc_lock_fini_recursive(NAME) __libc_lock_fini ((NAME).mutex) |
#define __libc_lock_lock(NAME) __mutex_lock (&(NAME)) |
/* Lock the recursive named lock variable. */ |
#define __libc_lock_lock_recursive(NAME) __libc_lock_lock ((NAME).mutex) |
#define __libc_lock_unlock(NAME) ((NAME)=0) |
#define __libc_lock_unlock_recursive(NAME) __libc_lock_unlock ((NAME).mutex) |
#endif /* __SYS_LOCK_H__ */ |
/contrib/sdk/sources/libc/include/sys/param.h |
---|
0,0 → 1,25 |
/* This is a dummy <sys/param.h> file, not customized for any |
particular system. If there is a param.h in libc/sys/SYSDIR/sys, |
it will override this one. */ |
#ifndef _SYS_PARAM_H |
# define _SYS_PARAM_H |
#include <sys/config.h> |
#include <machine/endian.h> |
#include <machine/param.h> |
#ifndef HZ |
# define HZ (60) |
#endif |
#ifndef NOFILE |
# define NOFILE (60) |
#endif |
#ifndef PATHSIZE |
# define PATHSIZE (1024) |
#endif |
#define MAX(a,b) ((a) > (b) ? (a) : (b)) |
#define MIN(a,b) ((a) < (b) ? (a) : (b)) |
#endif |
/contrib/sdk/sources/libc/include/sys/queue.h |
---|
0,0 → 1,471 |
/* |
* Copyright (c) 1991, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)queue.h 8.5 (Berkeley) 8/20/94 |
* $FreeBSD: src/sys/sys/queue.h,v 1.48 2002/04/17 14:00:37 tmm Exp $ |
*/ |
#ifndef _SYS_QUEUE_H_ |
#define _SYS_QUEUE_H_ |
#include <machine/ansi.h> /* for __offsetof */ |
/* |
* This file defines four types of data structures: singly-linked lists, |
* singly-linked tail queues, lists and tail queues. |
* |
* A singly-linked list is headed by a single forward pointer. The elements |
* are singly linked for minimum space and pointer manipulation overhead at |
* the expense of O(n) removal for arbitrary elements. New elements can be |
* added to the list after an existing element or at the head of the list. |
* Elements being removed from the head of the list should use the explicit |
* macro for this purpose for optimum efficiency. A singly-linked list may |
* only be traversed in the forward direction. Singly-linked lists are ideal |
* for applications with large datasets and few or no removals or for |
* implementing a LIFO queue. |
* |
* A singly-linked tail queue is headed by a pair of pointers, one to the |
* head of the list and the other to the tail of the list. The elements are |
* singly linked for minimum space and pointer manipulation overhead at the |
* expense of O(n) removal for arbitrary elements. New elements can be added |
* to the list after an existing element, at the head of the list, or at the |
* end of the list. Elements being removed from the head of the tail queue |
* should use the explicit macro for this purpose for optimum efficiency. |
* A singly-linked tail queue may only be traversed in the forward direction. |
* Singly-linked tail queues are ideal for applications with large datasets |
* and few or no removals or for implementing a FIFO queue. |
* |
* A list is headed by a single forward pointer (or an array of forward |
* pointers for a hash table header). The elements are doubly linked |
* so that an arbitrary element can be removed without a need to |
* traverse the list. New elements can be added to the list before |
* or after an existing element or at the head of the list. A list |
* may only be traversed in the forward direction. |
* |
* A tail queue is headed by a pair of pointers, one to the head of the |
* list and the other to the tail of the list. The elements are doubly |
* linked so that an arbitrary element can be removed without a need to |
* traverse the list. New elements can be added to the list before or |
* after an existing element, at the head of the list, or at the end of |
* the list. A tail queue may be traversed in either direction. |
* |
* For details on the use of these macros, see the queue(3) manual page. |
* |
* |
* SLIST LIST STAILQ TAILQ |
* _HEAD + + + + |
* _HEAD_INITIALIZER + + + + |
* _ENTRY + + + + |
* _INIT + + + + |
* _EMPTY + + + + |
* _FIRST + + + + |
* _NEXT + + + + |
* _PREV - - - + |
* _LAST - - + + |
* _FOREACH + + + + |
* _FOREACH_REVERSE - - - + |
* _INSERT_HEAD + + + + |
* _INSERT_BEFORE - + - + |
* _INSERT_AFTER + + + + |
* _INSERT_TAIL - - + + |
* _CONCAT - - + + |
* _REMOVE_HEAD + - + - |
* _REMOVE + + + + |
* |
*/ |
/* |
* Singly-linked List declarations. |
*/ |
#define SLIST_HEAD(name, type) \ |
struct name { \ |
struct type *slh_first; /* first element */ \ |
} |
#define SLIST_HEAD_INITIALIZER(head) \ |
{ NULL } |
#define SLIST_ENTRY(type) \ |
struct { \ |
struct type *sle_next; /* next element */ \ |
} |
/* |
* Singly-linked List functions. |
*/ |
#define SLIST_EMPTY(head) ((head)->slh_first == NULL) |
#define SLIST_FIRST(head) ((head)->slh_first) |
#define SLIST_FOREACH(var, head, field) \ |
for ((var) = SLIST_FIRST((head)); \ |
(var); \ |
(var) = SLIST_NEXT((var), field)) |
#define SLIST_INIT(head) do { \ |
SLIST_FIRST((head)) = NULL; \ |
} while (0) |
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ |
SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ |
SLIST_NEXT((slistelm), field) = (elm); \ |
} while (0) |
#define SLIST_INSERT_HEAD(head, elm, field) do { \ |
SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ |
SLIST_FIRST((head)) = (elm); \ |
} while (0) |
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) |
#define SLIST_REMOVE(head, elm, type, field) do { \ |
if (SLIST_FIRST((head)) == (elm)) { \ |
SLIST_REMOVE_HEAD((head), field); \ |
} \ |
else { \ |
struct type *curelm = SLIST_FIRST((head)); \ |
while (SLIST_NEXT(curelm, field) != (elm)) \ |
curelm = SLIST_NEXT(curelm, field); \ |
SLIST_NEXT(curelm, field) = \ |
SLIST_NEXT(SLIST_NEXT(curelm, field), field); \ |
} \ |
} while (0) |
#define SLIST_REMOVE_HEAD(head, field) do { \ |
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ |
} while (0) |
/* |
* Singly-linked Tail queue declarations. |
*/ |
#define STAILQ_HEAD(name, type) \ |
struct name { \ |
struct type *stqh_first;/* first element */ \ |
struct type **stqh_last;/* addr of last next element */ \ |
} |
#define STAILQ_HEAD_INITIALIZER(head) \ |
{ NULL, &(head).stqh_first } |
#define STAILQ_ENTRY(type) \ |
struct { \ |
struct type *stqe_next; /* next element */ \ |
} |
/* |
* Singly-linked Tail queue functions. |
*/ |
#define STAILQ_CONCAT(head1, head2) do { \ |
if (!STAILQ_EMPTY((head2))) { \ |
*(head1)->stqh_last = (head2)->stqh_first; \ |
(head1)->stqh_last = (head2)->stqh_last; \ |
STAILQ_INIT((head2)); \ |
} \ |
} while (0) |
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) |
#define STAILQ_FIRST(head) ((head)->stqh_first) |
#define STAILQ_FOREACH(var, head, field) \ |
for((var) = STAILQ_FIRST((head)); \ |
(var); \ |
(var) = STAILQ_NEXT((var), field)) |
#define STAILQ_INIT(head) do { \ |
STAILQ_FIRST((head)) = NULL; \ |
(head)->stqh_last = &STAILQ_FIRST((head)); \ |
} while (0) |
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ |
if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ |
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ |
STAILQ_NEXT((tqelm), field) = (elm); \ |
} while (0) |
#define STAILQ_INSERT_HEAD(head, elm, field) do { \ |
if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ |
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ |
STAILQ_FIRST((head)) = (elm); \ |
} while (0) |
#define STAILQ_INSERT_TAIL(head, elm, field) do { \ |
STAILQ_NEXT((elm), field) = NULL; \ |
*(head)->stqh_last = (elm); \ |
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ |
} while (0) |
#define STAILQ_LAST(head, type, field) \ |
(STAILQ_EMPTY((head)) ? \ |
NULL : \ |
((struct type *) \ |
((char *)((head)->stqh_last) - __offsetof(struct type, field)))) |
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) |
#define STAILQ_REMOVE(head, elm, type, field) do { \ |
if (STAILQ_FIRST((head)) == (elm)) { \ |
STAILQ_REMOVE_HEAD((head), field); \ |
} \ |
else { \ |
struct type *curelm = STAILQ_FIRST((head)); \ |
while (STAILQ_NEXT(curelm, field) != (elm)) \ |
curelm = STAILQ_NEXT(curelm, field); \ |
if ((STAILQ_NEXT(curelm, field) = \ |
STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\ |
(head)->stqh_last = &STAILQ_NEXT((curelm), field);\ |
} \ |
} while (0) |
#define STAILQ_REMOVE_HEAD(head, field) do { \ |
if ((STAILQ_FIRST((head)) = \ |
STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ |
(head)->stqh_last = &STAILQ_FIRST((head)); \ |
} while (0) |
#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \ |
if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \ |
(head)->stqh_last = &STAILQ_FIRST((head)); \ |
} while (0) |
/* |
* List declarations. |
*/ |
#define LIST_HEAD(name, type) \ |
struct name { \ |
struct type *lh_first; /* first element */ \ |
} |
#define LIST_HEAD_INITIALIZER(head) \ |
{ NULL } |
#define LIST_ENTRY(type) \ |
struct { \ |
struct type *le_next; /* next element */ \ |
struct type **le_prev; /* address of previous next element */ \ |
} |
/* |
* List functions. |
*/ |
#define LIST_EMPTY(head) ((head)->lh_first == NULL) |
#define LIST_FIRST(head) ((head)->lh_first) |
#define LIST_FOREACH(var, head, field) \ |
for ((var) = LIST_FIRST((head)); \ |
(var); \ |
(var) = LIST_NEXT((var), field)) |
#define LIST_INIT(head) do { \ |
LIST_FIRST((head)) = NULL; \ |
} while (0) |
#define LIST_INSERT_AFTER(listelm, elm, field) do { \ |
if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ |
LIST_NEXT((listelm), field)->field.le_prev = \ |
&LIST_NEXT((elm), field); \ |
LIST_NEXT((listelm), field) = (elm); \ |
(elm)->field.le_prev = &LIST_NEXT((listelm), field); \ |
} while (0) |
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ |
(elm)->field.le_prev = (listelm)->field.le_prev; \ |
LIST_NEXT((elm), field) = (listelm); \ |
*(listelm)->field.le_prev = (elm); \ |
(listelm)->field.le_prev = &LIST_NEXT((elm), field); \ |
} while (0) |
#define LIST_INSERT_HEAD(head, elm, field) do { \ |
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ |
LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ |
LIST_FIRST((head)) = (elm); \ |
(elm)->field.le_prev = &LIST_FIRST((head)); \ |
} while (0) |
#define LIST_NEXT(elm, field) ((elm)->field.le_next) |
#define LIST_REMOVE(elm, field) do { \ |
if (LIST_NEXT((elm), field) != NULL) \ |
LIST_NEXT((elm), field)->field.le_prev = \ |
(elm)->field.le_prev; \ |
*(elm)->field.le_prev = LIST_NEXT((elm), field); \ |
} while (0) |
/* |
* Tail queue declarations. |
*/ |
#define TAILQ_HEAD(name, type) \ |
struct name { \ |
struct type *tqh_first; /* first element */ \ |
struct type **tqh_last; /* addr of last next element */ \ |
} |
#define TAILQ_HEAD_INITIALIZER(head) \ |
{ NULL, &(head).tqh_first } |
#define TAILQ_ENTRY(type) \ |
struct { \ |
struct type *tqe_next; /* next element */ \ |
struct type **tqe_prev; /* address of previous next element */ \ |
} |
/* |
* Tail queue functions. |
*/ |
#define TAILQ_CONCAT(head1, head2, field) do { \ |
if (!TAILQ_EMPTY(head2)) { \ |
*(head1)->tqh_last = (head2)->tqh_first; \ |
(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ |
(head1)->tqh_last = (head2)->tqh_last; \ |
TAILQ_INIT((head2)); \ |
} \ |
} while (0) |
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) |
#define TAILQ_FIRST(head) ((head)->tqh_first) |
#define TAILQ_FOREACH(var, head, field) \ |
for ((var) = TAILQ_FIRST((head)); \ |
(var); \ |
(var) = TAILQ_NEXT((var), field)) |
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ |
for ((var) = TAILQ_LAST((head), headname); \ |
(var); \ |
(var) = TAILQ_PREV((var), headname, field)) |
#define TAILQ_INIT(head) do { \ |
TAILQ_FIRST((head)) = NULL; \ |
(head)->tqh_last = &TAILQ_FIRST((head)); \ |
} while (0) |
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ |
if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ |
TAILQ_NEXT((elm), field)->field.tqe_prev = \ |
&TAILQ_NEXT((elm), field); \ |
else \ |
(head)->tqh_last = &TAILQ_NEXT((elm), field); \ |
TAILQ_NEXT((listelm), field) = (elm); \ |
(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ |
} while (0) |
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ |
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ |
TAILQ_NEXT((elm), field) = (listelm); \ |
*(listelm)->field.tqe_prev = (elm); \ |
(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ |
} while (0) |
#define TAILQ_INSERT_HEAD(head, elm, field) do { \ |
if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ |
TAILQ_FIRST((head))->field.tqe_prev = \ |
&TAILQ_NEXT((elm), field); \ |
else \ |
(head)->tqh_last = &TAILQ_NEXT((elm), field); \ |
TAILQ_FIRST((head)) = (elm); \ |
(elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ |
} while (0) |
#define TAILQ_INSERT_TAIL(head, elm, field) do { \ |
TAILQ_NEXT((elm), field) = NULL; \ |
(elm)->field.tqe_prev = (head)->tqh_last; \ |
*(head)->tqh_last = (elm); \ |
(head)->tqh_last = &TAILQ_NEXT((elm), field); \ |
} while (0) |
#define TAILQ_LAST(head, headname) \ |
(*(((struct headname *)((head)->tqh_last))->tqh_last)) |
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) |
#define TAILQ_PREV(elm, headname, field) \ |
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) |
#define TAILQ_REMOVE(head, elm, field) do { \ |
if ((TAILQ_NEXT((elm), field)) != NULL) \ |
TAILQ_NEXT((elm), field)->field.tqe_prev = \ |
(elm)->field.tqe_prev; \ |
else \ |
(head)->tqh_last = (elm)->field.tqe_prev; \ |
*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ |
} while (0) |
#ifdef _KERNEL |
/* |
* XXX insque() and remque() are an old way of handling certain queues. |
* They bogusly assumes that all queue heads look alike. |
*/ |
struct quehead { |
struct quehead *qh_link; |
struct quehead *qh_rlink; |
}; |
#ifdef __GNUC__ |
static __inline void |
insque(void *a, void *b) |
{ |
struct quehead *element = (struct quehead *)a, |
*head = (struct quehead *)b; |
element->qh_link = head->qh_link; |
element->qh_rlink = head; |
head->qh_link = element; |
element->qh_link->qh_rlink = element; |
} |
static __inline void |
remque(void *a) |
{ |
struct quehead *element = (struct quehead *)a; |
element->qh_link->qh_rlink = element->qh_rlink; |
element->qh_rlink->qh_link = element->qh_link; |
element->qh_rlink = 0; |
} |
#else /* !__GNUC__ */ |
void insque(void *a, void *b); |
void remque(void *a); |
#endif /* __GNUC__ */ |
#endif /* _KERNEL */ |
#endif /* !_SYS_QUEUE_H_ */ |
/contrib/sdk/sources/libc/include/sys/reent.h |
---|
0,0 → 1,841 |
/* This header file provides the reentrancy. */ |
/* WARNING: All identifiers here must begin with an underscore. This file is |
included by stdio.h and others and we therefore must only use identifiers |
in the namespace allotted to us. */ |
#ifndef _SYS_REENT_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _SYS_REENT_H_ |
#include <_ansi.h> |
#include <sys/_types.h> |
#define _NULL 0 |
#ifndef __Long |
#if __LONG_MAX__ == 2147483647L |
#define __Long long |
typedef unsigned __Long __ULong; |
#elif __INT_MAX__ == 2147483647 |
#define __Long int |
typedef unsigned __Long __ULong; |
#endif |
#endif |
#if !defined( __Long) |
#include <sys/types.h> |
#endif |
#ifndef __Long |
#define __Long __int32_t |
typedef __uint32_t __ULong; |
#endif |
struct _reent; |
/* |
* If _REENT_SMALL is defined, we make struct _reent as small as possible, |
* by having nearly everything possible allocated at first use. |
*/ |
struct _Bigint |
{ |
struct _Bigint *_next; |
int _k, _maxwds, _sign, _wds; |
__ULong _x[1]; |
}; |
/* needed by reentrant structure */ |
struct __tm |
{ |
int __tm_sec; |
int __tm_min; |
int __tm_hour; |
int __tm_mday; |
int __tm_mon; |
int __tm_year; |
int __tm_wday; |
int __tm_yday; |
int __tm_isdst; |
}; |
/* |
* atexit() support. |
*/ |
#define _ATEXIT_SIZE 32 /* must be at least 32 to guarantee ANSI conformance */ |
struct _on_exit_args { |
void * _fnargs[_ATEXIT_SIZE]; /* user fn args */ |
void * _dso_handle[_ATEXIT_SIZE]; |
/* Bitmask is set if user function takes arguments. */ |
__ULong _fntypes; /* type of exit routine - |
Must have at least _ATEXIT_SIZE bits */ |
/* Bitmask is set if function was registered via __cxa_atexit. */ |
__ULong _is_cxa; |
}; |
#ifdef _REENT_SMALL |
struct _atexit { |
struct _atexit *_next; /* next in list */ |
int _ind; /* next index in this table */ |
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */ |
struct _on_exit_args * _on_exit_args_ptr; |
}; |
#else |
struct _atexit { |
struct _atexit *_next; /* next in list */ |
int _ind; /* next index in this table */ |
/* Some entries may already have been called, and will be NULL. */ |
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */ |
struct _on_exit_args _on_exit_args; |
}; |
#endif |
/* |
* Stdio buffers. |
* |
* This and __FILE are defined here because we need them for struct _reent, |
* but we don't want stdio.h included when stdlib.h is. |
*/ |
struct __sbuf { |
unsigned char *_base; |
int _size; |
}; |
/* |
* Stdio state variables. |
* |
* The following always hold: |
* |
* if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), |
* _lbfsize is -_bf._size, else _lbfsize is 0 |
* if _flags&__SRD, _w is 0 |
* if _flags&__SWR, _r is 0 |
* |
* This ensures that the getc and putc macros (or inline functions) never |
* try to write or read from a file that is in `read' or `write' mode. |
* (Moreover, they can, and do, automatically switch from read mode to |
* write mode, and back, on "r+" and "w+" files.) |
* |
* _lbfsize is used only to make the inline line-buffered output stream |
* code as compact as possible. |
* |
* _ub, _up, and _ur are used when ungetc() pushes back more characters |
* than fit in the current _bf, or when ungetc() pushes back a character |
* that does not match the previous one in _bf. When this happens, |
* _ub._base becomes non-nil (i.e., a stream has ungetc() data iff |
* _ub._base!=NULL) and _up and _ur save the current values of _p and _r. |
*/ |
#ifdef _REENT_SMALL |
/* |
* struct __sFILE_fake is the start of a struct __sFILE, with only the |
* minimal fields allocated. In __sinit() we really allocate the 3 |
* standard streams, etc., and point away from this fake. |
*/ |
struct __sFILE_fake { |
unsigned char *_p; /* current position in (some) buffer */ |
int _r; /* read space left for getc() */ |
int _w; /* write space left for putc() */ |
short _flags; /* flags, below; this FILE is free if 0 */ |
short _file; /* fileno, if Unix descriptor, else -1 */ |
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ |
int _lbfsize; /* 0 or -_bf._size, for inline putc */ |
struct _reent *_data; |
}; |
/* Following is needed both in libc/stdio and libc/stdlib so we put it |
* here instead of libc/stdio/local.h where it was previously. */ |
extern _VOID _EXFUN(__sinit,(struct _reent *)); |
# define _REENT_SMALL_CHECK_INIT(ptr) \ |
do \ |
{ \ |
if ((ptr) && !(ptr)->__sdidinit) \ |
__sinit (ptr); \ |
} \ |
while (0) |
#else |
# define _REENT_SMALL_CHECK_INIT(ptr) /* nothing */ |
#endif |
struct __sFILE { |
unsigned char *_p; /* current position in (some) buffer */ |
int _r; /* read space left for getc() */ |
int _w; /* write space left for putc() */ |
short _flags; /* flags, below; this FILE is free if 0 */ |
short _file; /* fileno, if Unix descriptor, else -1 */ |
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ |
int _lbfsize; /* 0 or -_bf._size, for inline putc */ |
#ifdef _REENT_SMALL |
struct _reent *_data; |
#endif |
/* operations */ |
_PTR _cookie; /* cookie passed to io functions */ |
_READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR, |
char *, int)); |
_READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR, |
const char *, int)); |
_fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int)); |
int _EXFNPTR(_close, (struct _reent *, _PTR)); |
/* separate buffer for long sequences of ungetc() */ |
struct __sbuf _ub; /* ungetc buffer */ |
unsigned char *_up; /* saved _p when _p is doing ungetc data */ |
int _ur; /* saved _r when _r is counting ungetc data */ |
/* tricks to meet minimum requirements even when malloc() fails */ |
unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ |
unsigned char _nbuf[1]; /* guarantee a getc() buffer */ |
/* separate buffer for fgetline() when line crosses buffer boundary */ |
struct __sbuf _lb; /* buffer for fgetline() */ |
/* Unix stdio files get aligned to block boundaries on fseek() */ |
int _blksize; /* stat.st_blksize (may be != _bf._size) */ |
int _offset; /* current lseek offset */ |
#ifndef _REENT_SMALL |
struct _reent *_data; /* Here for binary compatibility? Remove? */ |
#endif |
#ifndef __SINGLE_THREAD__ |
_flock_t _lock; /* for thread-safety locking */ |
#endif |
_mbstate_t _mbstate; /* for wide char stdio functions. */ |
int _flags2; /* for future use */ |
}; |
#ifdef __CUSTOM_FILE_IO__ |
/* Get custom _FILE definition. */ |
#include <sys/custom_file.h> |
#else /* !__CUSTOM_FILE_IO__ */ |
#ifdef __LARGE64_FILES |
struct __sFILE64 { |
unsigned char *_p; /* current position in (some) buffer */ |
int _r; /* read space left for getc() */ |
int _w; /* write space left for putc() */ |
short _flags; /* flags, below; this FILE is free if 0 */ |
short _file; /* fileno, if Unix descriptor, else -1 */ |
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ |
int _lbfsize; /* 0 or -_bf._size, for inline putc */ |
struct _reent *_data; |
/* operations */ |
_PTR _cookie; /* cookie passed to io functions */ |
_READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR, |
char *, int)); |
_READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR, |
const char *, int)); |
_fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int)); |
int _EXFNPTR(_close, (struct _reent *, _PTR)); |
/* separate buffer for long sequences of ungetc() */ |
struct __sbuf _ub; /* ungetc buffer */ |
unsigned char *_up; /* saved _p when _p is doing ungetc data */ |
int _ur; /* saved _r when _r is counting ungetc data */ |
/* tricks to meet minimum requirements even when malloc() fails */ |
unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ |
unsigned char _nbuf[1]; /* guarantee a getc() buffer */ |
/* separate buffer for fgetline() when line crosses buffer boundary */ |
struct __sbuf _lb; /* buffer for fgetline() */ |
/* Unix stdio files get aligned to block boundaries on fseek() */ |
int _blksize; /* stat.st_blksize (may be != _bf._size) */ |
int _flags2; /* for future use */ |
_off64_t _offset; /* current lseek offset */ |
_fpos64_t _EXFNPTR(_seek64, (struct _reent *, _PTR, _fpos64_t, int)); |
#ifndef __SINGLE_THREAD__ |
_flock_t _lock; /* for thread-safety locking */ |
#endif |
_mbstate_t _mbstate; /* for wide char stdio functions. */ |
}; |
typedef struct __sFILE64 __FILE; |
#else |
typedef struct __sFILE __FILE; |
#endif /* __LARGE64_FILES */ |
#endif /* !__CUSTOM_FILE_IO__ */ |
struct _glue |
{ |
struct _glue *_next; |
int _niobs; |
__FILE *_iobs; |
}; |
/* |
* rand48 family support |
* |
* Copyright (c) 1993 Martin Birgmeier |
* All rights reserved. |
* |
* You may redistribute unmodified or modified versions of this source |
* code provided that the above copyright notice and this and the |
* following conditions are retained. |
* |
* This software is provided ``as is'', and comes with no warranties |
* of any kind. I shall in no event be liable for anything that happens |
* to anyone/anything when using this software. |
*/ |
#define _RAND48_SEED_0 (0x330e) |
#define _RAND48_SEED_1 (0xabcd) |
#define _RAND48_SEED_2 (0x1234) |
#define _RAND48_MULT_0 (0xe66d) |
#define _RAND48_MULT_1 (0xdeec) |
#define _RAND48_MULT_2 (0x0005) |
#define _RAND48_ADD (0x000b) |
struct _rand48 { |
unsigned short _seed[3]; |
unsigned short _mult[3]; |
unsigned short _add; |
#ifdef _REENT_SMALL |
/* Put this in here as well, for good luck. */ |
__extension__ unsigned long long _rand_next; |
#endif |
}; |
/* How big the some arrays are. */ |
#define _REENT_EMERGENCY_SIZE 25 |
#define _REENT_ASCTIME_SIZE 26 |
#define _REENT_SIGNAL_SIZE 24 |
/* |
* struct _reent |
* |
* This structure contains *all* globals needed by the library. |
* It's raison d'etre is to facilitate threads by making all library routines |
* reentrant. IE: All state information is contained here. |
*/ |
#ifdef _REENT_SMALL |
struct _mprec |
{ |
/* used by mprec routines */ |
struct _Bigint *_result; |
int _result_k; |
struct _Bigint *_p5s; |
struct _Bigint **_freelist; |
}; |
struct _misc_reent |
{ |
/* miscellaneous reentrant data */ |
char *_strtok_last; |
_mbstate_t _mblen_state; |
_mbstate_t _wctomb_state; |
_mbstate_t _mbtowc_state; |
char _l64a_buf[8]; |
int _getdate_err; |
_mbstate_t _mbrlen_state; |
_mbstate_t _mbrtowc_state; |
_mbstate_t _mbsrtowcs_state; |
_mbstate_t _wcrtomb_state; |
_mbstate_t _wcsrtombs_state; |
}; |
/* This version of _reent is layed our with "int"s in pairs, to help |
* ports with 16-bit int's but 32-bit pointers, align nicely. */ |
struct _reent |
{ |
/* As an exception to the above put _errno first for binary |
compatibility with non _REENT_SMALL targets. */ |
int _errno; /* local copy of errno */ |
/* FILE is a big struct and may change over time. To try to achieve binary |
compatibility with future versions, put stdin,stdout,stderr here. |
These are pointers into member __sf defined below. */ |
__FILE *_stdin, *_stdout, *_stderr; /* XXX */ |
int _inc; /* used by tmpnam */ |
char *_emergency; |
int __sdidinit; /* 1 means stdio has been init'd */ |
int _current_category; /* unused */ |
_CONST char *_current_locale; /* unused */ |
struct _mprec *_mp; |
void _EXFNPTR(__cleanup, (struct _reent *)); |
int _gamma_signgam; |
/* used by some fp conversion routines */ |
int _cvtlen; /* should be size_t */ |
char *_cvtbuf; |
struct _rand48 *_r48; |
struct __tm *_localtime_buf; |
char *_asctime_buf; |
/* signal info */ |
void (**(_sig_func))(int); |
/* atexit stuff */ |
struct _atexit *_atexit; |
struct _atexit _atexit0; |
struct _glue __sglue; /* root of glue chain */ |
__FILE *__sf; /* file descriptors */ |
struct _misc_reent *_misc; /* strtok, multibyte states */ |
char *_signal_buf; /* strsignal */ |
}; |
extern const struct __sFILE_fake __sf_fake_stdin; |
extern const struct __sFILE_fake __sf_fake_stdout; |
extern const struct __sFILE_fake __sf_fake_stderr; |
# define _REENT_INIT(var) \ |
{ 0, \ |
(__FILE *)&__sf_fake_stdin, \ |
(__FILE *)&__sf_fake_stdout, \ |
(__FILE *)&__sf_fake_stderr, \ |
0, \ |
_NULL, \ |
0, \ |
0, \ |
"C", \ |
_NULL, \ |
_NULL, \ |
0, \ |
0, \ |
_NULL, \ |
_NULL, \ |
_NULL, \ |
_NULL, \ |
_NULL, \ |
_NULL, \ |
{_NULL, 0, {_NULL}, _NULL}, \ |
{_NULL, 0, _NULL}, \ |
_NULL, \ |
_NULL, \ |
_NULL \ |
} |
#define _REENT_INIT_PTR(var) \ |
{ (var)->_stdin = (__FILE *)&__sf_fake_stdin; \ |
(var)->_stdout = (__FILE *)&__sf_fake_stdout; \ |
(var)->_stderr = (__FILE *)&__sf_fake_stderr; \ |
(var)->_errno = 0; \ |
(var)->_inc = 0; \ |
(var)->_emergency = _NULL; \ |
(var)->__sdidinit = 0; \ |
(var)->_current_category = 0; \ |
(var)->_current_locale = "C"; \ |
(var)->_mp = _NULL; \ |
(var)->__cleanup = _NULL; \ |
(var)->_gamma_signgam = 0; \ |
(var)->_cvtlen = 0; \ |
(var)->_cvtbuf = _NULL; \ |
(var)->_r48 = _NULL; \ |
(var)->_localtime_buf = _NULL; \ |
(var)->_asctime_buf = _NULL; \ |
(var)->_sig_func = _NULL; \ |
(var)->_atexit = _NULL; \ |
(var)->_atexit0._next = _NULL; \ |
(var)->_atexit0._ind = 0; \ |
(var)->_atexit0._fns[0] = _NULL; \ |
(var)->_atexit0._on_exit_args_ptr = _NULL; \ |
(var)->__sglue._next = _NULL; \ |
(var)->__sglue._niobs = 0; \ |
(var)->__sglue._iobs = _NULL; \ |
(var)->__sf = 0; \ |
(var)->_misc = _NULL; \ |
(var)->_signal_buf = _NULL; \ |
} |
/* Only built the assert() calls if we are built with debugging. */ |
#if DEBUG |
#include <assert.h> |
#define __reent_assert(x) assert(x) |
#else |
#define __reent_assert(x) ((void)0) |
#endif |
#ifdef __CUSTOM_FILE_IO__ |
#error Custom FILE I/O and _REENT_SMALL not currently supported. |
#endif |
/* Generic _REENT check macro. */ |
#define _REENT_CHECK(var, what, type, size, init) do { \ |
struct _reent *_r = (var); \ |
if (_r->what == NULL) { \ |
_r->what = (type)malloc(size); \ |
__reent_assert(_r->what); \ |
init; \ |
} \ |
} while (0) |
#define _REENT_CHECK_TM(var) \ |
_REENT_CHECK(var, _localtime_buf, struct __tm *, sizeof *((var)->_localtime_buf), \ |
/* nothing */) |
#define _REENT_CHECK_ASCTIME_BUF(var) \ |
_REENT_CHECK(var, _asctime_buf, char *, _REENT_ASCTIME_SIZE, \ |
memset((var)->_asctime_buf, 0, _REENT_ASCTIME_SIZE)) |
/* Handle the dynamically allocated rand48 structure. */ |
#define _REENT_INIT_RAND48(var) do { \ |
struct _reent *_r = (var); \ |
_r->_r48->_seed[0] = _RAND48_SEED_0; \ |
_r->_r48->_seed[1] = _RAND48_SEED_1; \ |
_r->_r48->_seed[2] = _RAND48_SEED_2; \ |
_r->_r48->_mult[0] = _RAND48_MULT_0; \ |
_r->_r48->_mult[1] = _RAND48_MULT_1; \ |
_r->_r48->_mult[2] = _RAND48_MULT_2; \ |
_r->_r48->_add = _RAND48_ADD; \ |
_r->_r48->_rand_next = 1; \ |
} while (0) |
#define _REENT_CHECK_RAND48(var) \ |
_REENT_CHECK(var, _r48, struct _rand48 *, sizeof *((var)->_r48), _REENT_INIT_RAND48((var))) |
#define _REENT_INIT_MP(var) do { \ |
struct _reent *_r = (var); \ |
_r->_mp->_result_k = 0; \ |
_r->_mp->_result = _r->_mp->_p5s = _NULL; \ |
_r->_mp->_freelist = _NULL; \ |
} while (0) |
#define _REENT_CHECK_MP(var) \ |
_REENT_CHECK(var, _mp, struct _mprec *, sizeof *((var)->_mp), _REENT_INIT_MP(var)) |
#define _REENT_CHECK_EMERGENCY(var) \ |
_REENT_CHECK(var, _emergency, char *, _REENT_EMERGENCY_SIZE, /* nothing */) |
#define _REENT_INIT_MISC(var) do { \ |
struct _reent *_r = (var); \ |
_r->_misc->_strtok_last = _NULL; \ |
_r->_misc->_mblen_state.__count = 0; \ |
_r->_misc->_mblen_state.__value.__wch = 0; \ |
_r->_misc->_wctomb_state.__count = 0; \ |
_r->_misc->_wctomb_state.__value.__wch = 0; \ |
_r->_misc->_mbtowc_state.__count = 0; \ |
_r->_misc->_mbtowc_state.__value.__wch = 0; \ |
_r->_misc->_mbrlen_state.__count = 0; \ |
_r->_misc->_mbrlen_state.__value.__wch = 0; \ |
_r->_misc->_mbrtowc_state.__count = 0; \ |
_r->_misc->_mbrtowc_state.__value.__wch = 0; \ |
_r->_misc->_mbsrtowcs_state.__count = 0; \ |
_r->_misc->_mbsrtowcs_state.__value.__wch = 0; \ |
_r->_misc->_wcrtomb_state.__count = 0; \ |
_r->_misc->_wcrtomb_state.__value.__wch = 0; \ |
_r->_misc->_wcsrtombs_state.__count = 0; \ |
_r->_misc->_wcsrtombs_state.__value.__wch = 0; \ |
_r->_misc->_l64a_buf[0] = '\0'; \ |
_r->_misc->_getdate_err = 0; \ |
} while (0) |
#define _REENT_CHECK_MISC(var) \ |
_REENT_CHECK(var, _misc, struct _misc_reent *, sizeof *((var)->_misc), _REENT_INIT_MISC(var)) |
#define _REENT_CHECK_SIGNAL_BUF(var) \ |
_REENT_CHECK(var, _signal_buf, char *, _REENT_SIGNAL_SIZE, /* nothing */) |
#define _REENT_SIGNGAM(ptr) ((ptr)->_gamma_signgam) |
#define _REENT_RAND_NEXT(ptr) ((ptr)->_r48->_rand_next) |
#define _REENT_RAND48_SEED(ptr) ((ptr)->_r48->_seed) |
#define _REENT_RAND48_MULT(ptr) ((ptr)->_r48->_mult) |
#define _REENT_RAND48_ADD(ptr) ((ptr)->_r48->_add) |
#define _REENT_MP_RESULT(ptr) ((ptr)->_mp->_result) |
#define _REENT_MP_RESULT_K(ptr) ((ptr)->_mp->_result_k) |
#define _REENT_MP_P5S(ptr) ((ptr)->_mp->_p5s) |
#define _REENT_MP_FREELIST(ptr) ((ptr)->_mp->_freelist) |
#define _REENT_ASCTIME_BUF(ptr) ((ptr)->_asctime_buf) |
#define _REENT_TM(ptr) ((ptr)->_localtime_buf) |
#define _REENT_EMERGENCY(ptr) ((ptr)->_emergency) |
#define _REENT_STRTOK_LAST(ptr) ((ptr)->_misc->_strtok_last) |
#define _REENT_MBLEN_STATE(ptr) ((ptr)->_misc->_mblen_state) |
#define _REENT_MBTOWC_STATE(ptr)((ptr)->_misc->_mbtowc_state) |
#define _REENT_WCTOMB_STATE(ptr)((ptr)->_misc->_wctomb_state) |
#define _REENT_MBRLEN_STATE(ptr) ((ptr)->_misc->_mbrlen_state) |
#define _REENT_MBRTOWC_STATE(ptr) ((ptr)->_misc->_mbrtowc_state) |
#define _REENT_MBSRTOWCS_STATE(ptr) ((ptr)->_misc->_mbsrtowcs_state) |
#define _REENT_WCRTOMB_STATE(ptr) ((ptr)->_misc->_wcrtomb_state) |
#define _REENT_WCSRTOMBS_STATE(ptr) ((ptr)->_misc->_wcsrtombs_state) |
#define _REENT_L64A_BUF(ptr) ((ptr)->_misc->_l64a_buf) |
#define _REENT_GETDATE_ERR_P(ptr) (&((ptr)->_misc->_getdate_err)) |
#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_signal_buf) |
#else /* !_REENT_SMALL */ |
struct _reent |
{ |
int _errno; /* local copy of errno */ |
/* FILE is a big struct and may change over time. To try to achieve binary |
compatibility with future versions, put stdin,stdout,stderr here. |
These are pointers into member __sf defined below. */ |
__FILE *_stdin, *_stdout, *_stderr; |
int _inc; /* used by tmpnam */ |
char _emergency[_REENT_EMERGENCY_SIZE]; |
int _current_category; /* used by setlocale */ |
_CONST char *_current_locale; |
int __sdidinit; /* 1 means stdio has been init'd */ |
void _EXFNPTR(__cleanup, (struct _reent *)); |
/* used by mprec routines */ |
struct _Bigint *_result; |
int _result_k; |
struct _Bigint *_p5s; |
struct _Bigint **_freelist; |
/* used by some fp conversion routines */ |
int _cvtlen; /* should be size_t */ |
char *_cvtbuf; |
union |
{ |
struct |
{ |
unsigned int _unused_rand; |
char * _strtok_last; |
char _asctime_buf[_REENT_ASCTIME_SIZE]; |
struct __tm _localtime_buf; |
int _gamma_signgam; |
__extension__ unsigned long long _rand_next; |
struct _rand48 _r48; |
_mbstate_t _mblen_state; |
_mbstate_t _mbtowc_state; |
_mbstate_t _wctomb_state; |
char _l64a_buf[8]; |
char _signal_buf[_REENT_SIGNAL_SIZE]; |
int _getdate_err; |
_mbstate_t _mbrlen_state; |
_mbstate_t _mbrtowc_state; |
_mbstate_t _mbsrtowcs_state; |
_mbstate_t _wcrtomb_state; |
_mbstate_t _wcsrtombs_state; |
int _h_errno; |
} _reent; |
/* Two next two fields were once used by malloc. They are no longer |
used. They are used to preserve the space used before so as to |
allow addition of new reent fields and keep binary compatibility. */ |
struct |
{ |
#define _N_LISTS 30 |
unsigned char * _nextf[_N_LISTS]; |
unsigned int _nmalloc[_N_LISTS]; |
} _unused; |
} _new; |
/* atexit stuff */ |
struct _atexit *_atexit; /* points to head of LIFO stack */ |
struct _atexit _atexit0; /* one guaranteed table, required by ANSI */ |
/* signal info */ |
void (**(_sig_func))(int); |
/* These are here last so that __FILE can grow without changing the offsets |
of the above members (on the off chance that future binary compatibility |
would be broken otherwise). */ |
struct _glue __sglue; /* root of glue chain */ |
__FILE __sf[3]; /* first three file descriptors */ |
}; |
#define _REENT_INIT(var) \ |
{ 0, \ |
&(var).__sf[0], \ |
&(var).__sf[1], \ |
&(var).__sf[2], \ |
0, \ |
"", \ |
0, \ |
"C", \ |
0, \ |
_NULL, \ |
_NULL, \ |
0, \ |
_NULL, \ |
_NULL, \ |
0, \ |
_NULL, \ |
{ \ |
{ \ |
0, \ |
_NULL, \ |
"", \ |
{0, 0, 0, 0, 0, 0, 0, 0, 0}, \ |
0, \ |
1, \ |
{ \ |
{_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \ |
{_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, \ |
_RAND48_ADD \ |
}, \ |
{0, {0}}, \ |
{0, {0}}, \ |
{0, {0}}, \ |
"", \ |
"", \ |
0, \ |
{0, {0}}, \ |
{0, {0}}, \ |
{0, {0}}, \ |
{0, {0}}, \ |
{0, {0}} \ |
} \ |
}, \ |
_NULL, \ |
{_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}, \ |
_NULL, \ |
{_NULL, 0, _NULL} \ |
} |
#define _REENT_INIT_PTR(var) \ |
{ (var)->_errno = 0; \ |
(var)->_stdin = &(var)->__sf[0]; \ |
(var)->_stdout = &(var)->__sf[1]; \ |
(var)->_stderr = &(var)->__sf[2]; \ |
(var)->_inc = 0; \ |
memset(&(var)->_emergency, 0, sizeof((var)->_emergency)); \ |
(var)->_current_category = 0; \ |
(var)->_current_locale = "C"; \ |
(var)->__sdidinit = 0; \ |
(var)->__cleanup = _NULL; \ |
(var)->_result = _NULL; \ |
(var)->_result_k = 0; \ |
(var)->_p5s = _NULL; \ |
(var)->_freelist = _NULL; \ |
(var)->_cvtlen = 0; \ |
(var)->_cvtbuf = _NULL; \ |
(var)->_new._reent._unused_rand = 0; \ |
(var)->_new._reent._strtok_last = _NULL; \ |
(var)->_new._reent._asctime_buf[0] = 0; \ |
memset(&(var)->_new._reent._localtime_buf, 0, sizeof((var)->_new._reent._localtime_buf)); \ |
(var)->_new._reent._gamma_signgam = 0; \ |
(var)->_new._reent._rand_next = 1; \ |
(var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \ |
(var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \ |
(var)->_new._reent._r48._seed[2] = _RAND48_SEED_2; \ |
(var)->_new._reent._r48._mult[0] = _RAND48_MULT_0; \ |
(var)->_new._reent._r48._mult[1] = _RAND48_MULT_1; \ |
(var)->_new._reent._r48._mult[2] = _RAND48_MULT_2; \ |
(var)->_new._reent._r48._add = _RAND48_ADD; \ |
(var)->_new._reent._mblen_state.__count = 0; \ |
(var)->_new._reent._mblen_state.__value.__wch = 0; \ |
(var)->_new._reent._mbtowc_state.__count = 0; \ |
(var)->_new._reent._mbtowc_state.__value.__wch = 0; \ |
(var)->_new._reent._wctomb_state.__count = 0; \ |
(var)->_new._reent._wctomb_state.__value.__wch = 0; \ |
(var)->_new._reent._mbrlen_state.__count = 0; \ |
(var)->_new._reent._mbrlen_state.__value.__wch = 0; \ |
(var)->_new._reent._mbrtowc_state.__count = 0; \ |
(var)->_new._reent._mbrtowc_state.__value.__wch = 0; \ |
(var)->_new._reent._mbsrtowcs_state.__count = 0; \ |
(var)->_new._reent._mbsrtowcs_state.__value.__wch = 0; \ |
(var)->_new._reent._wcrtomb_state.__count = 0; \ |
(var)->_new._reent._wcrtomb_state.__value.__wch = 0; \ |
(var)->_new._reent._wcsrtombs_state.__count = 0; \ |
(var)->_new._reent._wcsrtombs_state.__value.__wch = 0; \ |
(var)->_new._reent._l64a_buf[0] = '\0'; \ |
(var)->_new._reent._signal_buf[0] = '\0'; \ |
(var)->_new._reent._getdate_err = 0; \ |
(var)->_atexit = _NULL; \ |
(var)->_atexit0._next = _NULL; \ |
(var)->_atexit0._ind = 0; \ |
(var)->_atexit0._fns[0] = _NULL; \ |
(var)->_atexit0._on_exit_args._fntypes = 0; \ |
(var)->_atexit0._on_exit_args._fnargs[0] = _NULL; \ |
(var)->_sig_func = _NULL; \ |
(var)->__sglue._next = _NULL; \ |
(var)->__sglue._niobs = 0; \ |
(var)->__sglue._iobs = _NULL; \ |
memset(&(var)->__sf, 0, sizeof((var)->__sf)); \ |
} |
#define _REENT_CHECK_RAND48(ptr) /* nothing */ |
#define _REENT_CHECK_MP(ptr) /* nothing */ |
#define _REENT_CHECK_TM(ptr) /* nothing */ |
#define _REENT_CHECK_ASCTIME_BUF(ptr) /* nothing */ |
#define _REENT_CHECK_EMERGENCY(ptr) /* nothing */ |
#define _REENT_CHECK_MISC(ptr) /* nothing */ |
#define _REENT_CHECK_SIGNAL_BUF(ptr) /* nothing */ |
#define _REENT_SIGNGAM(ptr) ((ptr)->_new._reent._gamma_signgam) |
#define _REENT_RAND_NEXT(ptr) ((ptr)->_new._reent._rand_next) |
#define _REENT_RAND48_SEED(ptr) ((ptr)->_new._reent._r48._seed) |
#define _REENT_RAND48_MULT(ptr) ((ptr)->_new._reent._r48._mult) |
#define _REENT_RAND48_ADD(ptr) ((ptr)->_new._reent._r48._add) |
#define _REENT_MP_RESULT(ptr) ((ptr)->_result) |
#define _REENT_MP_RESULT_K(ptr) ((ptr)->_result_k) |
#define _REENT_MP_P5S(ptr) ((ptr)->_p5s) |
#define _REENT_MP_FREELIST(ptr) ((ptr)->_freelist) |
#define _REENT_ASCTIME_BUF(ptr) ((ptr)->_new._reent._asctime_buf) |
#define _REENT_TM(ptr) (&(ptr)->_new._reent._localtime_buf) |
#define _REENT_EMERGENCY(ptr) ((ptr)->_emergency) |
#define _REENT_STRTOK_LAST(ptr) ((ptr)->_new._reent._strtok_last) |
#define _REENT_MBLEN_STATE(ptr) ((ptr)->_new._reent._mblen_state) |
#define _REENT_MBTOWC_STATE(ptr)((ptr)->_new._reent._mbtowc_state) |
#define _REENT_WCTOMB_STATE(ptr)((ptr)->_new._reent._wctomb_state) |
#define _REENT_MBRLEN_STATE(ptr)((ptr)->_new._reent._mbrlen_state) |
#define _REENT_MBRTOWC_STATE(ptr)((ptr)->_new._reent._mbrtowc_state) |
#define _REENT_MBSRTOWCS_STATE(ptr)((ptr)->_new._reent._mbsrtowcs_state) |
#define _REENT_WCRTOMB_STATE(ptr)((ptr)->_new._reent._wcrtomb_state) |
#define _REENT_WCSRTOMBS_STATE(ptr)((ptr)->_new._reent._wcsrtombs_state) |
#define _REENT_L64A_BUF(ptr) ((ptr)->_new._reent._l64a_buf) |
#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_new._reent._signal_buf) |
#define _REENT_GETDATE_ERR_P(ptr) (&((ptr)->_new._reent._getdate_err)) |
#endif /* !_REENT_SMALL */ |
/* This value is used in stdlib/misc.c. reent/reent.c has to know it |
as well to make sure the freelist is correctly free'd. Therefore |
we define it here, rather than in stdlib/misc.c, as before. */ |
#define _Kmax (sizeof (size_t) << 3) |
/* |
* All references to struct _reent are via this pointer. |
* Internally, newlib routines that need to reference it should use _REENT. |
*/ |
#ifndef __ATTRIBUTE_IMPURE_PTR__ |
#define __ATTRIBUTE_IMPURE_PTR__ |
#endif |
extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__; |
extern struct _reent *_CONST _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__; |
void _reclaim_reent _PARAMS ((struct _reent *)); |
/* #define _REENT_ONLY define this to get only reentrant routines */ |
static inline struct _reent *__getreent(void) |
{ |
struct _reent *ent; |
__asm__ __volatile__( |
"movl %%fs:16, %0" |
:"=r"(ent)); |
return ent; |
}; |
# define _REENT (__getreent()) |
#define _GLOBAL_REENT _global_impure_ptr |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_REENT_H_ */ |
/contrib/sdk/sources/libc/include/sys/resource.h |
---|
0,0 → 1,15 |
#ifndef _SYS_RESOURCE_H_ |
#define _SYS_RESOURCE_H_ |
#include <sys/time.h> |
#define RUSAGE_SELF 0 /* calling process */ |
#define RUSAGE_CHILDREN -1 /* terminated child processes */ |
struct rusage { |
struct timeval ru_utime; /* user time used */ |
struct timeval ru_stime; /* system time used */ |
}; |
#endif |
/contrib/sdk/sources/libc/include/sys/sched.h |
---|
0,0 → 1,67 |
/* |
* Written by Joel Sherrill <joel@OARcorp.com>. |
* |
* COPYRIGHT (c) 1989-2010. |
* On-Line Applications Research Corporation (OAR). |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION |
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS |
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
* $Id: sched.h,v 1.3 2010/04/01 18:33:37 jjohnstn Exp $ |
*/ |
#ifndef _SYS_SCHED_H_ |
#define _SYS_SCHED_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* Scheduling Policies */ |
/* Open Group Specifications Issue 6 */ |
#if defined(__CYGWIN__) |
#define SCHED_OTHER 3 |
#else |
#define SCHED_OTHER 0 |
#endif |
#define SCHED_FIFO 1 |
#define SCHED_RR 2 |
#if defined(_POSIX_SPORADIC_SERVER) |
#define SCHED_SPORADIC 4 |
#endif |
/* Scheduling Parameters */ |
/* Open Group Specifications Issue 6 */ |
struct sched_param { |
int sched_priority; /* Process execution scheduling priority */ |
#if defined(_POSIX_SPORADIC_SERVER) || defined(_POSIX_THREAD_SPORADIC_SERVER) |
int sched_ss_low_priority; /* Low scheduling priority for sporadic */ |
/* server */ |
struct timespec sched_ss_repl_period; |
/* Replenishment period for sporadic server */ |
struct timespec sched_ss_init_budget; |
/* Initial budget for sporadic server */ |
int sched_ss_max_repl; /* Maximum pending replenishments for */ |
/* sporadic server */ |
#endif |
}; |
#ifdef __cplusplus |
} |
#endif |
#endif |
/* end of include file */ |
/contrib/sdk/sources/libc/include/sys/signal.h |
---|
0,0 → 1,311 |
/* sys/signal.h */ |
#ifndef _SYS_SIGNAL_H |
#define _SYS_SIGNAL_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include "_ansi.h" |
#include <sys/features.h> |
#include <sys/types.h> |
/* #ifndef __STRICT_ANSI__*/ |
typedef unsigned long sigset_t; |
#if defined(__rtems__) |
#if defined(_POSIX_REALTIME_SIGNALS) |
/* sigev_notify values |
NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */ |
#define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */ |
/* when the event of interest occurs. */ |
#define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */ |
/* value, shall be delivered when the event of */ |
/* interest occurs. */ |
#define SIGEV_THREAD 3 /* A notification function shall be called to */ |
/* perform notification. */ |
/* Signal Generation and Delivery, P1003.1b-1993, p. 63 |
NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and |
sigev_notify_attributes to the sigevent structure. */ |
union sigval { |
int sival_int; /* Integer signal value */ |
void *sival_ptr; /* Pointer signal value */ |
}; |
struct sigevent { |
int sigev_notify; /* Notification type */ |
int sigev_signo; /* Signal number */ |
union sigval sigev_value; /* Signal value */ |
#if defined(_POSIX_THREADS) |
void (*sigev_notify_function)( union sigval ); |
/* Notification function */ |
pthread_attr_t *sigev_notify_attributes; /* Notification Attributes */ |
#endif |
}; |
/* Signal Actions, P1003.1b-1993, p. 64 */ |
/* si_code values, p. 66 */ |
#define SI_USER 1 /* Sent by a user. kill(), abort(), etc */ |
#define SI_QUEUE 2 /* Sent by sigqueue() */ |
#define SI_TIMER 3 /* Sent by expiration of a timer_settime() timer */ |
#define SI_ASYNCIO 4 /* Indicates completion of asycnhronous IO */ |
#define SI_MESGQ 5 /* Indicates arrival of a message at an empty queue */ |
typedef struct { |
int si_signo; /* Signal number */ |
int si_code; /* Cause of the signal */ |
union sigval si_value; /* Signal value */ |
} siginfo_t; |
#endif |
/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */ |
#define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children stop */ |
#define SA_SIGINFO 2 /* Invoke the signal catching function with */ |
/* three arguments instead of one. */ |
/* struct sigaction notes from POSIX: |
* |
* (1) Routines stored in sa_handler should take a single int as |
* their argument although the POSIX standard does not require this. |
* This is not longer true since at least POSIX.1-2008 |
* (2) The fields sa_handler and sa_sigaction may overlap, and a conforming |
* application should not use both simultaneously. |
*/ |
typedef void (*_sig_func_ptr)(int); |
struct sigaction { |
int sa_flags; /* Special flags to affect behavior of signal */ |
sigset_t sa_mask; /* Additional set of signals to be blocked */ |
/* during execution of signal-catching */ |
/* function. */ |
union { |
_sig_func_ptr _handler; /* SIG_DFL, SIG_IGN, or pointer to a function */ |
#if defined(_POSIX_REALTIME_SIGNALS) |
void (*_sigaction)( int, siginfo_t *, void * ); |
#endif |
} _signal_handlers; |
}; |
#define sa_handler _signal_handlers._handler |
#if defined(_POSIX_REALTIME_SIGNALS) |
#define sa_sigaction _signal_handlers._sigaction |
#endif |
#elif defined(__CYGWIN__) |
#include <cygwin/signal.h> |
#else |
#define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */ |
typedef void (*_sig_func_ptr)(int); |
struct sigaction |
{ |
_sig_func_ptr sa_handler; |
sigset_t sa_mask; |
int sa_flags; |
}; |
#endif /* defined(__rtems__) */ |
#define SIG_SETMASK 0 /* set mask with sigprocmask() */ |
#define SIG_BLOCK 1 /* set of signals to block */ |
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */ |
/* These depend upon the type of sigset_t, which right now |
is always a long.. They're in the POSIX namespace, but |
are not ANSI. */ |
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0) |
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0) |
#define sigemptyset(what) (*(what) = 0, 0) |
#define sigfillset(what) (*(what) = ~(0), 0) |
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0) |
int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset)); |
#if defined(_POSIX_THREADS) |
int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset)); |
#endif |
/* protos for functions found in winsup sources for CYGWIN */ |
#if defined(__CYGWIN__) || defined(__rtems__) |
#undef sigaddset |
#undef sigdelset |
#undef sigemptyset |
#undef sigfillset |
#undef sigismember |
int _EXFUN(kill, (pid_t, int)); |
int _EXFUN(killpg, (pid_t, int)); |
int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *)); |
int _EXFUN(sigaddset, (sigset_t *, const int)); |
int _EXFUN(sigdelset, (sigset_t *, const int)); |
int _EXFUN(sigismember, (const sigset_t *, int)); |
int _EXFUN(sigfillset, (sigset_t *)); |
int _EXFUN(sigemptyset, (sigset_t *)); |
int _EXFUN(sigpending, (sigset_t *)); |
int _EXFUN(sigsuspend, (const sigset_t *)); |
int _EXFUN(sigpause, (int)); |
#if defined(_POSIX_THREADS) |
#ifdef __CYGWIN__ |
# ifndef _CYGWIN_TYPES_H |
# error You need the winsup sources or a cygwin installation to compile the cygwin version of newlib. |
# endif |
#endif |
int _EXFUN(pthread_kill, (pthread_t thread, int sig)); |
#endif |
#if defined(_POSIX_REALTIME_SIGNALS) |
/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 |
NOTE: P1003.1c/D10, p. 39 adds sigwait(). */ |
int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info)); |
int _EXFUN(sigtimedwait, |
(const sigset_t *set, siginfo_t *info, const struct timespec *timeout) |
); |
int _EXFUN(sigwait, (const sigset_t *set, int *sig)); |
/* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */ |
int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value)); |
#endif /* defined(_POSIX_REALTIME_SIGNALS) */ |
#endif /* defined(__CYGWIN__) || defined(__rtems__) */ |
/* #endif __STRICT_ANSI__ */ |
#if defined(___AM29K__) |
/* These all need to be defined for ANSI C, but I don't think they are |
meaningful. */ |
#define SIGABRT 1 |
#define SIGFPE 1 |
#define SIGILL 1 |
#define SIGINT 1 |
#define SIGSEGV 1 |
#define SIGTERM 1 |
/* These need to be defined for POSIX, and some others do too. */ |
#define SIGHUP 1 |
#define SIGQUIT 1 |
#define NSIG 2 |
#elif defined(__GO32__) |
#define SIGINT 1 |
#define SIGKILL 2 |
#define SIGPIPE 3 |
#define SIGFPE 4 |
#define SIGHUP 5 |
#define SIGTERM 6 |
#define SIGSEGV 7 |
#define SIGTSTP 8 |
#define SIGQUIT 9 |
#define SIGTRAP 10 |
#define SIGILL 11 |
#define SIGEMT 12 |
#define SIGALRM 13 |
#define SIGBUS 14 |
#define SIGLOST 15 |
#define SIGSTOP 16 |
#define SIGABRT 17 |
#define SIGUSR1 18 |
#define SIGUSR2 19 |
#define NSIG 20 |
#elif !defined(SIGTRAP) |
#define SIGHUP 1 /* hangup */ |
#define SIGINT 2 /* interrupt */ |
#define SIGQUIT 3 /* quit */ |
#define SIGILL 4 /* illegal instruction (not reset when caught) */ |
#define SIGTRAP 5 /* trace trap (not reset when caught) */ |
#define SIGIOT 6 /* IOT instruction */ |
#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ |
#define SIGEMT 7 /* EMT instruction */ |
#define SIGFPE 8 /* floating point exception */ |
#define SIGKILL 9 /* kill (cannot be caught or ignored) */ |
#define SIGBUS 10 /* bus error */ |
#define SIGSEGV 11 /* segmentation violation */ |
#define SIGSYS 12 /* bad argument to system call */ |
#define SIGPIPE 13 /* write on a pipe with no one to read it */ |
#define SIGALRM 14 /* alarm clock */ |
#define SIGTERM 15 /* software termination signal from kill */ |
#if defined(__rtems__) |
#define SIGURG 16 /* urgent condition on IO channel */ |
#define SIGSTOP 17 /* sendable stop signal not from tty */ |
#define SIGTSTP 18 /* stop signal from tty */ |
#define SIGCONT 19 /* continue a stopped process */ |
#define SIGCHLD 20 /* to parent on child stop or exit */ |
#define SIGCLD 20 /* System V name for SIGCHLD */ |
#define SIGTTIN 21 /* to readers pgrp upon background tty read */ |
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ |
#define SIGIO 23 /* input/output possible signal */ |
#define SIGPOLL SIGIO /* System V name for SIGIO */ |
#define SIGWINCH 24 /* window changed */ |
#define SIGUSR1 25 /* user defined signal 1 */ |
#define SIGUSR2 26 /* user defined signal 2 */ |
/* Real-Time Signals Range, P1003.1b-1993, p. 61 |
NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX |
(which is a minimum of 8) signals. |
*/ |
#define SIGRTMIN 27 |
#define SIGRTMAX 31 |
#define __SIGFIRSTNOTRT SIGHUP |
#define __SIGLASTNOTRT SIGUSR2 |
#define NSIG 32 /* signal 0 implied */ |
#elif defined(__svr4__) |
/* svr4 specifics. different signals above 15, and sigaction. */ |
#define SIGUSR1 16 |
#define SIGUSR2 17 |
#define SIGCLD 18 |
#define SIGPWR 19 |
#define SIGWINCH 20 |
#define SIGPOLL 22 /* 20 for x.out binaries!!!! */ |
#define SIGSTOP 23 /* sendable stop signal not from tty */ |
#define SIGTSTP 24 /* stop signal from tty */ |
#define SIGCONT 25 /* continue a stopped process */ |
#define SIGTTIN 26 /* to readers pgrp upon background tty read */ |
#define SIGTTOU 27 /* like TTIN for output if (tp->t_local<OSTOP) */ |
#define NSIG 28 |
#else |
#define SIGURG 16 /* urgent condition on IO channel */ |
#define SIGSTOP 17 /* sendable stop signal not from tty */ |
#define SIGTSTP 18 /* stop signal from tty */ |
#define SIGCONT 19 /* continue a stopped process */ |
#define SIGCHLD 20 /* to parent on child stop or exit */ |
#define SIGCLD 20 /* System V name for SIGCHLD */ |
#define SIGTTIN 21 /* to readers pgrp upon background tty read */ |
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ |
#define SIGIO 23 /* input/output possible signal */ |
#define SIGPOLL SIGIO /* System V name for SIGIO */ |
#define SIGXCPU 24 /* exceeded CPU time limit */ |
#define SIGXFSZ 25 /* exceeded file size limit */ |
#define SIGVTALRM 26 /* virtual time alarm */ |
#define SIGPROF 27 /* profiling time alarm */ |
#define SIGWINCH 28 /* window changed */ |
#define SIGLOST 29 /* resource lost (eg, record-lock lost) */ |
#define SIGUSR1 30 /* user defined signal 1 */ |
#define SIGUSR2 31 /* user defined signal 2 */ |
#define NSIG 32 /* signal 0 implied */ |
#endif |
#endif |
#ifdef __cplusplus |
} |
#endif |
#ifndef _SIGNAL_H_ |
/* Some applications take advantage of the fact that <sys/signal.h> |
* and <signal.h> are equivalent in glibc. Allow for that here. */ |
#include <signal.h> |
#endif |
#endif /* _SYS_SIGNAL_H */ |
/contrib/sdk/sources/libc/include/sys/stat.h |
---|
0,0 → 1,183 |
#ifndef _SYS_STAT_H |
#define _SYS_STAT_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <_ansi.h> |
#include <time.h> |
#include <sys/types.h> |
/* dj's stat defines _STAT_H_ */ |
#ifndef _STAT_H_ |
/* It is intended that the layout of this structure not change when the |
sizes of any of the basic types change (short, int, long) [via a compile |
time option]. */ |
#ifdef __CYGWIN__ |
#include <cygwin/stat.h> |
#ifdef _COMPILING_NEWLIB |
#define stat64 __stat64 |
#endif |
#else |
struct stat |
{ |
dev_t st_dev; |
ino_t st_ino; |
mode_t st_mode; |
nlink_t st_nlink; |
uid_t st_uid; |
gid_t st_gid; |
dev_t st_rdev; |
off_t st_size; |
#if defined(__rtems__) |
struct timespec st_atim; |
struct timespec st_mtim; |
struct timespec st_ctim; |
blksize_t st_blksize; |
blkcnt_t st_blocks; |
#else |
/* SysV/sco doesn't have the rest... But Solaris, eabi does. */ |
#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__) |
time_t st_atime; |
time_t st_mtime; |
time_t st_ctime; |
#else |
time_t st_atime; |
long st_spare1; |
time_t st_mtime; |
long st_spare2; |
time_t st_ctime; |
long st_spare3; |
long st_blksize; |
long st_blocks; |
long st_spare4[2]; |
#endif |
#endif |
}; |
#if defined(__rtems__) |
#define st_atime st_atim.tv_sec |
#define st_ctime st_ctim.tv_sec |
#define st_mtime st_mtim.tv_sec |
#endif |
#endif |
#define _IFMT 0170000 /* type of file */ |
#define _IFDIR 0040000 /* directory */ |
#define _IFCHR 0020000 /* character special */ |
#define _IFBLK 0060000 /* block special */ |
#define _IFREG 0100000 /* regular */ |
#define _IFLNK 0120000 /* symbolic link */ |
#define _IFSOCK 0140000 /* socket */ |
#define _IFIFO 0010000 /* fifo */ |
#define S_BLKSIZE 1024 /* size of a block */ |
#define S_ISUID 0004000 /* set user id on execution */ |
#define S_ISGID 0002000 /* set group id on execution */ |
#define S_ISVTX 0001000 /* save swapped text even after use */ |
#ifndef _POSIX_SOURCE |
#define S_IREAD 0000400 /* read permission, owner */ |
#define S_IWRITE 0000200 /* write permission, owner */ |
#define S_IEXEC 0000100 /* execute/search permission, owner */ |
#define S_ENFMT 0002000 /* enforcement-mode locking */ |
#endif /* !_POSIX_SOURCE */ |
#define S_IFMT _IFMT |
#define S_IFDIR _IFDIR |
#define S_IFCHR _IFCHR |
#define S_IFBLK _IFBLK |
#define S_IFREG _IFREG |
#define S_IFLNK _IFLNK |
#define S_IFSOCK _IFSOCK |
#define S_IFIFO _IFIFO |
#ifdef _WIN32 |
/* The Windows header files define _S_ forms of these, so we do too |
for easier portability. */ |
#define _S_IFMT _IFMT |
#define _S_IFDIR _IFDIR |
#define _S_IFCHR _IFCHR |
#define _S_IFIFO _IFIFO |
#define _S_IFREG _IFREG |
#define _S_IREAD 0000400 |
#define _S_IWRITE 0000200 |
#define _S_IEXEC 0000100 |
#endif |
#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) |
#define S_IRUSR 0000400 /* read permission, owner */ |
#define S_IWUSR 0000200 /* write permission, owner */ |
#define S_IXUSR 0000100/* execute/search permission, owner */ |
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) |
#define S_IRGRP 0000040 /* read permission, group */ |
#define S_IWGRP 0000020 /* write permission, grougroup */ |
#define S_IXGRP 0000010/* execute/search permission, group */ |
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) |
#define S_IROTH 0000004 /* read permission, other */ |
#define S_IWOTH 0000002 /* write permission, other */ |
#define S_IXOTH 0000001/* execute/search permission, other */ |
#ifndef _POSIX_SOURCE |
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */ |
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */ |
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */ |
#endif |
#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK) |
#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR) |
#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR) |
#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO) |
#define S_ISREG(m) (((m)&_IFMT) == _IFREG) |
#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK) |
#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK) |
#if defined(__CYGWIN__) |
/* Special tv_nsec values for futimens(2) and utimensat(2). */ |
#define UTIME_NOW -2L |
#define UTIME_OMIT -1L |
#endif |
int _EXFUN(chmod,( const char *__path, mode_t __mode )); |
int _EXFUN(fchmod,(int __fd, mode_t __mode)); |
int _EXFUN(fstat,( int __fd, struct stat *__sbuf )); |
int _EXFUN(mkdir,( const char *_path, mode_t __mode )); |
int _EXFUN(mkfifo,( const char *__path, mode_t __mode )); |
int _EXFUN(stat,( const char *__path, struct stat *__sbuf )); |
mode_t _EXFUN(umask,( mode_t __mask )); |
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__) |
int _EXFUN(lstat,( const char *__path, struct stat *__buf )); |
int _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev )); |
#endif |
#if defined (__CYGWIN__) && !defined(__INSIDE_CYGWIN__) |
int _EXFUN(fchmodat, (int, const char *, mode_t, int)); |
int _EXFUN(fstatat, (int, const char *, struct stat *, int)); |
int _EXFUN(mkdirat, (int, const char *, mode_t)); |
int _EXFUN(mkfifoat, (int, const char *, mode_t)); |
int _EXFUN(mknodat, (int, const char *, mode_t, dev_t)); |
int _EXFUN(utimensat, (int, const char *, const struct timespec *, int)); |
int _EXFUN(futimens, (int, const struct timespec *)); |
#endif |
/* Provide prototypes for most of the _<systemcall> names that are |
provided in newlib for some compilers. */ |
#ifdef _COMPILING_NEWLIB |
int _EXFUN(_fstat,( int __fd, struct stat *__sbuf )); |
int _EXFUN(_stat,( const char *__path, struct stat *__sbuf )); |
#ifdef __LARGE64_FILES |
struct stat64; |
int _EXFUN(_fstat64,( int __fd, struct stat64 *__sbuf )); |
#endif |
#endif |
#endif /* !_STAT_H_ */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_STAT_H */ |
/contrib/sdk/sources/libc/include/sys/stdio.h |
---|
0,0 → 1,27 |
#ifndef _NEWLIB_STDIO_H |
#define _NEWLIB_STDIO_H |
#include <sys/lock.h> |
#include <sys/reent.h> |
/* Internal locking macros, used to protect stdio functions. In the |
general case, expand to nothing. Use __SSTR flag in FILE _flags to |
detect if FILE is private to sprintf/sscanf class of functions; if |
set then do nothing as lock is not initialised. */ |
#if !defined(_flockfile) |
//#ifndef __SINGLE_THREAD__ |
//# define _flockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_acquire_recursive((fp)->_lock)) |
//#else |
# define _flockfile(fp) (_CAST_VOID 0) |
//#endif |
#endif |
#if !defined(_funlockfile) |
#ifndef __SINGLE_THREAD__ |
# define _funlockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_release_recursive((fp)->_lock)) |
#else |
# define _funlockfile(fp) (_CAST_VOID 0) |
#endif |
#endif |
#endif /* _NEWLIB_STDIO_H */ |
/contrib/sdk/sources/libc/include/sys/string.h |
---|
0,0 → 1,2 |
/* This is a dummy <sys/string.h> used as a placeholder for |
systems that need to have a special header file. */ |
/contrib/sdk/sources/libc/include/sys/syslimits.h |
---|
0,0 → 1,65 |
/* |
* Copyright (c) 1988, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)syslimits.h 8.1 (Berkeley) 6/2/93 |
* $FreeBSD: src/sys/sys/syslimits.h,v 1.10 2001/06/18 20:24:54 wollman Exp $ |
*/ |
#ifndef _SYS_SYSLIMITS_H_ |
#define _SYS_SYSLIMITS_H_ |
#define ARG_MAX 65536 /* max bytes for an exec function */ |
#ifndef CHILD_MAX |
#define CHILD_MAX 40 /* max simultaneous processes */ |
#endif |
#define LINK_MAX 32767 /* max file link count */ |
#define MAX_CANON 255 /* max bytes in term canon input line */ |
#define MAX_INPUT 255 /* max bytes in terminal input */ |
#define NAME_MAX 255 /* max bytes in a file name */ |
#define NGROUPS_MAX 16 /* max supplemental group id's */ |
#ifndef OPEN_MAX |
#define OPEN_MAX 64 /* max open files per process */ |
#endif |
#define PATH_MAX 1024 /* max bytes in pathname */ |
#define PIPE_BUF 512 /* max bytes for atomic pipe writes */ |
#define IOV_MAX 1024 /* max elements in i/o vector */ |
#define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */ |
#define BC_DIM_MAX 2048 /* max array elements in bc(1) */ |
#define BC_SCALE_MAX 99 /* max scale value in bc(1) */ |
#define BC_STRING_MAX 1000 /* max const string length in bc(1) */ |
#define COLL_WEIGHTS_MAX 0 /* max weights for order keyword */ |
#define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */ |
#define LINE_MAX 2048 /* max bytes in an input line */ |
#define RE_DUP_MAX 255 /* max RE's in interval notation */ |
#endif |
/contrib/sdk/sources/libc/include/sys/time.h |
---|
0,0 → 1,84 |
/* time.h -- An implementation of the standard Unix <sys/time.h> file. |
Written by Geoffrey Noer <noer@cygnus.com> |
Public domain; no rights reserved. */ |
#ifndef _SYS_TIME_H_ |
#define _SYS_TIME_H_ |
#include <_ansi.h> |
#include <sys/types.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
#ifndef _WINSOCK_H |
#define _TIMEVAL_DEFINED |
struct timeval { |
time_t tv_sec; |
suseconds_t tv_usec; |
}; |
struct timezone { |
int tz_minuteswest; |
int tz_dsttime; |
}; |
#ifdef __CYGWIN__ |
#include <cygwin/sys_time.h> |
#endif /* __CYGWIN__ */ |
#endif /* _WINSOCK_H */ |
#define ITIMER_REAL 0 |
#define ITIMER_VIRTUAL 1 |
#define ITIMER_PROF 2 |
struct itimerval { |
struct timeval it_interval; |
struct timeval it_value; |
}; |
/* BSD time macros used by RTEMS code */ |
#if defined (__rtems__) || defined (__CYGWIN__) |
/* Convenience macros for operations on timevals. |
NOTE: `timercmp' does not work for >= or <=. */ |
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) |
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) |
#define timercmp(a, b, CMP) \ |
(((a)->tv_sec == (b)->tv_sec) ? \ |
((a)->tv_usec CMP (b)->tv_usec) : \ |
((a)->tv_sec CMP (b)->tv_sec)) |
#define timeradd(a, b, result) \ |
do { \ |
(result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ |
(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ |
if ((result)->tv_usec >= 1000000) \ |
{ \ |
++(result)->tv_sec; \ |
(result)->tv_usec -= 1000000; \ |
} \ |
} while (0) |
#define timersub(a, b, result) \ |
do { \ |
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ |
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ |
if ((result)->tv_usec < 0) { \ |
--(result)->tv_sec; \ |
(result)->tv_usec += 1000000; \ |
} \ |
} while (0) |
#endif /* defined (__rtems__) || defined (__CYGWIN__) */ |
int _EXFUN(gettimeofday, (struct timeval *__p, void *__tz)); |
int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *)); |
int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp)); |
int _EXFUN(getitimer, (int __which, struct itimerval *__value)); |
int _EXFUN(setitimer, (int __which, const struct itimerval *__value, |
struct itimerval *__ovalue)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_TIME_H_ */ |
/contrib/sdk/sources/libc/include/sys/timeb.h |
---|
0,0 → 1,39 |
/* timeb.h -- An implementation of the standard Unix <sys/timeb.h> file. |
Written by Ian Lance Taylor <ian@cygnus.com> |
Public domain; no rights reserved. |
<sys/timeb.h> declares the structure used by the ftime function, as |
well as the ftime function itself. Newlib does not provide an |
implementation of ftime. */ |
#ifndef _SYS_TIMEB_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _SYS_TIMEB_H |
#include <_ansi.h> |
#include <machine/types.h> |
#ifndef __time_t_defined |
typedef _TIME_T_ time_t; |
#define __time_t_defined |
#endif |
struct timeb |
{ |
time_t time; |
unsigned short millitm; |
short timezone; |
short dstflag; |
}; |
extern int ftime _PARAMS ((struct timeb *)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* ! defined (_SYS_TIMEB_H) */ |
/contrib/sdk/sources/libc/include/sys/times.h |
---|
0,0 → 1,28 |
#ifndef _SYS_TIMES_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _SYS_TIMES_H |
#include <_ansi.h> |
#include <machine/types.h> |
#ifndef __clock_t_defined |
typedef _CLOCK_T_ clock_t; |
#define __clock_t_defined |
#endif |
/* Get Process Times, P1003.1b-1993, p. 92 */ |
struct tms { |
clock_t tms_utime; /* user time */ |
clock_t tms_stime; /* system time */ |
clock_t tms_cutime; /* user time, children */ |
clock_t tms_cstime; /* system time, children */ |
}; |
clock_t _EXFUN(times,(struct tms *)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* !_SYS_TIMES_H */ |
/contrib/sdk/sources/libc/include/sys/types.h |
---|
0,0 → 1,488 |
/* unified sys/types.h: |
start with sef's sysvi386 version. |
merge go32 version -- a few ifdefs. |
h8300hms, h8300xray, and sysvnecv70 disagree on the following types: |
typedef int gid_t; |
typedef int uid_t; |
typedef int dev_t; |
typedef int ino_t; |
typedef int mode_t; |
typedef int caddr_t; |
however, these aren't "reasonable" values, the sysvi386 ones make far |
more sense, and should work sufficiently well (in particular, h8300 |
doesn't have a stat, and the necv70 doesn't matter.) -- eichin |
*/ |
#ifndef _SYS_TYPES_H |
#include <_ansi.h> |
#ifndef __INTTYPES_DEFINED__ |
#define __INTTYPES_DEFINED__ |
#include <machine/_types.h> |
#if defined(__rtems__) || defined(__XMK__) |
/* |
* The following section is RTEMS specific and is needed to more |
* closely match the types defined in the BSD sys/types.h. |
* This is needed to let the RTEMS/BSD TCP/IP stack compile. |
*/ |
/* deprecated */ |
#if ___int8_t_defined |
typedef __uint8_t u_int8_t; |
#endif |
#if ___int16_t_defined |
typedef __uint16_t u_int16_t; |
#endif |
#if ___int32_t_defined |
typedef __uint32_t u_int32_t; |
#endif |
#if ___int64_t_defined |
typedef __uint64_t u_int64_t; |
/* deprecated */ |
typedef __uint64_t u_quad_t; |
typedef __int64_t quad_t; |
typedef quad_t * qaddr_t; |
#endif |
#endif |
#endif /* ! __INTTYPES_DEFINED */ |
#ifndef __need_inttypes |
#define _SYS_TYPES_H |
#include <sys/_types.h> |
#ifdef __i386__ |
#if defined (GO32) || defined (__MSDOS__) |
#define __MS_types__ |
#endif |
#endif |
# include <stddef.h> |
# include <machine/types.h> |
/* To ensure the stat struct's layout doesn't change when sizeof(int), etc. |
changes, we assume sizeof short and long never change and have all types |
used to define struct stat use them and not int where possible. |
Where not possible, _ST_INTxx are used. It would be preferable to not have |
such assumptions, but until the extra fluff is necessary, it's avoided. |
No 64 bit targets use stat yet. What to do about them is postponed |
until necessary. */ |
#ifdef __GNUC__ |
#define _ST_INT32 __attribute__ ((__mode__ (__SI__))) |
#else |
#define _ST_INT32 |
#endif |
# ifndef _POSIX_SOURCE |
# define physadr physadr_t |
# define quad quad_t |
#ifndef _BSDTYPES_DEFINED |
/* also defined in mingw/gmon.h and in w32api/winsock[2].h */ |
typedef unsigned char u_char; |
typedef unsigned short u_short; |
typedef unsigned int u_int; |
typedef unsigned long u_long; |
#define _BSDTYPES_DEFINED |
#endif |
typedef unsigned short ushort; /* System V compatibility */ |
typedef unsigned int uint; /* System V compatibility */ |
typedef unsigned long ulong; /* System V compatibility */ |
# endif /*!_POSIX_SOURCE */ |
#ifndef __clock_t_defined |
typedef _CLOCK_T_ clock_t; |
#define __clock_t_defined |
#endif |
#ifndef __time_t_defined |
typedef _TIME_T_ time_t; |
#define __time_t_defined |
/* Time Value Specification Structures, P1003.1b-1993, p. 261 */ |
struct timespec { |
time_t tv_sec; /* Seconds */ |
long tv_nsec; /* Nanoseconds */ |
}; |
struct itimerspec { |
struct timespec it_interval; /* Timer period */ |
struct timespec it_value; /* Timer expiration */ |
}; |
#endif |
typedef long daddr_t; |
typedef char * caddr_t; |
#ifndef __CYGWIN__ |
#if defined(__MS_types__) || defined(__rtems__) || \ |
defined(__sparc__) || defined(__SPU__) |
typedef unsigned long ino_t; |
#else |
typedef unsigned short ino_t; |
#endif |
#endif /*__CYGWIN__*/ |
#ifdef __MS_types__ |
typedef unsigned long vm_offset_t; |
typedef unsigned long vm_size_t; |
#define __BIT_TYPES_DEFINED__ |
typedef signed char int8_t; |
typedef unsigned char u_int8_t; |
typedef short int16_t; |
typedef unsigned short u_int16_t; |
typedef int int32_t; |
typedef unsigned int u_int32_t; |
typedef long long int64_t; |
typedef unsigned long long u_int64_t; |
typedef int32_t register_t; |
#endif /* __MS_types__ */ |
/* |
* All these should be machine specific - right now they are all broken. |
* However, for all of Cygnus' embedded targets, we want them to all be |
* the same. Otherwise things like sizeof (struct stat) might depend on |
* how the file was compiled (e.g. -mint16 vs -mint32, etc.). |
*/ |
#ifndef __CYGWIN__ /* which defines these types in it's own types.h. */ |
typedef _off_t off_t; |
typedef __dev_t dev_t; |
typedef __uid_t uid_t; |
typedef __gid_t gid_t; |
#endif |
#if defined(__XMK__) |
typedef signed char pid_t; |
#else |
typedef int pid_t; |
#endif |
#if defined(__rtems__) |
typedef _mode_t mode_t; |
#endif |
#ifndef __CYGWIN__ |
typedef long key_t; |
#endif |
typedef _ssize_t ssize_t; |
#if !defined(__CYGWIN__) && !defined(__rtems__) |
#ifdef __MS_types__ |
typedef char * addr_t; |
typedef int mode_t; |
#else |
#if defined (__sparc__) && !defined (__sparc_v9__) |
#ifdef __svr4__ |
typedef unsigned long mode_t; |
#else |
typedef unsigned short mode_t; |
#endif |
#else |
typedef unsigned int mode_t _ST_INT32; |
#endif |
#endif /* ! __MS_types__ */ |
#endif /*__CYGWIN__*/ |
typedef unsigned short nlink_t; |
/* We don't define fd_set and friends if we are compiling POSIX |
source, or if we have included (or may include as indicated |
by __USE_W32_SOCKETS) the W32api winsock[2].h header which |
defines Windows versions of them. Note that a program which |
includes the W32api winsock[2].h header must know what it is doing; |
it must not call the cygwin32 select function. |
*/ |
# if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) |
# define _SYS_TYPES_FD_SET |
# define NBBY 8 /* number of bits in a byte */ |
/* |
* Select uses bit masks of file descriptors in longs. |
* These macros manipulate such bit fields (the filesystem macros use chars). |
* FD_SETSIZE may be defined by the user, but the default here |
* should be >= NOFILE (param.h). |
*/ |
# ifndef FD_SETSIZE |
# define FD_SETSIZE 64 |
# endif |
typedef long fd_mask; |
# define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ |
# ifndef howmany |
# define howmany(x,y) (((x)+((y)-1))/(y)) |
# endif |
/* We use a macro for fd_set so that including Sockets.h afterwards |
can work. */ |
typedef struct _types_fd_set { |
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; |
} _types_fd_set; |
#define fd_set _types_fd_set |
# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) |
# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) |
# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) |
# define FD_ZERO(p) (__extension__ (void)({ \ |
size_t __i; \ |
char *__tmp = (char *)p; \ |
for (__i = 0; __i < sizeof (*(p)); ++__i) \ |
*__tmp++ = 0; \ |
})) |
# endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) */ |
#undef __MS_types__ |
#undef _ST_INT32 |
#ifndef __clockid_t_defined |
typedef _CLOCKID_T_ clockid_t; |
#define __clockid_t_defined |
#endif |
#ifndef __timer_t_defined |
typedef _TIMER_T_ timer_t; |
#define __timer_t_defined |
#endif |
typedef unsigned long useconds_t; |
typedef long suseconds_t; |
#include <sys/features.h> |
/* Cygwin will probably never have full posix compliance due to little things |
* like an inability to set the stackaddress. Cygwin is also using void * |
* pointers rather than structs to ensure maximum binary compatability with |
* previous releases. |
* This means that we don't use the types defined here, but rather in |
* <cygwin/types.h> |
*/ |
#if defined(_POSIX_THREADS) && !defined(__CYGWIN__) |
#include <sys/sched.h> |
/* |
* 2.5 Primitive System Data Types, P1003.1c/D10, p. 19. |
*/ |
#if defined(__XMK__) |
typedef unsigned int pthread_t; /* identify a thread */ |
#else |
typedef __uint32_t pthread_t; /* identify a thread */ |
#endif |
/* P1003.1c/D10, p. 118-119 */ |
#define PTHREAD_SCOPE_PROCESS 0 |
#define PTHREAD_SCOPE_SYSTEM 1 |
/* P1003.1c/D10, p. 111 */ |
#define PTHREAD_INHERIT_SCHED 1 /* scheduling policy and associated */ |
/* attributes are inherited from */ |
/* the calling thread. */ |
#define PTHREAD_EXPLICIT_SCHED 2 /* set from provided attribute object */ |
/* P1003.1c/D10, p. 141 */ |
#define PTHREAD_CREATE_DETACHED 0 |
#define PTHREAD_CREATE_JOINABLE 1 |
#if defined(__XMK__) || defined(__rtems__) |
/* The following defines are part of the X/Open System Interface (XSI). */ |
/* This type of mutex does not detect deadlock. A thread attempting to relock this mutex without first unlocking |
* it shall deadlock. Attempting to unlock a mutex locked by a different thread results in undefined behavior. |
* Attempting to unlock an unlocked mutex results in undefined behavior. |
*/ |
#define PTHREAD_MUTEX_NORMAL 1 |
/* |
* This type of mutex provides error checking. A thread attempting to relock this mutex without first unlocking |
* it shall return with an error. A thread attempting to unlock a mutex which another thread has locked shall return |
* with an error. A thread attempting to unlock an unlocked mutex shall return with an error. |
*/ |
#define PTHREAD_MUTEX_ERRORCHECK 2 |
/* A thread attempting to relock this mutex without first unlocking it shall succeed in locking the mutex. |
* The relocking deadlock which can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with this type of mutex. |
* Multiple locks of this mutex shall require the same number of unlocks to release the mutex before another thread can |
* acquire the mutex. A thread attempting to unlock a mutex which another thread has locked shall return with an error. |
* A thread attempting to unlock an unlocked mutex shall return with an error. |
*/ |
#define PTHREAD_MUTEX_RECURSIVE 3 |
/* Attempting to recursively lock a mutex of this type results in undefined behavior. Attempting to unlock a |
* mutex of this type which was not locked by the calling thread results in undefined behavior. Attempting to |
* unlock a mutex of this type which is not locked results in undefined behavior. An implementation may map this |
* mutex to one of the other mutex types. |
*/ |
#define PTHREAD_MUTEX_DEFAULT 4 |
#endif /* defined(__XMK__) || defined(__rtems__) */ |
#if defined(__XMK__) |
typedef struct pthread_attr_s { |
int contentionscope; |
struct sched_param schedparam; |
int detachstate; |
void *stackaddr; |
size_t stacksize; |
} pthread_attr_t; |
#define PTHREAD_STACK_MIN 200 |
#else /* !defined(__XMK__) */ |
typedef struct { |
int is_initialized; |
void *stackaddr; |
int stacksize; |
int contentionscope; |
int inheritsched; |
int schedpolicy; |
struct sched_param schedparam; |
#if defined(__rtems__) |
size_t guardsize; |
#endif |
/* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */ |
#if defined(_POSIX_THREAD_CPUTIME) |
int cputime_clock_allowed; /* see time.h */ |
#endif |
int detachstate; |
} pthread_attr_t; |
#endif /* !defined(__XMK__) */ |
#if defined(_POSIX_THREAD_PROCESS_SHARED) |
/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared. */ |
#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */ |
#define PTHREAD_PROCESS_SHARED 1 /* visible too all processes with access to */ |
/* the memory where the resource is */ |
/* located */ |
#endif |
#if defined(_POSIX_THREAD_PRIO_PROTECT) |
/* Mutexes */ |
/* Values for blocking protocol. */ |
#define PTHREAD_PRIO_NONE 0 |
#define PTHREAD_PRIO_INHERIT 1 |
#define PTHREAD_PRIO_PROTECT 2 |
#endif |
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) |
/* Values for mutex type */ |
#define PTHREAD_MUTEX_NORMAL 0 |
#define PTHREAD_MUTEX_RECURSIVE 1 |
#define PTHREAD_MUTEX_ERRORCHECK 2 |
#define PTHREAD_MUTEX_DEFAULT 3 |
#endif |
#if defined(__XMK__) |
typedef unsigned int pthread_mutex_t; /* identify a mutex */ |
typedef struct { |
int type; |
} pthread_mutexattr_t; |
#else /* !defined(__XMK__) */ |
typedef __uint32_t pthread_mutex_t; /* identify a mutex */ |
typedef struct { |
int is_initialized; |
#if defined(_POSIX_THREAD_PROCESS_SHARED) |
int process_shared; /* allow mutex to be shared amongst processes */ |
#endif |
#if defined(_POSIX_THREAD_PRIO_PROTECT) |
int prio_ceiling; |
int protocol; |
#endif |
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) |
int type; |
#endif |
int recursive; |
} pthread_mutexattr_t; |
#endif /* !defined(__XMK__) */ |
/* Condition Variables */ |
typedef __uint32_t pthread_cond_t; /* identify a condition variable */ |
typedef struct { |
int is_initialized; |
#if defined(_POSIX_THREAD_PROCESS_SHARED) |
int process_shared; /* allow this to be shared amongst processes */ |
#endif |
} pthread_condattr_t; /* a condition attribute object */ |
/* Keys */ |
typedef __uint32_t pthread_key_t; /* thread-specific data keys */ |
typedef struct { |
int is_initialized; /* is this structure initialized? */ |
int init_executed; /* has the initialization routine been run? */ |
} pthread_once_t; /* dynamic package initialization */ |
#else |
#if defined (__CYGWIN__) |
#include <cygwin/types.h> |
#endif |
#endif /* defined(_POSIX_THREADS) */ |
/* POSIX Barrier Types */ |
#if defined(_POSIX_BARRIERS) |
typedef __uint32_t pthread_barrier_t; /* POSIX Barrier Object */ |
typedef struct { |
int is_initialized; /* is this structure initialized? */ |
#if defined(_POSIX_THREAD_PROCESS_SHARED) |
int process_shared; /* allow this to be shared amongst processes */ |
#endif |
} pthread_barrierattr_t; |
#endif /* defined(_POSIX_BARRIERS) */ |
/* POSIX Spin Lock Types */ |
#if defined(_POSIX_SPIN_LOCKS) |
typedef __uint32_t pthread_spinlock_t; /* POSIX Spin Lock Object */ |
#endif /* defined(_POSIX_SPIN_LOCKS) */ |
/* POSIX Reader/Writer Lock Types */ |
#if !defined (__CYGWIN__) |
#if defined(_POSIX_READER_WRITER_LOCKS) |
typedef __uint32_t pthread_rwlock_t; /* POSIX RWLock Object */ |
typedef struct { |
int is_initialized; /* is this structure initialized? */ |
#if defined(_POSIX_THREAD_PROCESS_SHARED) |
int process_shared; /* allow this to be shared amongst processes */ |
#endif |
} pthread_rwlockattr_t; |
#endif /* defined(_POSIX_READER_WRITER_LOCKS) */ |
#endif /* __CYGWIN__ */ |
#endif /* !__need_inttypes */ |
#undef __need_inttypes |
#endif /* _SYS_TYPES_H */ |
/contrib/sdk/sources/libc/include/sys/unistd.h |
---|
0,0 → 1,507 |
#ifndef _SYS_UNISTD_H |
#define _SYS_UNISTD_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <_ansi.h> |
#include <sys/types.h> |
#include <sys/_types.h> |
#define __need_size_t |
#define __need_ptrdiff_t |
#include <stddef.h> |
extern char **environ; |
void _EXFUN(_exit, (int __status ) _ATTRIBUTE ((noreturn))); |
int _EXFUN(access,(const char *__path, int __amode )); |
unsigned _EXFUN(alarm, (unsigned __secs )); |
int _EXFUN(chdir, (const char *__path )); |
int _EXFUN(chmod, (const char *__path, mode_t __mode )); |
#if !defined(__INSIDE_CYGWIN__) |
int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group )); |
#endif |
#if defined(__CYGWIN__) || defined(__rtems__) |
int _EXFUN(chroot, (const char *__path )); |
#endif |
int _EXFUN(close, (int __fildes )); |
#if defined(__CYGWIN__) |
size_t _EXFUN(confstr, (int __name, char *__buf, size_t __len)); |
#endif |
char * _EXFUN(ctermid, (char *__s )); |
char * _EXFUN(cuserid, (char *__s )); |
#if defined(__CYGWIN__) |
int _EXFUN(daemon, (int nochdir, int noclose)); |
#endif |
int _EXFUN(dup, (int __fildes )); |
int _EXFUN(dup2, (int __fildes, int __fildes2 )); |
#if defined(__CYGWIN__) |
int _EXFUN(dup3, (int __fildes, int __fildes2, int flags)); |
int _EXFUN(eaccess, (const char *__path, int __mode)); |
void _EXFUN(endusershell, (void)); |
int _EXFUN(euidaccess, (const char *__path, int __mode)); |
#endif |
int _EXFUN(execl, (const char *__path, const char *, ... )); |
int _EXFUN(execle, (const char *__path, const char *, ... )); |
int _EXFUN(execlp, (const char *__file, const char *, ... )); |
#if defined(__CYGWIN__) |
int _EXFUN(execlpe, (const char *__file, const char *, ... )); |
#endif |
int _EXFUN(execv, (const char *__path, char * const __argv[] )); |
int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] )); |
int _EXFUN(execvp, (const char *__file, char * const __argv[] )); |
#if defined(__CYGWIN__) |
int _EXFUN(execvpe, (const char *__file, char * const __argv[], char * const __envp[] )); |
int _EXFUN(faccessat, (int __dirfd, const char *__path, int __mode, int __flags)); |
#endif |
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__SPU__) |
int _EXFUN(fchdir, (int __fildes)); |
#endif |
int _EXFUN(fchmod, (int __fildes, mode_t __mode )); |
#if !defined(__INSIDE_CYGWIN__) |
int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group )); |
#endif |
#if defined(__CYGWIN__) |
int _EXFUN(fchownat, (int __dirfd, const char *__path, uid_t __owner, gid_t __group, int __flags)); |
int _EXFUN(fexecve, (int __fd, char * const __argv[], char * const __envp[] )); |
#endif |
pid_t _EXFUN(fork, (void )); |
long _EXFUN(fpathconf, (int __fd, int __name )); |
int _EXFUN(fsync, (int __fd)); |
int _EXFUN(fdatasync, (int __fd)); |
char * _EXFUN(getcwd, (char *__buf, size_t __size )); |
#if defined(__CYGWIN__) |
int _EXFUN(getdomainname ,(char *__name, size_t __len)); |
#endif |
#if !defined(__INSIDE_CYGWIN__) |
gid_t _EXFUN(getegid, (void )); |
uid_t _EXFUN(geteuid, (void )); |
gid_t _EXFUN(getgid, (void )); |
#endif |
int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] )); |
#if defined(__CYGWIN__) |
long _EXFUN(gethostid, (void)); |
#endif |
char * _EXFUN(getlogin, (void )); |
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) |
int _EXFUN(getlogin_r, (char *name, size_t namesize) ); |
#endif |
char * _EXFUN(getpass, (const char *__prompt)); |
int _EXFUN(getpagesize, (void)); |
#if defined(__CYGWIN__) |
int _EXFUN(getpeereid, (int, uid_t *, gid_t *)); |
#endif |
pid_t _EXFUN(getpgid, (pid_t)); |
pid_t _EXFUN(getpgrp, (void )); |
pid_t _EXFUN(getpid, (void )); |
pid_t _EXFUN(getppid, (void )); |
#if defined(__CYGWIN__) || defined(__rtems__) |
pid_t _EXFUN(getsid, (pid_t)); |
#endif |
#if !defined(__INSIDE_CYGWIN__) |
uid_t _EXFUN(getuid, (void )); |
#endif |
#ifdef __CYGWIN__ |
char * _EXFUN(getusershell, (void)); |
char * _EXFUN(getwd, (char *__buf )); |
int _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser)); |
#endif |
int _EXFUN(isatty, (int __fildes )); |
#if !defined(__INSIDE_CYGWIN__) |
int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group )); |
#endif |
int _EXFUN(link, (const char *__path1, const char *__path2 )); |
#if defined(__CYGWIN__) |
int _EXFUN(linkat, (int __dirfd1, const char *__path1, int __dirfd2, const char *__path2, int __flags )); |
#endif |
int _EXFUN(nice, (int __nice_value )); |
#if !defined(__INSIDE_CYGWIN__) |
off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence )); |
#endif |
#if defined(__SPU__) || defined(__CYGWIN__) |
#define F_ULOCK 0 |
#define F_LOCK 1 |
#define F_TLOCK 2 |
#define F_TEST 3 |
int _EXFUN(lockf, (int __fd, int __cmd, off_t __len)); |
#endif |
long _EXFUN(pathconf, (const char *__path, int __name )); |
int _EXFUN(pause, (void )); |
#ifdef __CYGWIN__ |
int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void))); |
#endif |
int _EXFUN(pipe, (int __fildes[2] )); |
#ifdef __CYGWIN__ |
int _EXFUN(pipe2, (int __fildes[2], int flags)); |
#endif |
ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset)); |
ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset)); |
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte )); |
#if defined(__CYGWIN__) |
int _EXFUN(rresvport, (int *__alport)); |
int _EXFUN(revoke, (char *__path)); |
#endif |
int _EXFUN(rmdir, (const char *__path )); |
#if defined(__CYGWIN__) |
int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser)); |
#endif |
void * _EXFUN(sbrk, (ptrdiff_t __incr)); |
#if !defined(__INSIDE_CYGWIN__) |
#if defined(__CYGWIN__) || defined(__rtems__) |
int _EXFUN(setegid, (gid_t __gid )); |
int _EXFUN(seteuid, (uid_t __uid )); |
#endif |
int _EXFUN(setgid, (gid_t __gid )); |
#endif |
#if defined(__CYGWIN__) |
int _EXFUN(setgroups, (int ngroups, const gid_t *grouplist )); |
#endif |
int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid )); |
int _EXFUN(setpgrp, (void )); |
#if defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__) |
int _EXFUN(setregid, (gid_t __rgid, gid_t __egid)); |
int _EXFUN(setreuid, (uid_t __ruid, uid_t __euid)); |
#endif |
pid_t _EXFUN(setsid, (void )); |
#if !defined(__INSIDE_CYGWIN__) |
int _EXFUN(setuid, (uid_t __uid )); |
#endif |
#if defined(__CYGWIN__) |
void _EXFUN(setusershell, (void)); |
#endif |
unsigned _EXFUN(sleep, (unsigned int __seconds )); |
void _EXFUN(swab, (const void *, void *, ssize_t)); |
long _EXFUN(sysconf, (int __name )); |
pid_t _EXFUN(tcgetpgrp, (int __fildes )); |
int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id )); |
char * _EXFUN(ttyname, (int __fildes )); |
#if defined(__CYGWIN__) || defined(__rtems__) |
int _EXFUN(ttyname_r, (int, char *, size_t)); |
#endif |
int _EXFUN(unlink, (const char *__path )); |
int _EXFUN(usleep, (useconds_t __useconds)); |
int _EXFUN(vhangup, (void )); |
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte )); |
#ifdef __CYGWIN__ |
# define __UNISTD_GETOPT__ |
# include <getopt.h> |
# undef __UNISTD_GETOPT__ |
#else |
extern char *optarg; /* getopt(3) external variables */ |
extern int optind, opterr, optopt; |
int getopt(int, char * const [], const char *); |
extern int optreset; /* getopt(3) external variable */ |
#endif |
#ifndef _POSIX_SOURCE |
pid_t _EXFUN(vfork, (void )); |
#endif /* _POSIX_SOURCE */ |
#ifdef _COMPILING_NEWLIB |
/* Provide prototypes for most of the _<systemcall> names that are |
provided in newlib for some compilers. */ |
int _EXFUN(_close, (int __fildes )); |
pid_t _EXFUN(_fork, (void )); |
pid_t _EXFUN(_getpid, (void )); |
int _EXFUN(_isatty, (int __fildes )); |
int _EXFUN(_link, (const char *__path1, const char *__path2 )); |
_off_t _EXFUN(_lseek, (int __fildes, _off_t __offset, int __whence )); |
#ifdef __LARGE64_FILES |
_off64_t _EXFUN(_lseek64, (int __filedes, _off64_t __offset, int __whence )); |
#endif |
_READ_WRITE_RETURN_TYPE _EXFUN(_read, (int __fd, void *__buf, size_t __nbyte )); |
void * _EXFUN(_sbrk, (ptrdiff_t __incr)); |
int _EXFUN(_unlink, (const char *__path )); |
_READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nbyte )); |
int _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] )); |
#endif |
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__sh__) || defined(__SPU__) |
#if !defined(__INSIDE_CYGWIN__) |
int _EXFUN(ftruncate, (int __fd, off_t __length)); |
int _EXFUN(truncate, (const char *, off_t __length)); |
#endif |
#endif |
#if defined(__CYGWIN__) || defined(__rtems__) |
int _EXFUN(getdtablesize, (void)); |
int _EXFUN(setdtablesize, (int)); |
useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval)); |
#if !(defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) |
/* winsock[2].h defines as __stdcall, and with int as 2nd arg */ |
int _EXFUN(gethostname, (char *__name, size_t __len)); |
#endif |
char * _EXFUN(mktemp, (char *)); |
#endif |
#if defined(__CYGWIN__) || defined(__SPU__) || defined(__rtems__) |
void _EXFUN(sync, (void)); |
#endif |
ssize_t _EXFUN(readlink, (const char *__path, char *__buf, size_t __buflen)); |
#if defined(__CYGWIN__) |
ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__path, char *__buf, size_t __buflen)); |
#endif |
int _EXFUN(symlink, (const char *__name1, const char *__name2)); |
#if defined(__CYGWIN__) |
int _EXFUN(symlinkat, (const char *, int, const char *)); |
int _EXFUN(unlinkat, (int, const char *, int)); |
#endif |
#define F_OK 0 |
#define R_OK 4 |
#define W_OK 2 |
#define X_OK 1 |
# define SEEK_SET 0 |
# define SEEK_CUR 1 |
# define SEEK_END 2 |
#include <sys/features.h> |
#define STDIN_FILENO 0 /* standard input file descriptor */ |
#define STDOUT_FILENO 1 /* standard output file descriptor */ |
#define STDERR_FILENO 2 /* standard error file descriptor */ |
/* |
* sysconf values per IEEE Std 1003.1, 2008 Edition |
*/ |
#define _SC_ARG_MAX 0 |
#define _SC_CHILD_MAX 1 |
#define _SC_CLK_TCK 2 |
#define _SC_NGROUPS_MAX 3 |
#define _SC_OPEN_MAX 4 |
#define _SC_JOB_CONTROL 5 |
#define _SC_SAVED_IDS 6 |
#define _SC_VERSION 7 |
#define _SC_PAGESIZE 8 |
#define _SC_PAGE_SIZE _SC_PAGESIZE |
/* These are non-POSIX values we accidentally introduced in 2000 without |
guarding them. Keeping them unguarded for backward compatibility. */ |
#define _SC_NPROCESSORS_CONF 9 |
#define _SC_NPROCESSORS_ONLN 10 |
#define _SC_PHYS_PAGES 11 |
#define _SC_AVPHYS_PAGES 12 |
/* End of non-POSIX values. */ |
#define _SC_MQ_OPEN_MAX 13 |
#define _SC_MQ_PRIO_MAX 14 |
#define _SC_RTSIG_MAX 15 |
#define _SC_SEM_NSEMS_MAX 16 |
#define _SC_SEM_VALUE_MAX 17 |
#define _SC_SIGQUEUE_MAX 18 |
#define _SC_TIMER_MAX 19 |
#define _SC_TZNAME_MAX 20 |
#define _SC_ASYNCHRONOUS_IO 21 |
#define _SC_FSYNC 22 |
#define _SC_MAPPED_FILES 23 |
#define _SC_MEMLOCK 24 |
#define _SC_MEMLOCK_RANGE 25 |
#define _SC_MEMORY_PROTECTION 26 |
#define _SC_MESSAGE_PASSING 27 |
#define _SC_PRIORITIZED_IO 28 |
#define _SC_REALTIME_SIGNALS 29 |
#define _SC_SEMAPHORES 30 |
#define _SC_SHARED_MEMORY_OBJECTS 31 |
#define _SC_SYNCHRONIZED_IO 32 |
#define _SC_TIMERS 33 |
#define _SC_AIO_LISTIO_MAX 34 |
#define _SC_AIO_MAX 35 |
#define _SC_AIO_PRIO_DELTA_MAX 36 |
#define _SC_DELAYTIMER_MAX 37 |
#define _SC_THREAD_KEYS_MAX 38 |
#define _SC_THREAD_STACK_MIN 39 |
#define _SC_THREAD_THREADS_MAX 40 |
#define _SC_TTY_NAME_MAX 41 |
#define _SC_THREADS 42 |
#define _SC_THREAD_ATTR_STACKADDR 43 |
#define _SC_THREAD_ATTR_STACKSIZE 44 |
#define _SC_THREAD_PRIORITY_SCHEDULING 45 |
#define _SC_THREAD_PRIO_INHERIT 46 |
/* _SC_THREAD_PRIO_PROTECT was _SC_THREAD_PRIO_CEILING in early drafts */ |
#define _SC_THREAD_PRIO_PROTECT 47 |
#define _SC_THREAD_PRIO_CEILING _SC_THREAD_PRIO_PROTECT |
#define _SC_THREAD_PROCESS_SHARED 48 |
#define _SC_THREAD_SAFE_FUNCTIONS 49 |
#define _SC_GETGR_R_SIZE_MAX 50 |
#define _SC_GETPW_R_SIZE_MAX 51 |
#define _SC_LOGIN_NAME_MAX 52 |
#define _SC_THREAD_DESTRUCTOR_ITERATIONS 53 |
#define _SC_ADVISORY_INFO 54 |
#define _SC_ATEXIT_MAX 55 |
#define _SC_BARRIERS 56 |
#define _SC_BC_BASE_MAX 57 |
#define _SC_BC_DIM_MAX 58 |
#define _SC_BC_SCALE_MAX 59 |
#define _SC_BC_STRING_MAX 60 |
#define _SC_CLOCK_SELECTION 61 |
#define _SC_COLL_WEIGHTS_MAX 62 |
#define _SC_CPUTIME 63 |
#define _SC_EXPR_NEST_MAX 64 |
#define _SC_HOST_NAME_MAX 65 |
#define _SC_IOV_MAX 66 |
#define _SC_IPV6 67 |
#define _SC_LINE_MAX 68 |
#define _SC_MONOTONIC_CLOCK 69 |
#define _SC_RAW_SOCKETS 70 |
#define _SC_READER_WRITER_LOCKS 71 |
#define _SC_REGEXP 72 |
#define _SC_RE_DUP_MAX 73 |
#define _SC_SHELL 74 |
#define _SC_SPAWN 75 |
#define _SC_SPIN_LOCKS 76 |
#define _SC_SPORADIC_SERVER 77 |
#define _SC_SS_REPL_MAX 78 |
#define _SC_SYMLOOP_MAX 79 |
#define _SC_THREAD_CPUTIME 80 |
#define _SC_THREAD_SPORADIC_SERVER 81 |
#define _SC_TIMEOUTS 82 |
#define _SC_TRACE 83 |
#define _SC_TRACE_EVENT_FILTER 84 |
#define _SC_TRACE_EVENT_NAME_MAX 85 |
#define _SC_TRACE_INHERIT 86 |
#define _SC_TRACE_LOG 87 |
#define _SC_TRACE_NAME_MAX 88 |
#define _SC_TRACE_SYS_MAX 89 |
#define _SC_TRACE_USER_EVENT_MAX 90 |
#define _SC_TYPED_MEMORY_OBJECTS 91 |
#define _SC_V7_ILP32_OFF32 92 |
#define _SC_V6_ILP32_OFF32 _SC_V7_ILP32_OFF32 |
#define _SC_XBS5_ILP32_OFF32 _SC_V7_ILP32_OFF32 |
#define _SC_V7_ILP32_OFFBIG 93 |
#define _SC_V6_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG |
#define _SC_XBS5_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG |
#define _SC_V7_LP64_OFF64 94 |
#define _SC_V6_LP64_OFF64 _SC_V7_LP64_OFF64 |
#define _SC_XBS5_LP64_OFF64 _SC_V7_LP64_OFF64 |
#define _SC_V7_LPBIG_OFFBIG 95 |
#define _SC_V6_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG |
#define _SC_XBS5_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG |
#define _SC_XOPEN_CRYPT 96 |
#define _SC_XOPEN_ENH_I18N 97 |
#define _SC_XOPEN_LEGACY 98 |
#define _SC_XOPEN_REALTIME 99 |
#define _SC_STREAM_MAX 100 |
#define _SC_PRIORITY_SCHEDULING 101 |
#define _SC_XOPEN_REALTIME_THREADS 102 |
#define _SC_XOPEN_SHM 103 |
#define _SC_XOPEN_STREAMS 104 |
#define _SC_XOPEN_UNIX 105 |
#define _SC_XOPEN_VERSION 106 |
#define _SC_2_CHAR_TERM 107 |
#define _SC_2_C_BIND 108 |
#define _SC_2_C_DEV 109 |
#define _SC_2_FORT_DEV 110 |
#define _SC_2_FORT_RUN 111 |
#define _SC_2_LOCALEDEF 112 |
#define _SC_2_PBS 113 |
#define _SC_2_PBS_ACCOUNTING 114 |
#define _SC_2_PBS_CHECKPOINT 115 |
#define _SC_2_PBS_LOCATE 116 |
#define _SC_2_PBS_MESSAGE 117 |
#define _SC_2_PBS_TRACK 118 |
#define _SC_2_SW_DEV 119 |
#define _SC_2_UPE 120 |
#define _SC_2_VERSION 121 |
#define _SC_THREAD_ROBUST_PRIO_INHERIT 122 |
#define _SC_THREAD_ROBUST_PRIO_PROTECT 123 |
#define _SC_XOPEN_UUCP 124 |
/* |
* pathconf values per IEEE Std 1003.1, 2008 Edition |
*/ |
#define _PC_LINK_MAX 0 |
#define _PC_MAX_CANON 1 |
#define _PC_MAX_INPUT 2 |
#define _PC_NAME_MAX 3 |
#define _PC_PATH_MAX 4 |
#define _PC_PIPE_BUF 5 |
#define _PC_CHOWN_RESTRICTED 6 |
#define _PC_NO_TRUNC 7 |
#define _PC_VDISABLE 8 |
#define _PC_ASYNC_IO 9 |
#define _PC_PRIO_IO 10 |
#define _PC_SYNC_IO 11 |
#define _PC_FILESIZEBITS 12 |
#define _PC_2_SYMLINKS 13 |
#define _PC_SYMLINK_MAX 14 |
#define _PC_ALLOC_SIZE_MIN 15 |
#define _PC_REC_INCR_XFER_SIZE 16 |
#define _PC_REC_MAX_XFER_SIZE 17 |
#define _PC_REC_MIN_XFER_SIZE 18 |
#define _PC_REC_XFER_ALIGN 19 |
#define _PC_TIMESTAMP_RESOLUTION 20 |
#ifdef __CYGWIN__ |
/* Ask for POSIX permission bits support. */ |
#define _PC_POSIX_PERMISSIONS 90 |
/* Ask for full POSIX permission support including uid/gid settings. */ |
#define _PC_POSIX_SECURITY 91 |
#endif |
/* |
* confstr values per IEEE Std 1003.1, 2004 Edition |
*/ |
#ifdef __CYGWIN__ /* Only defined on Cygwin for now. */ |
#define _CS_PATH 0 |
#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1 |
#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS |
#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS |
#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 2 |
#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS |
#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS |
#define _CS_POSIX_V7_ILP32_OFF32_LIBS 3 |
#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS |
#define _CS_XBS5_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS |
#define _CS_XBS5_ILP32_OFF32_LINTFLAGS 4 |
#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 5 |
#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS |
#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS |
#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 6 |
#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS |
#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS |
#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 7 |
#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS |
#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS |
#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS 8 |
#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 9 |
#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS |
#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS |
#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 10 |
#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS |
#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS |
#define _CS_POSIX_V7_LP64_OFF64_LIBS 11 |
#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS |
#define _CS_XBS5_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS |
#define _CS_XBS5_LP64_OFF64_LINTFLAGS 12 |
#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 13 |
#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS |
#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS |
#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 14 |
#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS |
#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS |
#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 15 |
#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS |
#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS |
#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS 16 |
#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 17 |
#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS |
#define _CS_XBS5_WIDTH_RESTRICTED_ENVS _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS |
#define _CS_POSIX_V7_THREADS_CFLAGS 18 |
#define _CS_POSIX_V7_THREADS_LDFLAGS 19 |
#define _CS_V7_ENV 20 |
#define _CS_V6_ENV _CS_V7_ENV |
#endif |
#ifndef __CYGWIN__ |
# define MAXPATHLEN 1024 |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SYS_UNISTD_H */ |
/contrib/sdk/sources/libc/include/sys/utime.h |
---|
0,0 → 1,22 |
#ifndef _SYS_UTIME_H |
#define _SYS_UTIME_H |
/* This is a dummy <sys/utime.h> file, not customized for any |
particular system. If there is a utime.h in libc/sys/SYSDIR/sys, |
it will override this one. */ |
#ifdef __cplusplus |
extern "C" { |
#endif |
struct utimbuf |
{ |
time_t actime; |
time_t modtime; |
}; |
#ifdef __cplusplus |
}; |
#endif |
#endif /* _SYS_UTIME_H */ |
/contrib/sdk/sources/libc/include/sys/wait.h |
---|
0,0 → 1,40 |
#ifndef _SYS_WAIT_H |
#define _SYS_WAIT_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <sys/types.h> |
#define WNOHANG 1 |
#define WUNTRACED 2 |
/* A status looks like: |
<2 bytes info> <2 bytes code> |
<code> == 0, child has exited, info is the exit value |
<code> == 1..7e, child has exited, info is the signal number. |
<code> == 7f, child has stopped, info was the signal number. |
<code> == 80, there was a core dump. |
*/ |
#define WIFEXITED(w) (((w) & 0xff) == 0) |
#define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f)) |
#define WIFSTOPPED(w) (((w) & 0xff) == 0x7f) |
#define WEXITSTATUS(w) (((w) >> 8) & 0xff) |
#define WTERMSIG(w) ((w) & 0x7f) |
#define WSTOPSIG WEXITSTATUS |
pid_t wait (int *); |
pid_t waitpid (pid_t, int *, int); |
/* Provide prototypes for most of the _<systemcall> names that are |
provided in newlib for some compilers. */ |
pid_t _wait (int *); |
#ifdef __cplusplus |
}; |
#endif |
#endif |
/contrib/sdk/sources/libc/include/kos32sys.h |
---|
0,0 → 1,452 |
#ifndef __KOS_32_SYS_H__ |
#define __KOS_32_SYS_H__ |
#include <newlib.h> |
#include <stdint.h> |
#include <stddef.h> |
//#ifdef CONFIG_DEBUF |
// #define DBG(format,...) printf(format,##__VA_ARGS__) |
//#else |
// #define DBG(format,...) |
//#endif |
#define TYPE_3_BORDER_WIDTH 5 |
typedef unsigned int color_t; |
typedef union __attribute__((packed)) |
{ |
uint32_t val; |
struct |
{ |
short x; |
short y; |
}; |
}pos_t; |
typedef union __attribute__((packed)) |
{ |
uint32_t val; |
struct |
{ |
uint8_t state; |
uint8_t code; |
uint16_t ctrl_key; |
}; |
}oskey_t; |
typedef struct |
{ |
unsigned handle; |
unsigned io_code; |
void *input; |
int inp_size; |
void *output; |
int out_size; |
}ioctl_t; |
static inline |
void DefineButton(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(8), |
"b"(x_w), |
"c"(y_h), |
"d"(id), |
"S"(color)); |
}; |
static inline |
uint32_t get_skin_height(void) |
{ |
uint32_t height; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
:"=a"(height) |
:"a"(48),"b"(4)); |
return height; |
} |
static inline |
void BeginDraw(void) |
{ |
__asm__ __volatile__( |
"int $0x40" ::"a"(12),"b"(1)); |
}; |
static inline |
void EndDraw(void) |
{ |
__asm__ __volatile__( |
"int $0x40" ::"a"(12),"b"(2)); |
}; |
static inline void DrawWindow(int x, int y, int w, int h, const char *name, |
color_t workcolor, uint32_t style) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(0), |
"b"((x << 16) | ((w-1) & 0xFFFF)), |
"c"((y << 16) | ((h-1) & 0xFFFF)), |
"d"((style << 24) | (workcolor & 0xFFFFFF)), |
"D"(name), |
"S"(0)); |
}; |
static inline |
pos_t get_mouse_pos(void) |
{ |
pos_t val; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
"rol $16, %%eax" |
:"=a"(val) |
:"a"(37),"b"(1)); |
return val; |
} |
static inline |
pos_t get_cursor_pos(void) |
{ |
pos_t val; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
"rol $16, %%eax" |
:"=a"(val) |
:"a"(37),"b"(0)); |
return val; |
} |
static inline |
uint32_t get_mouse_buttons(void) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(37),"b"(2)); |
return val; |
}; |
static inline |
uint32_t get_mouse_wheels(void) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40 \n\t" |
"rol $16, %%eax" |
:"=a"(val) |
:"a"(37),"b"(7)); |
return val; |
}; |
static inline |
uint32_t wait_for_event(uint32_t time) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(23), "b"(time)); |
return val; |
}; |
static inline uint32_t check_os_event() |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(11)); |
return val; |
}; |
static inline uint32_t get_os_event() |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(10)); |
return val; |
}; |
static inline |
uint32_t get_tick_count(void) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(26),"b"(9)); |
return val; |
}; |
static inline |
oskey_t get_key(void) |
{ |
oskey_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(2)); |
return val; |
} |
static inline |
uint32_t get_os_button() |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(17)); |
return val>>8; |
}; |
static inline uint32_t get_service(char *name) |
{ |
uint32_t retval = 0; |
asm volatile ("int $0x40" |
:"=a"(retval) |
:"a"(68),"b"(16),"c"(name) |
:"memory"); |
return retval; |
}; |
static inline int call_service(ioctl_t *io) |
{ |
int retval; |
asm volatile("int $0x40" |
:"=a"(retval) |
:"a"(68),"b"(17),"c"(io) |
:"memory","cc"); |
return retval; |
}; |
static inline |
void draw_line(int xs, int ys, int xe, int ye, color_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(38), "d"(color), |
"b"((xs << 16) | xe), |
"c"((ys << 16) | ye)); |
} |
static inline |
void draw_bar(int x, int y, int w, int h, color_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(13), "d"(color), |
"b"((x << 16) | w), |
"c"((y << 16) | h)); |
} |
static inline |
void draw_bitmap(void *bitmap, int x, int y, int w, int h) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(7), "b"(bitmap), |
"c"((w << 16) | h), |
"d"((x << 16) | y)); |
} |
static inline |
void draw_text_sys(const char *text, int x, int y, int len, color_t color) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(4),"d"(text), |
"b"((x << 16) | y), |
"S"(len),"c"(color)); |
} |
static inline void yield(void) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(68), "b"(1)); |
}; |
static inline void delay(uint32_t time) |
{ |
__asm__ __volatile__( |
"int $0x40" |
::"a"(5), "b"(time) |
:"memory"); |
}; |
static inline |
void *user_alloc(size_t size) |
{ |
void *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(12),"c"(size)); |
return val; |
} |
static inline |
int user_free(void *mem) |
{ |
int val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(13),"c"(mem)); |
return val; |
} |
static inline |
int *user_unmap(void *base, size_t offset, size_t size) |
{ |
int *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size)); |
return val; |
} |
typedef union |
{ |
struct |
{ |
void *data; |
size_t size; |
}; |
unsigned long long raw; |
}ufile_t; |
static inline ufile_t load_file(const char *path) |
{ |
ufile_t uf; |
__asm__ __volatile__ ( |
"int $0x40" |
:"=A"(uf.raw) |
:"a" (68), "b"(27),"c"(path)); |
return uf; |
}; |
static inline int GetScreenSize() |
{ |
int retval; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(retval) |
:"a"(61), "b"(1)); |
return retval; |
} |
static inline |
uint32_t load_cursor(void *path, uint32_t flags) |
{ |
uint32_t val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(37), "b"(4), "c"(path), "d"(flags)); |
return val; |
} |
static inline |
uint32_t set_cursor(uint32_t cursor) |
{ |
uint32_t old; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(old) |
:"a"(37), "b"(5), "c"(cursor)); |
return old; |
} |
static inline |
int destroy_cursor(uint32_t cursor) |
{ |
int ret; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(ret) |
:"a"(37), "b"(6), "c"(cursor) |
:"memory"); |
return ret; |
}; |
static inline void get_proc_info(char *info) |
{ |
__asm__ __volatile__( |
"int $0x40" |
: |
:"a"(9), "b"(info), "c"(-1)); |
} |
static inline |
void* user_realloc(void *mem, size_t size) |
{ |
void *val; |
__asm__ __volatile__( |
"int $0x40" |
:"=a"(val) |
:"a"(68),"b"(20),"c"(size),"d"(mem) |
:"memory"); |
return val; |
} |
void *get_resource(void *data, uint32_t id); |
struct blit_call |
{ |
int dstx; |
int dsty; |
int w; |
int h; |
int srcx; |
int srcy; |
int srcw; |
int srch; |
unsigned char *bitmap; |
int stride; |
}; |
void Blit(void *bitmap, int dst_x, int dst_y, |
int src_x, int src_y, int w, int h, |
int src_w, int src_h, int stride); |
#endif |
/contrib/sdk/sources/libc/include/_ansi.h |
---|
0,0 → 1,133 |
/* Provide support for both ANSI and non-ANSI environments. */ |
/* Some ANSI environments are "broken" in the sense that __STDC__ cannot be |
relied upon to have it's intended meaning. Therefore we must use our own |
concoction: _HAVE_STDC. Always use _HAVE_STDC instead of __STDC__ in newlib |
sources! |
To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will |
"comment out" the non-ANSI parts of the ANSI header files (non-ANSI header |
files aren't affected). */ |
#ifndef _ANSIDECL_H_ |
#define _ANSIDECL_H_ |
#include <newlib.h> |
#include <sys/config.h> |
/* First try to figure out whether we really are in an ANSI C environment. */ |
/* FIXME: This probably needs some work. Perhaps sys/config.h can be |
prevailed upon to give us a clue. */ |
#ifdef __STDC__ |
#define _HAVE_STDC |
#endif |
/* ISO C++. */ |
#ifdef __cplusplus |
#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C)) |
#ifdef _HAVE_STD_CXX |
#define _BEGIN_STD_C namespace std { extern "C" { |
#define _END_STD_C } } |
#else |
#define _BEGIN_STD_C extern "C" { |
#define _END_STD_C } |
#endif |
#if defined(__GNUC__) && \ |
( (__GNUC__ >= 4) || \ |
( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) ) |
#define _NOTHROW __attribute__ ((nothrow)) |
#else |
#define _NOTHROW throw() |
#endif |
#endif |
#else |
#define _BEGIN_STD_C |
#define _END_STD_C |
#define _NOTHROW |
#endif |
#ifdef _HAVE_STDC |
#define _PTR void * |
#define _AND , |
#define _NOARGS void |
#define _CONST const |
#define _VOLATILE volatile |
#define _SIGNED signed |
#define _DOTS , ... |
#define _VOID void |
#ifdef __CYGWIN__ |
#define _EXFUN_NOTHROW(name, proto) __cdecl name proto _NOTHROW |
#define _EXFUN(name, proto) __cdecl name proto |
#define _EXPARM(name, proto) (* __cdecl name) proto |
#define _EXFNPTR(name, proto) (__cdecl * name) proto |
#else |
#define _EXFUN_NOTHROW(name, proto) name proto _NOTHROW |
#define _EXFUN(name, proto) name proto |
#define _EXPARM(name, proto) (* name) proto |
#define _EXFNPTR(name, proto) (* name) proto |
#endif |
#define _DEFUN(name, arglist, args) name(args) |
#define _DEFUN_VOID(name) name(_NOARGS) |
#define _CAST_VOID (void) |
#ifndef _LONG_DOUBLE |
#define _LONG_DOUBLE long double |
#endif |
#ifndef _LONG_LONG_TYPE |
#define _LONG_LONG_TYPE long long |
#endif |
#ifndef _PARAMS |
#define _PARAMS(paramlist) paramlist |
#endif |
#else |
#define _PTR char * |
#define _AND ; |
#define _NOARGS |
#define _CONST |
#define _VOLATILE |
#define _SIGNED |
#define _DOTS |
#define _VOID void |
#define _EXFUN(name, proto) name() |
#define _EXFUN_NOTHROW(name, proto) name() |
#define _DEFUN(name, arglist, args) name arglist args; |
#define _DEFUN_VOID(name) name() |
#define _CAST_VOID |
#define _LONG_DOUBLE double |
#define _LONG_LONG_TYPE long |
#ifndef _PARAMS |
#define _PARAMS(paramlist) () |
#endif |
#endif |
/* Support gcc's __attribute__ facility. */ |
#ifdef __GNUC__ |
#define _ATTRIBUTE(attrs) __attribute__ (attrs) |
#else |
#define _ATTRIBUTE(attrs) |
#endif |
/* The traditional meaning of 'extern inline' for GCC is not |
to emit the function body unless the address is explicitly |
taken. However this behaviour is changing to match the C99 |
standard, which uses 'extern inline' to indicate that the |
function body *must* be emitted. If we are using GCC, but do |
not have the new behaviour, we need to use extern inline; if |
we are using a new GCC with the C99-compatible behaviour, or |
a non-GCC compiler (which we will have to hope is C99, since |
there is no other way to achieve the effect of omitting the |
function if it isn't referenced) we just use plain 'inline', |
which c99 defines to mean more-or-less the same as the Gnu C |
'extern inline'. */ |
#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__) |
/* We're using GCC, but without the new C99-compatible behaviour. */ |
#define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__)) |
#else |
/* We're using GCC in C99 mode, or an unknown compiler which |
we just have to hope obeys the C99 semantics of inline. */ |
#define _ELIDABLE_INLINE __inline__ |
#endif |
#endif /* _ANSIDECL_H_ */ |
/contrib/sdk/sources/libc/include/_syslist.h |
---|
0,0 → 1,40 |
/* internal use only -- mapping of "system calls" for libraries that lose |
and only provide C names, so that we end up in violation of ANSI */ |
#ifndef __SYSLIST_H |
#define __SYSLIST_H |
#ifdef MISSING_SYSCALL_NAMES |
#define _close close |
#define _execve execve |
#define _fcntl fcntl |
#define _fork fork |
#define _fstat fstat |
#define _getpid getpid |
#define _gettimeofday gettimeofday |
#define _isatty isatty |
#define _kill kill |
#define _link link |
#define _lseek lseek |
#define _mkdir mkdir |
#define _open open |
#define _read read |
#define _sbrk sbrk |
#define _stat stat |
#define _times times |
#define _unlink unlink |
#define _wait wait |
#define _write write |
#endif /* MISSING_SYSCALL_NAMES */ |
#if defined MISSING_SYSCALL_NAMES || !defined HAVE_OPENDIR |
/* If the system call interface is missing opendir, readdir, and |
closedir, there is an implementation of these functions in |
libc/posix that is implemented using open, getdents, and close. |
Note, these functions are currently not in the libc/syscalls |
directory. */ |
#define _opendir opendir |
#define _readdir readdir |
#define _closedir closedir |
#endif /* MISSING_SYSCALL_NAMES || !HAVE_OPENDIR */ |
#endif /* !__SYSLIST_H_ */ |
/contrib/sdk/sources/libc/include/alloca.h |
---|
0,0 → 1,21 |
/* libc/include/alloca.h - Allocate memory on stack */ |
/* Written 2000 by Werner Almesberger */ |
/* Rearranged for general inclusion by stdlib.h. |
2001, Corinna Vinschen <vinschen@redhat.com> */ |
#ifndef _NEWLIB_ALLOCA_H |
#define _NEWLIB_ALLOCA_H |
#include "_ansi.h" |
#include <sys/reent.h> |
#undef alloca |
#ifdef __GNUC__ |
#define alloca(size) __builtin_alloca(size) |
#else |
void * _EXFUN(alloca,(size_t)); |
#endif |
#endif |
/contrib/sdk/sources/libc/include/ar.h |
---|
0,0 → 1,69 |
/* $NetBSD: ar.h,v 1.4 1994/10/26 00:55:43 cgd Exp $ */ |
/*- |
* Copyright (c) 1991, 1993 |
* The Regents of the University of California. All rights reserved. |
* (c) UNIX System Laboratories, Inc. |
* All or some portions of this file are derived from material licensed |
* to the University of California by American Telephone and Telegraph |
* Co. or Unix System Laboratories, Inc. and are reproduced herein with |
* the permission of UNIX System Laboratories, Inc. |
* |
* This code is derived from software contributed to Berkeley by |
* Hugh Smith at The University of Guelph. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)ar.h 8.2 (Berkeley) 1/21/94 |
*/ |
#ifndef _AR_H_ |
#define _AR_H_ |
/* Pre-4BSD archives had these magic numbers in them. */ |
#define OARMAG1 0177555 |
#define OARMAG2 0177545 |
#define ARMAG "!<arch>\n" /* ar "magic number" */ |
#define SARMAG 8 /* strlen(ARMAG); */ |
#define AR_EFMT1 "#1/" /* extended format #1 */ |
struct ar_hdr { |
char ar_name[16]; /* name */ |
char ar_date[12]; /* modification time */ |
char ar_uid[6]; /* user id */ |
char ar_gid[6]; /* group id */ |
char ar_mode[8]; /* octal file permissions */ |
char ar_size[10]; /* size in bytes */ |
#define ARFMAG "`\n" |
char ar_fmag[2]; /* consistency check */ |
}; |
#endif /* !_AR_H_ */ |
/contrib/sdk/sources/libc/include/argz.h |
---|
0,0 → 1,33 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#ifndef _ARGZ_H_ |
#define _ARGZ_H_ |
#include <errno.h> |
#include <sys/types.h> |
#include "_ansi.h" |
_BEGIN_STD_C |
/* The newlib implementation of these functions assumes that sizeof(char) == 1. */ |
error_t argz_create (char *const argv[], char **argz, size_t *argz_len); |
error_t argz_create_sep (const char *string, int sep, char **argz, size_t *argz_len); |
size_t argz_count (const char *argz, size_t argz_len); |
void argz_extract (char *argz, size_t argz_len, char **argv); |
void argz_stringify (char *argz, size_t argz_len, int sep); |
error_t argz_add (char **argz, size_t *argz_len, const char *str); |
error_t argz_add_sep (char **argz, size_t *argz_len, const char *str, int sep); |
error_t argz_append (char **argz, size_t *argz_len, const char *buf, size_t buf_len); |
error_t argz_delete (char **argz, size_t *argz_len, char *entry); |
error_t argz_insert (char **argz, size_t *argz_len, char *before, const char *entry); |
char * argz_next (char *argz, size_t argz_len, const char *entry); |
error_t argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, unsigned *replace_count); |
_END_STD_C |
#endif /* _ARGZ_H_ */ |
/contrib/sdk/sources/libc/include/assert.h |
---|
0,0 → 1,50 |
/* |
assert.h |
*/ |
#ifndef _NEWLIB_ASSERT_H |
#define _NEWLIB_ASSERT_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include "_ansi.h" |
#undef assert |
#ifdef NDEBUG /* required by ANSI standard */ |
# define assert(__e) ((void)0) |
#else |
# define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \ |
__ASSERT_FUNC, #__e)) |
# ifndef __ASSERT_FUNC |
/* Use g++'s demangled names in C++. */ |
# if defined __cplusplus && defined __GNUC__ |
# define __ASSERT_FUNC __PRETTY_FUNCTION__ |
/* C99 requires the use of __func__. */ |
# elif __STDC_VERSION__ >= 199901L |
# define __ASSERT_FUNC __func__ |
/* Older versions of gcc don't have __func__ but can use __FUNCTION__. */ |
# elif __GNUC__ >= 2 |
# define __ASSERT_FUNC __FUNCTION__ |
/* failed to detect __func__ support. */ |
# else |
# define __ASSERT_FUNC ((char *) 0) |
# endif |
# endif /* !__ASSERT_FUNC */ |
#endif /* !NDEBUG */ |
void _EXFUN(__assert, (const char *, int, const char *) |
_ATTRIBUTE ((__noreturn__))); |
void _EXFUN(__assert_func, (const char *, int, const char *, const char *) |
_ATTRIBUTE ((__noreturn__))); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _NEWLIB_ASSERT_H */ |
/contrib/sdk/sources/libc/include/complex.h |
---|
0,0 → 1,124 |
/* $NetBSD: complex.h,v 1.3 2010/09/15 16:11:30 christos Exp $ */ |
/* |
* Written by Matthias Drochner. |
* Public domain. |
*/ |
#ifndef _COMPLEX_H |
#define _COMPLEX_H |
#define complex _Complex |
#define _Complex_I 1.0fi |
#define I _Complex_I |
#include <sys/cdefs.h> |
__BEGIN_DECLS |
/* 7.3.5 Trigonometric functions */ |
/* 7.3.5.1 The cacos functions */ |
double complex cacos(double complex); |
float complex cacosf(float complex); |
/* 7.3.5.2 The casin functions */ |
double complex casin(double complex); |
float complex casinf(float complex); |
/* 7.3.5.1 The catan functions */ |
double complex catan(double complex); |
float complex catanf(float complex); |
/* 7.3.5.1 The ccos functions */ |
double complex ccos(double complex); |
float complex ccosf(float complex); |
/* 7.3.5.1 The csin functions */ |
double complex csin(double complex); |
float complex csinf(float complex); |
/* 7.3.5.1 The ctan functions */ |
double complex ctan(double complex); |
float complex ctanf(float complex); |
/* 7.3.6 Hyperbolic functions */ |
/* 7.3.6.1 The cacosh functions */ |
double complex cacosh(double complex); |
float complex cacoshf(float complex); |
/* 7.3.6.2 The casinh functions */ |
double complex casinh(double complex); |
float complex casinhf(float complex); |
/* 7.3.6.3 The catanh functions */ |
double complex catanh(double complex); |
float complex catanhf(float complex); |
/* 7.3.6.4 The ccosh functions */ |
double complex ccosh(double complex); |
float complex ccoshf(float complex); |
/* 7.3.6.5 The csinh functions */ |
double complex csinh(double complex); |
float complex csinhf(float complex); |
/* 7.3.6.6 The ctanh functions */ |
double complex ctanh(double complex); |
float complex ctanhf(float complex); |
/* 7.3.7 Exponential and logarithmic functions */ |
/* 7.3.7.1 The cexp functions */ |
double complex cexp(double complex); |
float complex cexpf(float complex); |
/* 7.3.7.2 The clog functions */ |
double complex clog(double complex); |
float complex clogf(float complex); |
/* 7.3.8 Power and absolute-value functions */ |
/* 7.3.8.1 The cabs functions */ |
/*#ifndef __LIBM0_SOURCE__ |
/* avoid conflict with historical cabs(struct complex) */ |
/* double cabs(double complex) __RENAME(__c99_cabs); |
float cabsf(float complex) __RENAME(__c99_cabsf); |
#endif |
*/ |
double cabs(double complex) ; |
float cabsf(float complex) ; |
/* 7.3.8.2 The cpow functions */ |
double complex cpow(double complex, double complex); |
float complex cpowf(float complex, float complex); |
/* 7.3.8.3 The csqrt functions */ |
double complex csqrt(double complex); |
float complex csqrtf(float complex); |
/* 7.3.9 Manipulation functions */ |
/* 7.3.9.1 The carg functions */ |
double carg(double complex); |
float cargf(float complex); |
/* 7.3.9.2 The cimag functions */ |
double cimag(double complex); |
float cimagf(float complex); |
/*long double cimagl(long double complex); */ |
/* 7.3.9.3 The conj functions */ |
double complex conj(double complex); |
float complex conjf(float complex); |
/*long double complex conjl(long double complex); */ |
/* 7.3.9.4 The cproj functions */ |
double complex cproj(double complex); |
float complex cprojf(float complex); |
/*long double complex cprojl(long double complex); */ |
/* 7.3.9.5 The creal functions */ |
double creal(double complex); |
float crealf(float complex); |
/*long double creall(long double complex); */ |
__END_DECLS |
#endif /* ! _COMPLEX_H */ |
/contrib/sdk/sources/libc/include/ctype.h |
---|
0,0 → 1,113 |
#ifndef _CTYPE_H_ |
#define _CTYPE_H_ |
#include "_ansi.h" |
_BEGIN_STD_C |
int _EXFUN(isalnum, (int __c)); |
int _EXFUN(isalpha, (int __c)); |
int _EXFUN(iscntrl, (int __c)); |
int _EXFUN(isdigit, (int __c)); |
int _EXFUN(isgraph, (int __c)); |
int _EXFUN(islower, (int __c)); |
int _EXFUN(isprint, (int __c)); |
int _EXFUN(ispunct, (int __c)); |
int _EXFUN(isspace, (int __c)); |
int _EXFUN(isupper, (int __c)); |
int _EXFUN(isxdigit,(int __c)); |
int _EXFUN(tolower, (int __c)); |
int _EXFUN(toupper, (int __c)); |
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L |
int _EXFUN(isblank, (int __c)); |
#endif |
#ifndef __STRICT_ANSI__ |
int _EXFUN(isascii, (int __c)); |
int _EXFUN(toascii, (int __c)); |
#define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a') |
#define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A') |
#endif |
#define _U 01 |
#define _L 02 |
#define _N 04 |
#define _S 010 |
#define _P 020 |
#define _C 040 |
#define _X 0100 |
#define _B 0200 |
#ifndef _MB_CAPABLE |
_CONST |
#endif |
extern __IMPORT char *__ctype_ptr__; |
#ifndef __cplusplus |
/* These macros are intentionally written in a manner that will trigger |
a gcc -Wall warning if the user mistakenly passes a 'char' instead |
of an int containing an 'unsigned char'. Note that the sizeof will |
always be 1, which is what we want for mapping EOF to __ctype_ptr__[0]; |
the use of a raw index inside the sizeof triggers the gcc warning if |
__c was of type char, and sizeof masks side effects of the extra __c. |
Meanwhile, the real index to __ctype_ptr__+1 must be cast to int, |
since isalpha(0x100000001LL) must equal isalpha(1), rather than being |
an out-of-bounds reference on a 64-bit machine. */ |
#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)]) |
#define isalpha(__c) (__ctype_lookup(__c)&(_U|_L)) |
#define isupper(__c) ((__ctype_lookup(__c)&(_U|_L))==_U) |
#define islower(__c) ((__ctype_lookup(__c)&(_U|_L))==_L) |
#define isdigit(__c) (__ctype_lookup(__c)&_N) |
#define isxdigit(__c) (__ctype_lookup(__c)&(_X|_N)) |
#define isspace(__c) (__ctype_lookup(__c)&_S) |
#define ispunct(__c) (__ctype_lookup(__c)&_P) |
#define isalnum(__c) (__ctype_lookup(__c)&(_U|_L|_N)) |
#define isprint(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N|_B)) |
#define isgraph(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N)) |
#define iscntrl(__c) (__ctype_lookup(__c)&_C) |
#if defined(__GNUC__) && \ |
(!defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L) |
#define isblank(__c) \ |
__extension__ ({ __typeof__ (__c) __x = (__c); \ |
(__ctype_lookup(__x)&_B) || (int) (__x) == '\t';}) |
#endif |
/* Non-gcc versions will get the library versions, and will be |
slightly slower. These macros are not NLS-aware so they are |
disabled if the system supports the extended character sets. */ |
# if defined(__GNUC__) |
# if !defined (_MB_EXTENDED_CHARSETS_ISO) && !defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
# define toupper(__c) \ |
__extension__ ({ __typeof__ (__c) __x = (__c); \ |
islower (__x) ? (int) __x - 'a' + 'A' : (int) __x;}) |
# define tolower(__c) \ |
__extension__ ({ __typeof__ (__c) __x = (__c); \ |
isupper (__x) ? (int) __x - 'A' + 'a' : (int) __x;}) |
# else /* _MB_EXTENDED_CHARSETS* */ |
/* Allow a gcc warning if the user passed 'char', but defer to the |
function. */ |
# define toupper(__c) \ |
__extension__ ({ __typeof__ (__c) __x = (__c); \ |
(void) __ctype_ptr__[__x]; (toupper) (__x);}) |
# define tolower(__c) \ |
__extension__ ({ __typeof__ (__c) __x = (__c); \ |
(void) __ctype_ptr__[__x]; (tolower) (__x);}) |
# endif /* _MB_EXTENDED_CHARSETS* */ |
# endif /* __GNUC__ */ |
#endif /* !__cplusplus */ |
#ifndef __STRICT_ANSI__ |
#define isascii(__c) ((unsigned)(__c)<=0177) |
#define toascii(__c) ((__c)&0177) |
#endif |
/* For C++ backward-compatibility only. */ |
extern __IMPORT _CONST char _ctype_[]; |
_END_STD_C |
#endif /* _CTYPE_H_ */ |
/contrib/sdk/sources/libc/include/dirent.h |
---|
0,0 → 1,15 |
#ifndef _DIRENT_H_ |
#define _DIRENT_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <sys/dirent.h> |
#if !defined(MAXNAMLEN) && !defined(_POSIX_SOURCE) |
#define MAXNAMLEN 1024 |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /*_DIRENT_H_*/ |
/contrib/sdk/sources/libc/include/envlock.h |
---|
0,0 → 1,15 |
/* envlock.h -- header file for env routines. */ |
#ifndef _INCLUDE_ENVLOCK_H_ |
#define _INCLUDE_ENVLOCK_H_ |
#include <_ansi.h> |
#include <sys/reent.h> |
#define ENV_LOCK __env_lock(reent_ptr) |
#define ENV_UNLOCK __env_unlock(reent_ptr) |
void _EXFUN(__env_lock,(struct _reent *reent)); |
void _EXFUN(__env_unlock,(struct _reent *reent)); |
#endif /* _INCLUDE_ENVLOCK_H_ */ |
/contrib/sdk/sources/libc/include/envz.h |
---|
0,0 → 1,16 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include <errno.h> |
#include <sys/types.h> |
/* The newlib implementation of these functions assumes that sizeof(char) == 1. */ |
char * envz_entry (const char *envz, size_t envz_len, const char *name); |
char * envz_get (const char *envz, size_t envz_len, const char *name); |
error_t envz_add (char **envz, size_t *envz_len, const char *name, const char *value); |
error_t envz_merge (char **envz, size_t *envz_len, const char *envz2, size_t envz2_len, int override); |
void envz_remove(char **envz, size_t *envz_len, const char *name); |
void envz_strip (char **envz, size_t *envz_len); |
/contrib/sdk/sources/libc/include/errno.h |
---|
0,0 → 1,11 |
#ifndef __ERRNO_H__ |
#define __ERRNO_H__ |
#ifndef __error_t_defined |
typedef int error_t; |
#define __error_t_defined 1 |
#endif |
#include <sys/errno.h> |
#endif /* !__ERRNO_H__ */ |
/contrib/sdk/sources/libc/include/fastmath.h |
---|
0,0 → 1,13 |
#ifndef _FASTMATH_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _FASTMATH_H_ |
#include <math.h> |
#include <machine/fastmath.h> |
#ifdef __cplusplus |
} |
#endif |
#endif /* _FASTMATH_H_ */ |
/contrib/sdk/sources/libc/include/fcntl.h |
---|
0,0 → 1,0 |
#include <sys/fcntl.h> |
/contrib/sdk/sources/libc/include/fenv.h |
---|
0,0 → 1,105 |
#ifndef _FENV_H_ |
#define _FENV_H_ |
/* FPU status word exception flags */ |
#define FE_INVALID 0x01 |
#define FE_DENORMAL 0x02 |
#define FE_DIVBYZERO 0x04 |
#define FE_OVERFLOW 0x08 |
#define FE_UNDERFLOW 0x10 |
#define FE_INEXACT 0x20 |
#define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO \ |
| FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) |
/* FPU control word rounding flags */ |
#define FE_TONEAREST 0x0000 |
#define FE_DOWNWARD 0x0400 |
#define FE_UPWARD 0x0800 |
#define FE_TOWARDZERO 0x0c00 |
/* The MXCSR exception flags are the same as the |
FE flags. */ |
#define __MXCSR_EXCEPT_FLAG_SHIFT 0 |
/* How much to shift FE status word exception flags |
to get the MXCSR exeptions masks, */ |
#define __MXCSR_EXCEPT_MASK_SHIFT 7 |
/* How much to shift FE control word rounding flags |
to get MXCSR rounding flags, */ |
#define __MXCSR_ROUND_FLAG_SHIFT 3 |
#ifndef RC_INVOKED |
/* |
For now, support only for the basic abstraction of flags that are |
either set or clear. fexcept_t could be structure that holds more |
info about the fp environment. |
*/ |
typedef unsigned short fexcept_t; |
/* This 32-byte struct represents the entire floating point |
environment as stored by fnstenv or fstenv, augmented by |
the contents of the MXCSR register, as stored by stmxcsr |
(if CPU supports it). */ |
typedef struct |
{ |
unsigned short __control_word; |
unsigned short __unused0; |
unsigned short __status_word; |
unsigned short __unused1; |
unsigned short __tag_word; |
unsigned short __unused2; |
unsigned int __ip_offset; /* instruction pointer offset */ |
unsigned short __ip_selector; |
unsigned short __opcode; |
unsigned int __data_offset; |
unsigned short __data_selector; |
unsigned short __unused3; |
unsigned int __mxcsr; /* contents of the MXCSR register */ |
} fenv_t; |
/*The C99 standard (7.6.9) allows us to define implementation-specific macros for |
different fp environments */ |
/* The default Intel x87 floating point environment (64-bit mantissa) */ |
#define FE_PC64_ENV ((const fenv_t *)-1) |
/* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */ |
#define FE_PC53_ENV ((const fenv_t *)-2) |
/* The FE_DFL_ENV macro is required by standard. |
fesetenv will use the environment set at app startup.*/ |
#define FE_DFL_ENV ((const fenv_t *) 0) |
#ifdef __cplusplus |
extern "C" { |
#endif |
/*TODO: Some of these could be inlined */ |
/* 7.6.2 Exception */ |
extern int __cdecl feclearexcept (int); |
extern int __cdecl fegetexceptflag (fexcept_t * flagp, int excepts); |
extern int __cdecl feraiseexcept (int excepts ); |
extern int __cdecl fesetexceptflag (const fexcept_t *, int); |
extern int __cdecl fetestexcept (int excepts); |
/* 7.6.3 Rounding */ |
extern int __cdecl fegetround (void); |
extern int __cdecl fesetround (int mode); |
/* 7.6.4 Environment */ |
extern int __cdecl fegetenv (fenv_t * envp); |
extern int __cdecl fesetenv (const fenv_t * ); |
extern int __cdecl feupdateenv (const fenv_t *); |
extern int __cdecl feholdexcept (fenv_t *); |
#ifdef __cplusplus |
} |
#endif |
#endif /* Not RC_INVOKED */ |
#endif /* ndef _FENV_H */ |
/contrib/sdk/sources/libc/include/fnmatch.h |
---|
0,0 → 1,55 |
/*- |
* Copyright (c) 1992, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/include/fnmatch.h,v 1.10 2002/03/23 17:24:53 imp Exp $ |
* @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 |
*/ |
#ifndef _FNMATCH_H_ |
#define _FNMATCH_H_ |
#define FNM_NOMATCH 1 /* Match failed. */ |
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ |
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ |
#define FNM_PERIOD 0x04 /* Period must be matched by period. */ |
#if defined(_GNU_SOURCE) || !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) |
#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */ |
#define FNM_CASEFOLD 0x10 /* Case insensitive search. */ |
#define FNM_IGNORECASE FNM_CASEFOLD |
#define FNM_FILE_NAME FNM_PATHNAME |
#endif |
#include <sys/cdefs.h> |
__BEGIN_DECLS |
int fnmatch(const char *, const char *, int); |
__END_DECLS |
#endif /* !_FNMATCH_H_ */ |
/contrib/sdk/sources/libc/include/getopt.h |
---|
0,0 → 1,190 |
/**************************************************************************** |
getopt.h - Read command line options |
AUTHOR: Gregory Pietsch |
CREATED Thu Jan 09 22:37:00 1997 |
DESCRIPTION: |
The getopt() function parses the command line arguments. Its arguments argc |
and argv are the argument count and array as passed to the main() function |
on program invocation. The argument optstring is a list of available option |
characters. If such a character is followed by a colon (`:'), the option |
takes an argument, which is placed in optarg. If such a character is |
followed by two colons, the option takes an optional argument, which is |
placed in optarg. If the option does not take an argument, optarg is NULL. |
The external variable optind is the index of the next array element of argv |
to be processed; it communicates from one call to the next which element to |
process. |
The getopt_long() function works like getopt() except that it also accepts |
long options started by two dashes `--'. If these take values, it is either |
in the form |
--arg=value |
or |
--arg value |
It takes the additional arguments longopts which is a pointer to the first |
element of an array of type GETOPT_LONG_OPTION_T, defined below. The last |
element of the array has to be filled with NULL for the name field. |
The longind pointer points to the index of the current long option relative |
to longopts if it is non-NULL. |
The getopt() function returns the option character if the option was found |
successfully, `:' if there was a missing parameter for one of the options, |
`?' for an unknown option character, and EOF for the end of the option list. |
The getopt_long() function's return value is described below. |
The function getopt_long_only() is identical to getopt_long(), except that a |
plus sign `+' can introduce long options as well as `--'. |
Describe how to deal with options that follow non-option ARGV-elements. |
If the caller did not specify anything, the default is REQUIRE_ORDER if the |
environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. |
REQUIRE_ORDER means don't recognize them as options; stop option processing |
when the first non-option is seen. This is what Unix does. This mode of |
operation is selected by either setting the environment variable |
POSIXLY_CORRECT, or using `+' as the first character of the optstring |
parameter. |
PERMUTE is the default. We permute the contents of ARGV as we scan, so that |
eventually all the non-options are at the end. This allows options to be |
given in any order, even with programs that were not written to expect this. |
RETURN_IN_ORDER is an option available to programs that were written to |
expect options and other ARGV-elements in any order and that care about the |
ordering of the two. We describe each non-option ARGV-element as if it were |
the argument of an option with character code 1. Using `-' as the first |
character of the optstring parameter selects this mode of operation. |
The special argument `--' forces an end of option-scanning regardless of the |
value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause |
getopt() and friends to return EOF with optind != argc. |
COPYRIGHT NOTICE AND DISCLAIMER: |
Copyright (C) 1997 Gregory Pietsch |
This file and the accompanying getopt.c implementation file are hereby |
placed in the public domain without restrictions. Just give the author |
credit, don't claim you wrote it or prevent anyone else from using it. |
Gregory Pietsch's current e-mail address: |
gpietsch@comcast.net |
****************************************************************************/ |
/* This is a glibc-extension header file. */ |
#ifndef GETOPT_H |
#define GETOPT_H |
#include <_ansi.h> |
/* include files needed by this include file */ |
#define no_argument 0 |
#define required_argument 1 |
#define optional_argument 2 |
#ifdef __cplusplus |
extern "C" |
{ |
#endif /* __cplusplus */ |
/* types defined by this include file */ |
struct option |
{ |
char *name; /* the name of the long option */ |
int has_arg; /* one of the above macros */ |
int *flag; /* determines if getopt_long() returns a |
* value for a long option; if it is |
* non-NULL, 0 is returned as a function |
* value and the value of val is stored in |
* the area pointed to by flag. Otherwise, |
* val is returned. */ |
int val; /* determines the value to return if flag is |
* NULL. */ |
}; |
/* While getopt.h is a glibc extension, the following are newlib extensions. |
* They are optionally included via the __need_getopt_newlib flag. */ |
#ifdef __need_getopt_newlib |
/* macros defined by this include file */ |
#define NO_ARG no_argument |
#define REQUIRED_ARG required_argument |
#define OPTIONAL_ARG optional_argument |
/* The GETOPT_DATA_INITIALIZER macro is used to initialize a statically- |
allocated variable of type struct getopt_data. */ |
#define GETOPT_DATA_INITIALIZER {0,0,0,0,0} |
/* These #defines are to make accessing the reentrant functions easier. */ |
#define getopt_r __getopt_r |
#define getopt_long_r __getopt_long_r |
#define getopt_long_only_r __getopt_long_only_r |
/* The getopt_data structure is for reentrancy. Its members are similar to |
the externally-defined variables. */ |
typedef struct getopt_data |
{ |
char *optarg; |
int optind, opterr, optopt, optwhere; |
} getopt_data; |
#endif /* __need_getopt_newlib */ |
/* externally-defined variables */ |
extern char *optarg; |
extern int optind; |
extern int opterr; |
extern int optopt; |
/* function prototypes */ |
int _EXFUN (getopt, |
(int __argc, char *const __argv[], const char *__optstring)); |
int _EXFUN (getopt_long, |
(int __argc, char *const __argv[], const char *__shortopts, |
const struct option * __longopts, int *__longind)); |
int _EXFUN (getopt_long_only, |
(int __argc, char *const __argv[], const char *__shortopts, |
const struct option * __longopts, int *__longind)); |
#ifdef __need_getopt_newlib |
int _EXFUN (__getopt_r, |
(int __argc, char *const __argv[], const char *__optstring, |
struct getopt_data * __data)); |
int _EXFUN (__getopt_long_r, |
(int __argc, char *const __argv[], const char *__shortopts, |
const struct option * __longopts, int *__longind, |
struct getopt_data * __data)); |
int _EXFUN (__getopt_long_only_r, |
(int __argc, char *const __argv[], const char *__shortopts, |
const struct option * __longopts, int *__longind, |
struct getopt_data * __data)); |
#endif /* __need_getopt_newlib */ |
#ifdef __cplusplus |
}; |
#endif /* __cplusplus */ |
#endif /* GETOPT_H */ |
/* END OF FILE getopt.h */ |
/contrib/sdk/sources/libc/include/glob.h |
---|
0,0 → 1,89 |
/* |
* Copyright (c) 1989, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Guido van Rossum. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)glob.h 8.1 (Berkeley) 6/2/93 |
* $FreeBSD: src/include/glob.h,v 1.6 2002/03/23 17:24:53 imp Exp $ |
*/ |
#ifndef _GLOB_H_ |
#define _GLOB_H_ |
#include <sys/cdefs.h> |
struct stat; |
typedef struct { |
int gl_pathc; /* Count of total paths so far. */ |
int gl_matchc; /* Count of paths matching pattern. */ |
int gl_offs; /* Reserved at beginning of gl_pathv. */ |
int gl_flags; /* Copy of flags parameter to glob. */ |
char **gl_pathv; /* List of paths matching pattern. */ |
/* Copy of errfunc parameter to glob. */ |
int (*gl_errfunc)(const char *, int); |
/* |
* Alternate filesystem access methods for glob; replacement |
* versions of closedir(3), readdir(3), opendir(3), stat(2) |
* and lstat(2). |
*/ |
void (*gl_closedir)(void *); |
struct dirent *(*gl_readdir)(void *); |
void *(*gl_opendir)(const char *); |
int (*gl_lstat)(const char *, struct stat *); |
int (*gl_stat)(const char *, struct stat *); |
} glob_t; |
#define GLOB_APPEND 0x0001 /* Append to output from previous call. */ |
#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ |
#define GLOB_ERR 0x0004 /* Return on error. */ |
#define GLOB_MARK 0x0008 /* Append / to matching directories. */ |
#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ |
#define GLOB_NOSORT 0x0020 /* Don't sort. */ |
#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ |
#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ |
#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ |
#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ |
#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ |
#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ |
#define GLOB_LIMIT 0x1000 /* limit number of returned paths */ |
/* backwards compatibility, this is the old name for this option */ |
#define GLOB_MAXPATH GLOB_LIMIT |
#define GLOB_NOSPACE (-1) /* Malloc call failed. */ |
#define GLOB_ABEND (-2) /* Unignored error. */ |
__BEGIN_DECLS |
int glob(const char *, int, int (*)(const char *, int), glob_t *); |
void globfree(glob_t *); |
__END_DECLS |
#endif /* !_GLOB_H_ */ |
/contrib/sdk/sources/libc/include/grp.h |
---|
0,0 → 1,94 |
/* $NetBSD: grp.h,v 1.7 1995/04/29 05:30:40 cgd Exp $ */ |
/*- |
* Copyright (c) 1989, 1993 |
* The Regents of the University of California. All rights reserved. |
* (c) UNIX System Laboratories, Inc. |
* All or some portions of this file are derived from material licensed |
* to the University of California by American Telephone and Telegraph |
* Co. or Unix System Laboratories, Inc. and are reproduced herein with |
* the permission of UNIX System Laboratories, Inc. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)grp.h 8.2 (Berkeley) 1/21/94 |
*/ |
#ifndef _GRP_H_ |
#define _GRP_H_ |
#include <sys/types.h> |
#ifdef __CYGWIN__ |
#include <cygwin/grp.h> |
#endif |
#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) |
#define _PATH_GROUP "/etc/group" |
#endif |
struct group { |
char *gr_name; /* group name */ |
char *gr_passwd; /* group password */ |
gid_t gr_gid; /* group id */ |
char **gr_mem; /* group members */ |
}; |
#ifdef __cplusplus |
extern "C" { |
#endif |
#ifndef __INSIDE_CYGWIN__ |
struct group *getgrgid (gid_t); |
struct group *getgrnam (const char *); |
int getgrnam_r (const char *, struct group *, |
char *, size_t, struct group **); |
int getgrgid_r (gid_t, struct group *, |
char *, size_t, struct group **); |
#ifndef _POSIX_SOURCE |
struct group *getgrent (void); |
void setgrent (void); |
void endgrent (void); |
#ifndef __CYGWIN__ |
void setgrfile (const char *); |
#endif /* !__CYGWIN__ */ |
#ifndef _XOPEN_SOURCE |
#ifndef __CYGWIN__ |
char *group_from_gid (gid_t, int); |
int setgroupent (int); |
#endif /* !__CYGWIN__ */ |
int initgroups (const char *, gid_t); |
#endif /* !_XOPEN_SOURCE */ |
#endif /* !_POSIX_SOURCE */ |
#endif /* !__INSIDE_CYGWIN__ */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* !_GRP_H_ */ |
/contrib/sdk/sources/libc/include/gthr.h |
---|
0,0 → 1,103 |
/* Threads compatibility routines for libgcc2. */ |
/* Compile this one with gcc. */ |
/* Copyright (C) 1997, 1998, 2004, 2008, 2009 Free Software Foundation, Inc. |
This file is part of GCC. |
GCC is free software; you can redistribute it and/or modify it under |
the terms of the GNU General Public License as published by the Free |
Software Foundation; either version 3, or (at your option) any later |
version. |
GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
for more details. |
Under Section 7 of GPL version 3, you are granted additional |
permissions described in the GCC Runtime Library Exception, version |
3.1, as published by the Free Software Foundation. |
You should have received a copy of the GNU General Public License and |
a copy of the GCC Runtime Library Exception along with this program; |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
<http://www.gnu.org/licenses/>. */ |
#ifndef GCC_GTHR_H |
#define GCC_GTHR_H |
typedef unsigned int __gthread_key_t; |
typedef struct { |
volatile int done; |
int started; |
} __gthread_once_t; |
typedef struct { |
volatile int counter; |
} __gthread_mutex_t; |
void *tls_alloc(void); |
static int __gthread_mutex_lock (__gthread_mutex_t *mutex) |
{ |
__mutex_lock(&mutex->counter); |
return 0; |
}; |
static int __gthread_mutex_unlock (__gthread_mutex_t *mutex) |
{ |
mutex->counter = 0; |
return 0; |
}; |
static inline int __gthread_key_create (__gthread_key_t *__key, |
void (*__dtor) (void *) __attribute__((unused))) |
{ |
int __status = 0; |
void *__tls_index = tls_alloc(); |
if (__tls_index != NULL) |
{ |
*__key = (unsigned int)__tls_index; |
#ifdef MINGW32_SUPPORTS_MT_EH /* FIXME */ |
/* Mingw runtime will run the dtors in reverse order for each thread |
when the thread exits. */ |
// __status = __mingwthr_key_dtor (*__key, __dtor); |
#endif |
} |
else |
__status = (int) ENOMEM; |
return __status; |
} |
static inline void * |
__gthread_getspecific (__gthread_key_t __key) |
{ |
void *val; |
__asm__ __volatile__( |
"movl %%fs:(%1), %0" |
:"=r"(val) |
:"r"(__key)); |
return val; |
}; |
static inline int |
__gthread_setspecific (__gthread_key_t __key, const void *__ptr) |
{ |
if(!(__key & 3)) |
{ |
__asm__ __volatile__( |
"movl %0, %%fs:(%1)" |
::"r"(__ptr),"r"(__key)); |
return 0; |
} |
else return EINVAL; |
} |
#endif |
/contrib/sdk/sources/libc/include/iconv.h |
---|
0,0 → 1,62 |
/* |
* Copyright (c) 2003-2004, Artem B. Bityuckiy, SoftMine Corporation. |
* Rights transferred to Franklin Electronic Publishers. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#ifndef _ICONV_H_ |
#define _ICONV_H_ |
#include <_ansi.h> |
#include <reent.h> |
#include <sys/types.h> |
#include <sys/_types.h> |
/* iconv_t: charset conversion descriptor type */ |
typedef _iconv_t iconv_t; |
_BEGIN_STD_C |
#ifndef _REENT_ONLY |
iconv_t |
_EXFUN(iconv_open, (_CONST char *, _CONST char *)); |
size_t |
_EXFUN(iconv, (iconv_t, char **, size_t *, char **, size_t *)); |
int |
_EXFUN(iconv_close, (iconv_t)); |
#endif |
iconv_t |
_EXFUN(_iconv_open_r, (struct _reent *, _CONST char *, _CONST char *)); |
size_t |
_EXFUN(_iconv_r, (struct _reent *, iconv_t, _CONST char **, |
size_t *, char **, size_t *)); |
int |
_EXFUN(_iconv_close_r, (struct _reent *, iconv_t)); |
_END_STD_C |
#endif /* #ifndef _ICONV_H_ */ |
/contrib/sdk/sources/libc/include/ieeefp.h |
---|
0,0 → 1,256 |
#ifndef _IEEE_FP_H_ |
#define _IEEE_FP_H_ |
#include "_ansi.h" |
#include <machine/ieeefp.h> |
_BEGIN_STD_C |
/* FIXME FIXME FIXME: |
Neither of __ieee_{float,double}_shape_tape seem to be used anywhere |
except in libm/test. If that is the case, please delete these from here. |
If that is not the case, please insert documentation here describing why |
they're needed. */ |
#ifdef __IEEE_BIG_ENDIAN |
typedef union |
{ |
double value; |
struct |
{ |
unsigned int sign : 1; |
unsigned int exponent: 11; |
unsigned int fraction0:4; |
unsigned int fraction1:16; |
unsigned int fraction2:16; |
unsigned int fraction3:16; |
} number; |
struct |
{ |
unsigned int sign : 1; |
unsigned int exponent: 11; |
unsigned int quiet:1; |
unsigned int function0:3; |
unsigned int function1:16; |
unsigned int function2:16; |
unsigned int function3:16; |
} nan; |
struct |
{ |
unsigned long msw; |
unsigned long lsw; |
} parts; |
long aslong[2]; |
} __ieee_double_shape_type; |
#endif |
#ifdef __IEEE_LITTLE_ENDIAN |
typedef union |
{ |
double value; |
struct |
{ |
#ifdef __SMALL_BITFIELDS |
unsigned int fraction3:16; |
unsigned int fraction2:16; |
unsigned int fraction1:16; |
unsigned int fraction0: 4; |
#else |
unsigned int fraction1:32; |
unsigned int fraction0:20; |
#endif |
unsigned int exponent :11; |
unsigned int sign : 1; |
} number; |
struct |
{ |
#ifdef __SMALL_BITFIELDS |
unsigned int function3:16; |
unsigned int function2:16; |
unsigned int function1:16; |
unsigned int function0:3; |
#else |
unsigned int function1:32; |
unsigned int function0:19; |
#endif |
unsigned int quiet:1; |
unsigned int exponent: 11; |
unsigned int sign : 1; |
} nan; |
struct |
{ |
unsigned long lsw; |
unsigned long msw; |
} parts; |
long aslong[2]; |
} __ieee_double_shape_type; |
#endif |
#ifdef __IEEE_BIG_ENDIAN |
typedef union |
{ |
float value; |
struct |
{ |
unsigned int sign : 1; |
unsigned int exponent: 8; |
unsigned int fraction0: 7; |
unsigned int fraction1: 16; |
} number; |
struct |
{ |
unsigned int sign:1; |
unsigned int exponent:8; |
unsigned int quiet:1; |
unsigned int function0:6; |
unsigned int function1:16; |
} nan; |
long p1; |
} __ieee_float_shape_type; |
#endif |
#ifdef __IEEE_LITTLE_ENDIAN |
typedef union |
{ |
float value; |
struct |
{ |
unsigned int fraction0: 7; |
unsigned int fraction1: 16; |
unsigned int exponent: 8; |
unsigned int sign : 1; |
} number; |
struct |
{ |
unsigned int function1:16; |
unsigned int function0:6; |
unsigned int quiet:1; |
unsigned int exponent:8; |
unsigned int sign:1; |
} nan; |
long p1; |
} __ieee_float_shape_type; |
#endif |
/* FLOATING ROUNDING */ |
typedef int fp_rnd; |
#define FP_RN 0 /* Round to nearest */ |
#define FP_RM 1 /* Round down */ |
#define FP_RP 2 /* Round up */ |
#define FP_RZ 3 /* Round to zero (trunate) */ |
fp_rnd _EXFUN(fpgetround,(void)); |
fp_rnd _EXFUN(fpsetround, (fp_rnd)); |
/* EXCEPTIONS */ |
typedef int fp_except; |
#define FP_X_INV 0x10 /* Invalid operation */ |
#define FP_X_DX 0x80 /* Divide by zero */ |
#define FP_X_OFL 0x04 /* Overflow exception */ |
#define FP_X_UFL 0x02 /* Underflow exception */ |
#define FP_X_IMP 0x01 /* imprecise exception */ |
fp_except _EXFUN(fpgetmask,(void)); |
fp_except _EXFUN(fpsetmask,(fp_except)); |
fp_except _EXFUN(fpgetsticky,(void)); |
fp_except _EXFUN(fpsetsticky, (fp_except)); |
/* INTEGER ROUNDING */ |
typedef int fp_rdi; |
#define FP_RDI_TOZ 0 /* Round to Zero */ |
#define FP_RDI_RD 1 /* Follow float mode */ |
fp_rdi _EXFUN(fpgetroundtoi,(void)); |
fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi)); |
#undef isnan |
#undef isinf |
int _EXFUN(isnan, (double)); |
int _EXFUN(isinf, (double)); |
int _EXFUN(finite, (double)); |
int _EXFUN(isnanf, (float)); |
int _EXFUN(isinff, (float)); |
int _EXFUN(finitef, (float)); |
#define __IEEE_DBL_EXPBIAS 1023 |
#define __IEEE_FLT_EXPBIAS 127 |
#define __IEEE_DBL_EXPLEN 11 |
#define __IEEE_FLT_EXPLEN 8 |
#define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1)) |
#define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1)) |
#define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1)) |
#define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1)) |
#define __IEEE_DBL_NAN_EXP 0x7ff |
#define __IEEE_FLT_NAN_EXP 0xff |
#ifndef __ieeefp_isnanf |
#define __ieeefp_isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \ |
((*(long *)&(x) & 0x007fffffL)!=0000000000L)) |
#endif |
#define isnanf(x) __ieeefp_isnanf(x) |
#ifndef __ieeefp_isinff |
#define __ieeefp_isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \ |
((*(long *)&(x) & 0x007fffffL)==0000000000L)) |
#endif |
#define isinff(x) __ieeefp_isinff(x) |
#ifndef __ieeefp_finitef |
#define __ieeefp_finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L)) |
#endif |
#define finitef(x) __ieeefp_finitef(x) |
#ifdef _DOUBLE_IS_32BITS |
#undef __IEEE_DBL_EXPBIAS |
#define __IEEE_DBL_EXPBIAS __IEEE_FLT_EXPBIAS |
#undef __IEEE_DBL_EXPLEN |
#define __IEEE_DBL_EXPLEN __IEEE_FLT_EXPLEN |
#undef __IEEE_DBL_FRACLEN |
#define __IEEE_DBL_FRACLEN __IEEE_FLT_FRACLEN |
#undef __IEEE_DBL_MAXPOWTWO |
#define __IEEE_DBL_MAXPOWTWO __IEEE_FLT_MAXPOWTWO |
#undef __IEEE_DBL_NAN_EXP |
#define __IEEE_DBL_NAN_EXP __IEEE_FLT_NAN_EXP |
#undef __ieee_double_shape_type |
#define __ieee_double_shape_type __ieee_float_shape_type |
#endif /* _DOUBLE_IS_32BITS */ |
_END_STD_C |
#endif /* _IEEE_FP_H_ */ |
/contrib/sdk/sources/libc/include/inttypes.h |
---|
0,0 → 1,290 |
/* |
* Copyright (c) 2004, 2005 by |
* Ralf Corsepius, Ulm/Germany. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/** |
* @file inttypes.h |
*/ |
#ifndef _INTTYPES_H |
#define _INTTYPES_H |
#include <stdint.h> |
#define __need_wchar_t |
#include <stddef.h> |
#define __STRINGIFY(a) #a |
/* 8-bit types */ |
#define __PRI8(x) __STRINGIFY(x) |
#define __SCN8(x) __STRINGIFY(hh##x) |
#define PRId8 __PRI8(d) |
#define PRIi8 __PRI8(i) |
#define PRIo8 __PRI8(o) |
#define PRIu8 __PRI8(u) |
#define PRIx8 __PRI8(x) |
#define PRIX8 __PRI8(X) |
#define SCNd8 __SCN8(d) |
#define SCNi8 __SCN8(i) |
#define SCNo8 __SCN8(o) |
#define SCNu8 __SCN8(u) |
#define SCNx8 __SCN8(x) |
#define PRIdLEAST8 __PRI8(d) |
#define PRIiLEAST8 __PRI8(i) |
#define PRIoLEAST8 __PRI8(o) |
#define PRIuLEAST8 __PRI8(u) |
#define PRIxLEAST8 __PRI8(x) |
#define PRIXLEAST8 __PRI8(X) |
#define SCNdLEAST8 __SCN8(d) |
#define SCNiLEAST8 __SCN8(i) |
#define SCNoLEAST8 __SCN8(o) |
#define SCNuLEAST8 __SCN8(u) |
#define SCNxLEAST8 __SCN8(x) |
#define PRIdFAST8 __PRI8(d) |
#define PRIiFAST8 __PRI8(i) |
#define PRIoFAST8 __PRI8(o) |
#define PRIuFAST8 __PRI8(u) |
#define PRIxFAST8 __PRI8(x) |
#define PRIXFAST8 __PRI8(X) |
#define SCNdFAST8 __SCN8(d) |
#define SCNiFAST8 __SCN8(i) |
#define SCNoFAST8 __SCN8(o) |
#define SCNuFAST8 __SCN8(u) |
#define SCNxFAST8 __SCN8(x) |
/* 16-bit types */ |
#define __PRI16(x) __STRINGIFY(x) |
#define __SCN16(x) __STRINGIFY(h##x) |
#define PRId16 __PRI16(d) |
#define PRIi16 __PRI16(i) |
#define PRIo16 __PRI16(o) |
#define PRIu16 __PRI16(u) |
#define PRIx16 __PRI16(x) |
#define PRIX16 __PRI16(X) |
#define SCNd16 __SCN16(d) |
#define SCNi16 __SCN16(i) |
#define SCNo16 __SCN16(o) |
#define SCNu16 __SCN16(u) |
#define SCNx16 __SCN16(x) |
#define PRIdLEAST16 __PRI16(d) |
#define PRIiLEAST16 __PRI16(i) |
#define PRIoLEAST16 __PRI16(o) |
#define PRIuLEAST16 __PRI16(u) |
#define PRIxLEAST16 __PRI16(x) |
#define PRIXLEAST16 __PRI16(X) |
#define SCNdLEAST16 __SCN16(d) |
#define SCNiLEAST16 __SCN16(i) |
#define SCNoLEAST16 __SCN16(o) |
#define SCNuLEAST16 __SCN16(u) |
#define SCNxLEAST16 __SCN16(x) |
#define PRIdFAST16 __PRI16(d) |
#define PRIiFAST16 __PRI16(i) |
#define PRIoFAST16 __PRI16(o) |
#define PRIuFAST16 __PRI16(u) |
#define PRIxFAST16 __PRI16(x) |
#define PRIXFAST16 __PRI16(X) |
#define SCNdFAST16 __SCN16(d) |
#define SCNiFAST16 __SCN16(i) |
#define SCNoFAST16 __SCN16(o) |
#define SCNuFAST16 __SCN16(u) |
#define SCNxFAST16 __SCN16(x) |
/* 32-bit types */ |
#if __have_long32 |
#define __PRI32(x) __STRINGIFY(l##x) |
#define __SCN32(x) __STRINGIFY(l##x) |
#else |
#define __PRI32(x) __STRINGIFY(x) |
#define __SCN32(x) __STRINGIFY(x) |
#endif |
#define PRId32 __PRI32(d) |
#define PRIi32 __PRI32(i) |
#define PRIo32 __PRI32(o) |
#define PRIu32 __PRI32(u) |
#define PRIx32 __PRI32(x) |
#define PRIX32 __PRI32(X) |
#define SCNd32 __SCN32(d) |
#define SCNi32 __SCN32(i) |
#define SCNo32 __SCN32(o) |
#define SCNu32 __SCN32(u) |
#define SCNx32 __SCN32(x) |
#define PRIdLEAST32 __PRI32(d) |
#define PRIiLEAST32 __PRI32(i) |
#define PRIoLEAST32 __PRI32(o) |
#define PRIuLEAST32 __PRI32(u) |
#define PRIxLEAST32 __PRI32(x) |
#define PRIXLEAST32 __PRI32(X) |
#define SCNdLEAST32 __SCN32(d) |
#define SCNiLEAST32 __SCN32(i) |
#define SCNoLEAST32 __SCN32(o) |
#define SCNuLEAST32 __SCN32(u) |
#define SCNxLEAST32 __SCN32(x) |
#define PRIdFAST32 __PRI32(d) |
#define PRIiFAST32 __PRI32(i) |
#define PRIoFAST32 __PRI32(o) |
#define PRIuFAST32 __PRI32(u) |
#define PRIxFAST32 __PRI32(x) |
#define PRIXFAST32 __PRI32(X) |
#define SCNdFAST32 __SCN32(d) |
#define SCNiFAST32 __SCN32(i) |
#define SCNoFAST32 __SCN32(o) |
#define SCNuFAST32 __SCN32(u) |
#define SCNxFAST32 __SCN32(x) |
/* 64-bit types */ |
#if __have_long64 |
#define __PRI64(x) __STRINGIFY(l##x) |
#define __SCN64(x) __STRINGIFY(l##x) |
#elif __have_longlong64 |
#define __PRI64(x) __STRINGIFY(ll##x) |
#define __SCN64(x) __STRINGIFY(ll##x) |
#else |
#define __PRI64(x) __STRINGIFY(x) |
#define __SCN64(x) __STRINGIFY(x) |
#endif |
#define PRId64 __PRI64(d) |
#define PRIi64 __PRI64(i) |
#define PRIo64 __PRI64(o) |
#define PRIu64 __PRI64(u) |
#define PRIx64 __PRI64(x) |
#define PRIX64 __PRI64(X) |
#define SCNd64 __SCN64(d) |
#define SCNi64 __SCN64(i) |
#define SCNo64 __SCN64(o) |
#define SCNu64 __SCN64(u) |
#define SCNx64 __SCN64(x) |
#if __int64_t_defined |
#define PRIdLEAST64 __PRI64(d) |
#define PRIiLEAST64 __PRI64(i) |
#define PRIoLEAST64 __PRI64(o) |
#define PRIuLEAST64 __PRI64(u) |
#define PRIxLEAST64 __PRI64(x) |
#define PRIXLEAST64 __PRI64(X) |
#define SCNdLEAST64 __SCN64(d) |
#define SCNiLEAST64 __SCN64(i) |
#define SCNoLEAST64 __SCN64(o) |
#define SCNuLEAST64 __SCN64(u) |
#define SCNxLEAST64 __SCN64(x) |
#define PRIdFAST64 __PRI64(d) |
#define PRIiFAST64 __PRI64(i) |
#define PRIoFAST64 __PRI64(o) |
#define PRIuFAST64 __PRI64(u) |
#define PRIxFAST64 __PRI64(x) |
#define PRIXFAST64 __PRI64(X) |
#define SCNdFAST64 __SCN64(d) |
#define SCNiFAST64 __SCN64(i) |
#define SCNoFAST64 __SCN64(o) |
#define SCNuFAST64 __SCN64(u) |
#define SCNxFAST64 __SCN64(x) |
#endif |
/* max-bit types */ |
#if __have_long64 |
#define __PRIMAX(x) __STRINGIFY(l##x) |
#define __SCNMAX(x) __STRINGIFY(l##x) |
#elif __have_longlong64 |
#define __PRIMAX(x) __STRINGIFY(ll##x) |
#define __SCNMAX(x) __STRINGIFY(ll##x) |
#else |
#define __PRIMAX(x) __STRINGIFY(x) |
#define __SCNMAX(x) __STRINGIFY(x) |
#endif |
#define PRIdMAX __PRIMAX(d) |
#define PRIiMAX __PRIMAX(i) |
#define PRIoMAX __PRIMAX(o) |
#define PRIuMAX __PRIMAX(u) |
#define PRIxMAX __PRIMAX(x) |
#define PRIXMAX __PRIMAX(X) |
#define SCNdMAX __SCNMAX(d) |
#define SCNiMAX __SCNMAX(i) |
#define SCNoMAX __SCNMAX(o) |
#define SCNuMAX __SCNMAX(u) |
#define SCNxMAX __SCNMAX(x) |
/* ptr types */ |
#if __have_long64 |
#define __PRIPTR(x) __STRINGIFY(l##x) |
#define __SCNPTR(x) __STRINGIFY(l##x) |
#elif __have_longlong64 |
#define __PRIPTR(x) __STRINGIFY(ll##x) |
#define __SCNPTR(x) __STRINGIFY(ll##x) |
#else |
#define __PRIPTR(x) __STRINGIFY(x) |
#define __SCNPTR(x) __STRINGIFY(x) |
#endif |
#define PRIdPTR __PRIPTR(d) |
#define PRIiPTR __PRIPTR(i) |
#define PRIoPTR __PRIPTR(o) |
#define PRIuPTR __PRIPTR(u) |
#define PRIxPTR __PRIPTR(x) |
#define PRIXPTR __PRIPTR(X) |
#define SCNdPTR __SCNPTR(d) |
#define SCNiPTR __SCNPTR(i) |
#define SCNoPTR __SCNPTR(o) |
#define SCNuPTR __SCNPTR(u) |
#define SCNxPTR __SCNPTR(x) |
typedef struct { |
intmax_t quot; |
intmax_t rem; |
} imaxdiv_t; |
#ifdef __cplusplus |
extern "C" { |
#endif |
extern intmax_t imaxabs(intmax_t j); |
extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer); |
extern intmax_t strtoimax(const char *__restrict, char **__restrict, int); |
extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int); |
extern intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int); |
extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int); |
#ifdef __cplusplus |
} |
#endif |
#endif |
/contrib/sdk/sources/libc/include/langinfo.h |
---|
0,0 → 1,316 |
/*- |
* Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/include/langinfo.h,v 1.5 2002/03/23 17:24:53 imp Exp $ |
*/ |
#ifndef _LANGINFO_H_ |
#define _LANGINFO_H_ |
#include <newlib.h> |
#include <sys/config.h> |
#include <sys/cdefs.h> |
typedef int nl_item; |
enum __nl_item |
{ |
/* POSIX and BSD defined items have to stick to the original values |
to maintain backward compatibility. */ |
_NL_CTYPE_CODESET_NAME = 0, /* codeset name */ |
#define CODESET _NL_CTYPE_CODESET_NAME |
D_T_FMT, /* string for formatting date and time */ |
#define D_T_FMT D_T_FMT |
D_FMT, /* date format string */ |
#define D_FMT D_FMT |
T_FMT, /* time format string */ |
#define T_FMT T_FMT |
T_FMT_AMPM, /* a.m. or p.m. time formatting string */ |
#define T_FMT_AMPM T_FMT_AMPM |
AM_STR, /* Ante Meridian affix */ |
#define AM_STR AM_STR |
PM_STR, /* Post Meridian affix */ |
#define PM_STR PM_STR |
/* week day names */ |
DAY_1, |
#define DAY_1 DAY_1 |
DAY_2, |
#define DAY_2 DAY_2 |
DAY_3, |
#define DAY_3 DAY_3 |
DAY_4, |
#define DAY_4 DAY_4 |
DAY_5, |
#define DAY_5 DAY_5 |
DAY_6, |
#define DAY_6 DAY_6 |
DAY_7, |
#define DAY_7 DAY_7 |
/* abbreviated week day names */ |
ABDAY_1, |
#define ABDAY_1 ABDAY_1 |
ABDAY_2, |
#define ABDAY_2 ABDAY_2 |
ABDAY_3, |
#define ABDAY_3 ABDAY_3 |
ABDAY_4, |
#define ABDAY_4 ABDAY_4 |
ABDAY_5, |
#define ABDAY_5 ABDAY_5 |
ABDAY_6, |
#define ABDAY_6 ABDAY_6 |
ABDAY_7, |
#define ABDAY_7 ABDAY_7 |
/* month names */ |
MON_1, |
#define MON_1 MON_1 |
MON_2, |
#define MON_2 MON_2 |
MON_3, |
#define MON_3 MON_3 |
MON_4, |
#define MON_4 MON_4 |
MON_5, |
#define MON_5 MON_5 |
MON_6, |
#define MON_6 MON_6 |
MON_7, |
#define MON_7 MON_7 |
MON_8, |
#define MON_8 MON_8 |
MON_9, |
#define MON_9 MON_9 |
MON_10, |
#define MON_10 MON_10 |
MON_11, |
#define MON_11 MON_11 |
MON_12, |
#define MON_12 MON_12 |
/* abbreviated month names */ |
ABMON_1, |
#define ABMON_1 ABMON_1 |
ABMON_2, |
#define ABMON_2 ABMON_2 |
ABMON_3, |
#define ABMON_3 ABMON_3 |
ABMON_4, |
#define ABMON_4 ABMON_4 |
ABMON_5, |
#define ABMON_5 ABMON_5 |
ABMON_6, |
#define ABMON_6 ABMON_6 |
ABMON_7, |
#define ABMON_7 ABMON_7 |
ABMON_8, |
#define ABMON_8 ABMON_8 |
ABMON_9, |
#define ABMON_9 ABMON_9 |
ABMON_10, |
#define ABMON_10 ABMON_10 |
ABMON_11, |
#define ABMON_11 ABMON_11 |
ABMON_12, |
#define ABMON_12 ABMON_12 |
ERA, /* era description segments */ |
#define ERA ERA |
ERA_D_FMT, /* era date format string */ |
#define ERA_D_FMT ERA_D_FMT |
ERA_D_T_FMT, /* era date and time format string */ |
#define ERA_D_T_FMT ERA_D_T_FMT |
ERA_T_FMT, /* era time format string */ |
#define ERA_T_FMT ERA_T_FMT |
ALT_DIGITS, /* alternative symbols for digits */ |
#define ALT_DIGITS ALT_DIGITS |
RADIXCHAR, /* radix char */ |
#define RADIXCHAR RADIXCHAR |
THOUSEP, /* separator for thousands */ |
#define THOUSEP THOUSEP |
YESEXPR, /* affirmative response expression */ |
#define YESEXPR YESEXPR |
NOEXPR, /* negative response expression */ |
#define NOEXPR NOEXPR |
YESSTR, /* affirmative response for yes/no queries */ |
#define YESSTR YESSTR |
NOSTR, /* negative response for yes/no queries */ |
#define NOSTR NOSTR |
CRNCYSTR, /* currency symbol */ |
#define CRNCYSTR CRNCYSTR |
D_MD_ORDER, /* month/day order (BSD extension) */ |
#define D_MD_ORDER D_MD_ORDER |
_NL_TIME_DATE_FMT = 84, /* date fmt used by date(1) (GNU extension) */ |
#define _DATE_FMT _NL_TIME_DATE_FMT |
#ifdef __HAVE_LOCALE_INFO__ |
_NL_CTYPE_MB_CUR_MAX, |
_NL_MESSAGES_CODESET, |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
/* NOTE: |
Always maintain the order and position of existing entries! |
Always append new entry to the list, prior to the definition |
of _NL_LOCALE_EXTENDED_LAST_ENTRY. */ |
_NL_LOCALE_EXTENDED_FIRST_ENTRY, |
_NL_CTYPE_OUTDIGITS0_MB, |
_NL_CTYPE_OUTDIGITS1_MB, |
_NL_CTYPE_OUTDIGITS2_MB, |
_NL_CTYPE_OUTDIGITS3_MB, |
_NL_CTYPE_OUTDIGITS4_MB, |
_NL_CTYPE_OUTDIGITS5_MB, |
_NL_CTYPE_OUTDIGITS6_MB, |
_NL_CTYPE_OUTDIGITS7_MB, |
_NL_CTYPE_OUTDIGITS8_MB, |
_NL_CTYPE_OUTDIGITS9_MB, |
_NL_CTYPE_OUTDIGITS0_WC, |
_NL_CTYPE_OUTDIGITS1_WC, |
_NL_CTYPE_OUTDIGITS2_WC, |
_NL_CTYPE_OUTDIGITS3_WC, |
_NL_CTYPE_OUTDIGITS4_WC, |
_NL_CTYPE_OUTDIGITS5_WC, |
_NL_CTYPE_OUTDIGITS6_WC, |
_NL_CTYPE_OUTDIGITS7_WC, |
_NL_CTYPE_OUTDIGITS8_WC, |
_NL_CTYPE_OUTDIGITS9_WC, |
_NL_TIME_CODESET, |
_NL_TIME_WMON_1, |
_NL_TIME_WMON_2, |
_NL_TIME_WMON_3, |
_NL_TIME_WMON_4, |
_NL_TIME_WMON_5, |
_NL_TIME_WMON_6, |
_NL_TIME_WMON_7, |
_NL_TIME_WMON_8, |
_NL_TIME_WMON_9, |
_NL_TIME_WMON_10, |
_NL_TIME_WMON_11, |
_NL_TIME_WMON_12, |
_NL_TIME_WMONTH_1, |
_NL_TIME_WMONTH_2, |
_NL_TIME_WMONTH_3, |
_NL_TIME_WMONTH_4, |
_NL_TIME_WMONTH_5, |
_NL_TIME_WMONTH_6, |
_NL_TIME_WMONTH_7, |
_NL_TIME_WMONTH_8, |
_NL_TIME_WMONTH_9, |
_NL_TIME_WMONTH_10, |
_NL_TIME_WMONTH_11, |
_NL_TIME_WMONTH_12, |
_NL_TIME_WWDAY_1, |
_NL_TIME_WWDAY_2, |
_NL_TIME_WWDAY_3, |
_NL_TIME_WWDAY_4, |
_NL_TIME_WWDAY_5, |
_NL_TIME_WWDAY_6, |
_NL_TIME_WWDAY_7, |
_NL_TIME_WWEEKDAY_1, |
_NL_TIME_WWEEKDAY_2, |
_NL_TIME_WWEEKDAY_3, |
_NL_TIME_WWEEKDAY_4, |
_NL_TIME_WWEEKDAY_5, |
_NL_TIME_WWEEKDAY_6, |
_NL_TIME_WWEEKDAY_7, |
_NL_TIME_WT_FMT, |
_NL_TIME_WD_FMT, |
_NL_TIME_WD_T_FMT, |
_NL_TIME_WAM_STR, |
_NL_TIME_WPM_STR, |
_NL_TIME_WDATE_FMT, |
_NL_TIME_WT_FMT_AMPM, |
_NL_TIME_WERA, |
_NL_TIME_WERA_D_FMT, |
_NL_TIME_WERA_D_T_FMT, |
_NL_TIME_WERA_T_FMT, |
_NL_TIME_WALT_DIGITS, |
_NL_NUMERIC_CODESET, |
_NL_NUMERIC_GROUPING, |
_NL_NUMERIC_DECIMAL_POINT_WC, |
_NL_NUMERIC_THOUSANDS_SEP_WC, |
_NL_MONETARY_INT_CURR_SYMBOL, |
_NL_MONETARY_CURRENCY_SYMBOL, |
_NL_MONETARY_MON_DECIMAL_POINT, |
_NL_MONETARY_MON_THOUSANDS_SEP, |
_NL_MONETARY_MON_GROUPING, |
_NL_MONETARY_POSITIVE_SIGN, |
_NL_MONETARY_NEGATIVE_SIGN, |
_NL_MONETARY_INT_FRAC_DIGITS, |
_NL_MONETARY_FRAC_DIGITS, |
_NL_MONETARY_P_CS_PRECEDES, |
_NL_MONETARY_P_SEP_BY_SPACE, |
_NL_MONETARY_N_CS_PRECEDES, |
_NL_MONETARY_N_SEP_BY_SPACE, |
_NL_MONETARY_P_SIGN_POSN, |
_NL_MONETARY_N_SIGN_POSN, |
_NL_MONETARY_INT_P_CS_PRECEDES, |
_NL_MONETARY_INT_P_SEP_BY_SPACE, |
_NL_MONETARY_INT_N_CS_PRECEDES, |
_NL_MONETARY_INT_N_SEP_BY_SPACE, |
_NL_MONETARY_INT_P_SIGN_POSN, |
_NL_MONETARY_INT_N_SIGN_POSN, |
_NL_MONETARY_CODESET, |
_NL_MONETARY_WINT_CURR_SYMBOL, |
_NL_MONETARY_WCURRENCY_SYMBOL, |
_NL_MONETARY_WMON_DECIMAL_POINT, |
_NL_MONETARY_WMON_THOUSANDS_SEP, |
_NL_MONETARY_WPOSITIVE_SIGN, |
_NL_MONETARY_WNEGATIVE_SIGN, |
_NL_MESSAGES_WYESEXPR, |
_NL_MESSAGES_WNOEXPR, |
_NL_MESSAGES_WYESSTR, |
_NL_MESSAGES_WNOSTR, |
_NL_COLLATE_CODESET, |
/* This MUST be the last entry since it's used to check for an array |
index in nl_langinfo(). */ |
_NL_LOCALE_EXTENDED_LAST_ENTRY |
#endif /* __HAVE_LOCALE_INFO_EXTENDED__ */ |
#endif /* __HAVE_LOCALE_INFO__ */ |
}; |
__BEGIN_DECLS |
char *nl_langinfo(nl_item); |
__END_DECLS |
#endif /* !_LANGINFO_H_ */ |
/contrib/sdk/sources/libc/include/libgen.h |
---|
0,0 → 1,23 |
/* |
* libgen.h - defined by XPG4 |
*/ |
#ifndef _LIBGEN_H_ |
#define _LIBGEN_H_ |
#include "_ansi.h" |
#include <sys/reent.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
char *_EXFUN(basename, (char *)); |
char *_EXFUN(dirname, (char *)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _LIBGEN_H_ */ |
/contrib/sdk/sources/libc/include/limits.h |
---|
0,0 → 1,146 |
#ifndef _LIBC_LIMITS_H_ |
# define _LIBC_LIMITS_H_ 1 |
#include <newlib.h> |
# ifdef _MB_LEN_MAX |
# define MB_LEN_MAX _MB_LEN_MAX |
# else |
# define MB_LEN_MAX 1 |
# endif |
/* Maximum number of positional arguments, if _WANT_IO_POS_ARGS. */ |
# ifndef NL_ARGMAX |
# define NL_ARGMAX 32 |
# endif |
/* if do not have #include_next support, then we |
have to define the limits here. */ |
# if !defined __GNUC__ || __GNUC__ < 2 |
# ifndef _LIMITS_H |
# define _LIMITS_H 1 |
# include <sys/config.h> |
/* Number of bits in a `char'. */ |
# undef CHAR_BIT |
# define CHAR_BIT 8 |
/* Minimum and maximum values a `signed char' can hold. */ |
# undef SCHAR_MIN |
# define SCHAR_MIN (-128) |
# undef SCHAR_MAX |
# define SCHAR_MAX 127 |
/* Maximum value an `unsigned char' can hold. (Minimum is 0). */ |
# undef UCHAR_MAX |
# define UCHAR_MAX 255 |
/* Minimum and maximum values a `char' can hold. */ |
# ifdef __CHAR_UNSIGNED__ |
# undef CHAR_MIN |
# define CHAR_MIN 0 |
# undef CHAR_MAX |
# define CHAR_MAX 255 |
# else |
# undef CHAR_MIN |
# define CHAR_MIN (-128) |
# undef CHAR_MAX |
# define CHAR_MAX 127 |
# endif |
/* Minimum and maximum values a `signed short int' can hold. */ |
# undef SHRT_MIN |
/* For the sake of 16 bit hosts, we may not use -32768 */ |
# define SHRT_MIN (-32767-1) |
# undef SHRT_MAX |
# define SHRT_MAX 32767 |
/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ |
# undef USHRT_MAX |
# define USHRT_MAX 65535 |
/* Minimum and maximum values a `signed int' can hold. */ |
# ifndef __INT_MAX__ |
# define __INT_MAX__ 2147483647 |
# endif |
# undef INT_MIN |
# define INT_MIN (-INT_MAX-1) |
# undef INT_MAX |
# define INT_MAX __INT_MAX__ |
/* Maximum value an `unsigned int' can hold. (Minimum is 0). */ |
# undef UINT_MAX |
# define UINT_MAX (INT_MAX * 2U + 1) |
/* Minimum and maximum values a `signed long int' can hold. |
(Same as `int'). */ |
# ifndef __LONG_MAX__ |
# if defined (__alpha__) || (defined (__sparc__) && defined(__arch64__)) || defined (__sparcv9) |
# define __LONG_MAX__ 9223372036854775807L |
# else |
# define __LONG_MAX__ 2147483647L |
# endif /* __alpha__ || sparc64 */ |
# endif |
# undef LONG_MIN |
# define LONG_MIN (-LONG_MAX-1) |
# undef LONG_MAX |
# define LONG_MAX __LONG_MAX__ |
/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ |
# undef ULONG_MAX |
# define ULONG_MAX (LONG_MAX * 2UL + 1) |
# ifndef __LONG_LONG_MAX__ |
# define __LONG_LONG_MAX__ 9223372036854775807LL |
# endif |
# if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L |
/* Minimum and maximum values a `signed long long int' can hold. */ |
# undef LLONG_MIN |
# define LLONG_MIN (-LLONG_MAX-1) |
# undef LLONG_MAX |
# define LLONG_MAX __LONG_LONG_MAX__ |
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ |
# undef ULLONG_MAX |
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) |
# endif |
# if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__) |
/* Minimum and maximum values a `signed long long int' can hold. */ |
# undef LONG_LONG_MIN |
# define LONG_LONG_MIN (-LONG_LONG_MAX-1) |
# undef LONG_LONG_MAX |
# define LONG_LONG_MAX __LONG_LONG_MAX__ |
/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ |
# undef ULONG_LONG_MAX |
# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1) |
# endif |
# endif /* _LIMITS_H */ |
# endif /* GCC 2. */ |
#endif /* !_LIBC_LIMITS_H_ */ |
#if defined __GNUC__ && !defined _GCC_LIMITS_H_ |
/* `_GCC_LIMITS_H_' is what GCC's file defines. */ |
# include_next <limits.h> |
#endif /* __GNUC__ && !_GCC_LIMITS_H_ */ |
#ifndef _POSIX2_RE_DUP_MAX |
/* The maximum number of repeated occurrences of a regular expression |
* permitted when using the interval notation `\{M,N\}'. */ |
#define _POSIX2_RE_DUP_MAX 255 |
#endif /* _POSIX2_RE_DUP_MAX */ |
#ifndef ARG_MAX |
#define ARG_MAX 4096 |
#endif |
#ifndef PATH_MAX |
#define PATH_MAX 4096 |
#endif |
/contrib/sdk/sources/libc/include/locale.h |
---|
0,0 → 1,65 |
/* |
locale.h |
Values appropriate for the formatting of monetary and other |
numberic quantities. |
*/ |
#ifndef _LOCALE_H_ |
#define _LOCALE_H_ |
#include "_ansi.h" |
#ifndef NULL |
#define NULL 0 |
#endif |
#define LC_ALL 0 |
#define LC_COLLATE 1 |
#define LC_CTYPE 2 |
#define LC_MONETARY 3 |
#define LC_NUMERIC 4 |
#define LC_TIME 5 |
#define LC_MESSAGES 6 |
_BEGIN_STD_C |
struct lconv |
{ |
char *decimal_point; |
char *thousands_sep; |
char *grouping; |
char *int_curr_symbol; |
char *currency_symbol; |
char *mon_decimal_point; |
char *mon_thousands_sep; |
char *mon_grouping; |
char *positive_sign; |
char *negative_sign; |
char int_frac_digits; |
char frac_digits; |
char p_cs_precedes; |
char p_sep_by_space; |
char n_cs_precedes; |
char n_sep_by_space; |
char p_sign_posn; |
char n_sign_posn; |
char int_n_cs_precedes; |
char int_n_sep_by_space; |
char int_n_sign_posn; |
char int_p_cs_precedes; |
char int_p_sep_by_space; |
char int_p_sign_posn; |
}; |
#ifndef _REENT_ONLY |
char *_EXFUN(setlocale,(int category, const char *locale)); |
struct lconv *_EXFUN(localeconv,(void)); |
#endif |
struct _reent; |
char *_EXFUN(_setlocale_r,(struct _reent *, int category, const char *locale)); |
struct lconv *_EXFUN(_localeconv_r,(struct _reent *)); |
_END_STD_C |
#endif /* _LOCALE_H_ */ |
/contrib/sdk/sources/libc/include/machine/_default_types.h |
---|
0,0 → 1,121 |
/* |
* $Id: _default_types.h,v 1.2 2008/06/11 22:14:54 jjohnstn Exp $ |
*/ |
#ifndef _MACHINE__DEFAULT_TYPES_H |
#define _MACHINE__DEFAULT_TYPES_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* |
* Guess on types by examining *_MIN / *_MAX defines. |
*/ |
#if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ >= 3 ) \ |
&& defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 )) |
/* GCC >= 3.3.0 has __<val>__ implicitly defined. */ |
#define __EXP(x) __##x##__ |
#else |
/* Fall back to POSIX versions from <limits.h> */ |
#define __EXP(x) x |
#include <limits.h> |
#endif |
#if __EXP(SCHAR_MAX) == 0x7f |
typedef signed char __int8_t ; |
typedef unsigned char __uint8_t ; |
#define ___int8_t_defined 1 |
#endif |
#if __EXP(INT_MAX) == 0x7fff |
typedef signed int __int16_t; |
typedef unsigned int __uint16_t; |
#define ___int16_t_defined 1 |
#elif __EXP(SHRT_MAX) == 0x7fff |
typedef signed short __int16_t; |
typedef unsigned short __uint16_t; |
#define ___int16_t_defined 1 |
#elif __EXP(SCHAR_MAX) == 0x7fff |
typedef signed char __int16_t; |
typedef unsigned char __uint16_t; |
#define ___int16_t_defined 1 |
#endif |
#if ___int16_t_defined |
typedef __int16_t __int_least16_t; |
typedef __uint16_t __uint_least16_t; |
#define ___int_least16_t_defined 1 |
#if !___int8_t_defined |
typedef __int16_t __int_least8_t; |
typedef __uint16_t __uint_least8_t; |
#define ___int_least8_t_defined 1 |
#endif |
#endif |
#if __EXP(INT_MAX) == 0x7fffffffL |
typedef signed int __int32_t; |
typedef unsigned int __uint32_t; |
#define ___int32_t_defined 1 |
#elif __EXP(LONG_MAX) == 0x7fffffffL |
typedef signed long __int32_t; |
typedef unsigned long __uint32_t; |
#define ___int32_t_defined 1 |
#elif __EXP(SHRT_MAX) == 0x7fffffffL |
typedef signed short __int32_t; |
typedef unsigned short __uint32_t; |
#define ___int32_t_defined 1 |
#elif __EXP(SCHAR_MAX) == 0x7fffffffL |
typedef signed char __int32_t; |
typedef unsigned char __uint32_t; |
#define ___int32_t_defined 1 |
#endif |
#if ___int32_t_defined |
typedef __int32_t __int_least32_t; |
typedef __uint32_t __uint_least32_t; |
#define ___int_least32_t_defined 1 |
#if !___int8_t_defined |
typedef __int32_t __int_least8_t; |
typedef __uint32_t __uint_least8_t; |
#define ___int_least8_t_defined 1 |
#endif |
#if !___int16_t_defined |
typedef __int32_t __int_least16_t; |
typedef __uint32_t __uint_least16_t; |
#define ___int_least16_t_defined 1 |
#endif |
#endif |
#if __EXP(LONG_MAX) > 0x7fffffff |
typedef signed long __int64_t; |
typedef unsigned long __uint64_t; |
#define ___int64_t_defined 1 |
/* GCC has __LONG_LONG_MAX__ */ |
#elif defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) |
typedef signed long long __int64_t; |
typedef unsigned long long __uint64_t; |
#define ___int64_t_defined 1 |
/* POSIX mandates LLONG_MAX in <limits.h> */ |
#elif defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) |
typedef signed long long __int64_t; |
typedef unsigned long long __uint64_t; |
#define ___int64_t_defined 1 |
#elif __EXP(INT_MAX) > 0x7fffffff |
typedef signed int __int64_t; |
typedef unsigned int __uint64_t; |
#define ___int64_t_defined 1 |
#endif |
#undef __EXP |
#ifdef __cplusplus |
} |
#endif |
#endif /* _MACHINE__DEFAULT_TYPES_H */ |
/contrib/sdk/sources/libc/include/machine/_types.h |
---|
0,0 → 1,8 |
/* |
* $Id: _types.h,v 1.3 2007/09/07 21:16:25 jjohnstn Exp $ |
*/ |
#ifndef _MACHINE__TYPES_H |
#define _MACHINE__TYPES_H |
#include <machine/_default_types.h> |
#endif |
/contrib/sdk/sources/libc/include/machine/ansi.h |
---|
0,0 → 1,0 |
/* dummy header file to support BSD compiler */ |
/contrib/sdk/sources/libc/include/machine/endian.h |
---|
0,0 → 1,20 |
#ifndef __MACHINE_ENDIAN_H__ |
#include <sys/config.h> |
#ifndef BIG_ENDIAN |
#define BIG_ENDIAN 4321 |
#endif |
#ifndef LITTLE_ENDIAN |
#define LITTLE_ENDIAN 1234 |
#endif |
#ifndef BYTE_ORDER |
#if defined(__IEEE_LITTLE_ENDIAN) || defined(__IEEE_BYTES_LITTLE_ENDIAN) |
#define BYTE_ORDER LITTLE_ENDIAN |
#else |
#define BYTE_ORDER BIG_ENDIAN |
#endif |
#endif |
#endif /* __MACHINE_ENDIAN_H__ */ |
/contrib/sdk/sources/libc/include/machine/fastmath.h |
---|
0,0 → 1,100 |
#ifdef __sysvnecv70_target |
double EXFUN(fast_sin,(double)); |
double EXFUN(fast_cos,(double)); |
double EXFUN(fast_tan,(double)); |
double EXFUN(fast_asin,(double)); |
double EXFUN(fast_acos,(double)); |
double EXFUN(fast_atan,(double)); |
double EXFUN(fast_sinh,(double)); |
double EXFUN(fast_cosh,(double)); |
double EXFUN(fast_tanh,(double)); |
double EXFUN(fast_asinh,(double)); |
double EXFUN(fast_acosh,(double)); |
double EXFUN(fast_atanh,(double)); |
double EXFUN(fast_abs,(double)); |
double EXFUN(fast_sqrt,(double)); |
double EXFUN(fast_exp2,(double)); |
double EXFUN(fast_exp10,(double)); |
double EXFUN(fast_expe,(double)); |
double EXFUN(fast_log10,(double)); |
double EXFUN(fast_log2,(double)); |
double EXFUN(fast_loge,(double)); |
#define sin(x) fast_sin(x) |
#define cos(x) fast_cos(x) |
#define tan(x) fast_tan(x) |
#define asin(x) fast_asin(x) |
#define acos(x) fast_acos(x) |
#define atan(x) fast_atan(x) |
#define sinh(x) fast_sinh(x) |
#define cosh(x) fast_cosh(x) |
#define tanh(x) fast_tanh(x) |
#define asinh(x) fast_asinh(x) |
#define acosh(x) fast_acosh(x) |
#define atanh(x) fast_atanh(x) |
#define abs(x) fast_abs(x) |
#define sqrt(x) fast_sqrt(x) |
#define exp2(x) fast_exp2(x) |
#define exp10(x) fast_exp10(x) |
#define expe(x) fast_expe(x) |
#define log10(x) fast_log10(x) |
#define log2(x) fast_log2(x) |
#define loge(x) fast_loge(x) |
#ifdef _HAVE_STDC |
/* These functions are in assembler, they really do take floats. This |
can only be used with a real ANSI compiler */ |
float EXFUN(fast_sinf,(float)); |
float EXFUN(fast_cosf,(float)); |
float EXFUN(fast_tanf,(float)); |
float EXFUN(fast_asinf,(float)); |
float EXFUN(fast_acosf,(float)); |
float EXFUN(fast_atanf,(float)); |
float EXFUN(fast_sinhf,(float)); |
float EXFUN(fast_coshf,(float)); |
float EXFUN(fast_tanhf,(float)); |
float EXFUN(fast_asinhf,(float)); |
float EXFUN(fast_acoshf,(float)); |
float EXFUN(fast_atanhf,(float)); |
float EXFUN(fast_absf,(float)); |
float EXFUN(fast_sqrtf,(float)); |
float EXFUN(fast_exp2f,(float)); |
float EXFUN(fast_exp10f,(float)); |
float EXFUN(fast_expef,(float)); |
float EXFUN(fast_log10f,(float)); |
float EXFUN(fast_log2f,(float)); |
float EXFUN(fast_logef,(float)); |
#define sinf(x) fast_sinf(x) |
#define cosf(x) fast_cosf(x) |
#define tanf(x) fast_tanf(x) |
#define asinf(x) fast_asinf(x) |
#define acosf(x) fast_acosf(x) |
#define atanf(x) fast_atanf(x) |
#define sinhf(x) fast_sinhf(x) |
#define coshf(x) fast_coshf(x) |
#define tanhf(x) fast_tanhf(x) |
#define asinhf(x) fast_asinhf(x) |
#define acoshf(x) fast_acoshf(x) |
#define atanhf(x) fast_atanhf(x) |
#define absf(x) fast_absf(x) |
#define sqrtf(x) fast_sqrtf(x) |
#define exp2f(x) fast_exp2f(x) |
#define exp10f(x) fast_exp10f(x) |
#define expef(x) fast_expef(x) |
#define log10f(x) fast_log10f(x) |
#define log2f(x) fast_log2f(x) |
#define logef(x) fast_logef(x) |
#endif |
/* Override the functions defined in math.h */ |
#endif /* __sysvnecv70_target */ |
/contrib/sdk/sources/libc/include/machine/ieeefp.h |
---|
0,0 → 1,382 |
#ifndef __IEEE_BIG_ENDIAN |
#ifndef __IEEE_LITTLE_ENDIAN |
/* This file can define macros to choose variations of the IEEE float |
format: |
_FLT_LARGEST_EXPONENT_IS_NORMAL |
Defined if the float format uses the largest exponent for finite |
numbers rather than NaN and infinity representations. Such a |
format cannot represent NaNs or infinities at all, but it's FLT_MAX |
is twice the IEEE value. |
_FLT_NO_DENORMALS |
Defined if the float format does not support IEEE denormals. Every |
float with a zero exponent is taken to be a zero representation. |
??? At the moment, there are no equivalent macros above for doubles and |
the macros are not fully supported by --enable-newlib-hw-fp. |
__IEEE_BIG_ENDIAN |
Defined if the float format is big endian. This is mutually exclusive |
with __IEEE_LITTLE_ENDIAN. |
__IEEE_LITTLE_ENDIAN |
Defined if the float format is little endian. This is mutually exclusive |
with __IEEE_BIG_ENDIAN. |
Note that one of __IEEE_BIG_ENDIAN or __IEEE_LITTLE_ENDIAN must be specified for a |
platform or error will occur. |
__IEEE_BYTES_LITTLE_ENDIAN |
This flag is used in conjunction with __IEEE_BIG_ENDIAN to describe a situation |
whereby multiple words of an IEEE floating point are in big endian order, but the |
words themselves are little endian with respect to the bytes. |
_DOUBLE_IS_32BITS |
This is used on platforms that support double by using the 32-bit IEEE |
float type. |
_FLOAT_ARG |
This represents what type a float arg is passed as. It is used when the type is |
not promoted to double. |
*/ |
#if (defined(__arm__) || defined(__thumb__)) && !defined(__MAVERICK__) |
/* ARM traditionally used big-endian words; and within those words the |
byte ordering was big or little endian depending upon the target. |
Modern floating-point formats are naturally ordered; in this case |
__VFP_FP__ will be defined, even if soft-float. */ |
#ifdef __VFP_FP__ |
# ifdef __ARMEL__ |
# define __IEEE_LITTLE_ENDIAN |
# else |
# define __IEEE_BIG_ENDIAN |
# endif |
#else |
# define __IEEE_BIG_ENDIAN |
# ifdef __ARMEL__ |
# define __IEEE_BYTES_LITTLE_ENDIAN |
# endif |
#endif |
#endif |
#ifdef __hppa__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __SPU__ |
#define __IEEE_BIG_ENDIAN |
#define isfinite(__y) \ |
(__extension__ ({int __cy; \ |
(sizeof (__y) == sizeof (float)) ? (1) : \ |
(__cy = fpclassify(__y)) != FP_INFINITE && __cy != FP_NAN;})) |
#define isinf(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isinfd(__x)) |
#define isnan(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isnand(__x)) |
/* |
* Macros for use in ieeefp.h. We can't just define the real ones here |
* (like those above) as we have name space issues when this is *not* |
* included via generic the ieeefp.h. |
*/ |
#define __ieeefp_isnanf(x) 0 |
#define __ieeefp_isinff(x) 0 |
#define __ieeefp_finitef(x) 1 |
#endif |
#ifdef __sparc__ |
#ifdef __LITTLE_ENDIAN_DATA__ |
#define __IEEE_LITTLE_ENDIAN |
#else |
#define __IEEE_BIG_ENDIAN |
#endif |
#endif |
#if defined(__m68k__) || defined(__mc68000__) |
#define __IEEE_BIG_ENDIAN |
#endif |
#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__) |
#define __IEEE_BIG_ENDIAN |
#ifdef __HAVE_SHORT_DOUBLE__ |
# define _DOUBLE_IS_32BITS |
#endif |
#endif |
#if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) || defined (__H8500__) || defined (__H8300SX__) |
#define __IEEE_BIG_ENDIAN |
#define _FLOAT_ARG float |
#define _DOUBLE_IS_32BITS |
#endif |
#if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__) |
#define __IEEE_LITTLE_ENDIAN |
#define _FLOAT_ARG float |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __sh__ |
#ifdef __LITTLE_ENDIAN__ |
#define __IEEE_LITTLE_ENDIAN |
#else |
#define __IEEE_BIG_ENDIAN |
#endif |
#if defined(__SH2E__) || defined(__SH3E__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A_SINGLE_ONLY__) |
#define _DOUBLE_IS_32BITS |
#endif |
#endif |
#ifdef _AM29K |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef _WIN32 |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __i386__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __i960__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __lm32__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __M32R__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#if defined(_C4x) || defined(_C3x) |
#define __IEEE_BIG_ENDIAN |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __TMS320C6X__ |
#ifdef _BIG_ENDIAN |
#define __IEEE_BIG_ENDIAN |
#else |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#endif |
#ifdef __TIC80__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __MIPSEL__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __MIPSEB__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __MMIX__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __D30V__ |
#define __IEEE_BIG_ENDIAN |
#endif |
/* necv70 was __IEEE_LITTLE_ENDIAN. */ |
#ifdef __W65__ |
#define __IEEE_LITTLE_ENDIAN |
#define _DOUBLE_IS_32BITS |
#endif |
#if defined(__Z8001__) || defined(__Z8002__) |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __m88k__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __mn10300__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __mn10200__ |
#define __IEEE_LITTLE_ENDIAN |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __v800 |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __v850 |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __D10V__ |
#define __IEEE_BIG_ENDIAN |
#if __DOUBLE__ == 32 |
#define _DOUBLE_IS_32BITS |
#endif |
#endif |
#ifdef __PPC__ |
#if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX) |
#define __IEEE_BIG_ENDIAN |
#else |
#if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(_WIN32) && _WIN32) |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#endif |
#endif |
#ifdef __xstormy16__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __arc__ |
#ifdef __big_endian__ |
#define __IEEE_BIG_ENDIAN |
#else |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#endif |
#ifdef __CRX__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __fr30__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __mcore__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __mt__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __frv__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __moxie__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __ia64__ |
#ifdef __BIG_ENDIAN__ |
#define __IEEE_BIG_ENDIAN |
#else |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#endif |
#ifdef __AVR__ |
#define __IEEE_LITTLE_ENDIAN |
#define _DOUBLE_IS_32BITS |
#endif |
#if defined(__or32__) || defined(__or1k__) || defined(__or16__) |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __IP2K__ |
#define __IEEE_BIG_ENDIAN |
#define __SMALL_BITFIELDS |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __iq2000__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __MAVERICK__ |
#ifdef __ARMEL__ |
# define __IEEE_LITTLE_ENDIAN |
#else /* must be __ARMEB__ */ |
# define __IEEE_BIG_ENDIAN |
#endif /* __ARMEL__ */ |
#endif /* __MAVERICK__ */ |
#ifdef __m32c__ |
#define __IEEE_LITTLE_ENDIAN |
#define __SMALL_BITFIELDS |
#endif |
#ifdef __CRIS__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __BFIN__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __x86_64__ |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifdef __mep__ |
#ifdef __LITTLE_ENDIAN__ |
#define __IEEE_LITTLE_ENDIAN |
#else |
#define __IEEE_BIG_ENDIAN |
#endif |
#endif |
#ifdef __MICROBLAZE__ |
#define __IEEE_BIG_ENDIAN |
#endif |
#ifdef __RL78__ |
#define __IEEE_LITTLE_ENDIAN |
#define __SMALL_BITFIELDS /* 16 Bit INT */ |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __RX__ |
#ifdef __RX_BIG_ENDIAN__ |
#define __IEEE_BIG_ENDIAN |
#else |
#define __IEEE_LITTLE_ENDIAN |
#endif |
#ifndef __RX_64BIT_DOUBLES__ |
#define _DOUBLE_IS_32BITS |
#endif |
#ifdef __RX_16BIT_INTS__ |
#define __SMALL_BITFIELDS |
#endif |
#endif |
#if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__)) |
#define __IEEE_LITTLE_ENDIAN |
#define __SMALL_BITFIELDS /* 16 Bit INT */ |
#endif |
#ifndef __IEEE_BIG_ENDIAN |
#ifndef __IEEE_LITTLE_ENDIAN |
#error Endianess not declared!! |
#endif /* not __IEEE_LITTLE_ENDIAN */ |
#endif /* not __IEEE_BIG_ENDIAN */ |
#endif /* not __IEEE_LITTLE_ENDIAN */ |
#endif /* not __IEEE_BIG_ENDIAN */ |
/contrib/sdk/sources/libc/include/machine/malloc.h |
---|
0,0 → 1,8 |
#ifndef _MACHMALLOC_H_ |
#define _MACHMALLOC_H_ |
/* place holder so platforms may add malloc.h extensions */ |
#endif /* _MACHMALLOC_H_ */ |
/contrib/sdk/sources/libc/include/machine/param.h |
---|
0,0 → 1,0 |
/* Place holder for machine-specific param.h. */ |
/contrib/sdk/sources/libc/include/machine/setjmp-dj.h |
---|
0,0 → 1,43 |
/* |
* Copyright (C) 1991 DJ Delorie |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms is permitted |
* provided that the above copyright notice and following paragraph are |
* duplicated in all such forms. |
* |
* This file is distributed WITHOUT ANY WARRANTY; without even the implied |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* Modified to use SETJMP_DJ_H rather than SETJMP_H to avoid |
conflicting with setjmp.h. Ian Taylor, Cygnus support, April, |
1993. */ |
#ifndef _SETJMP_DJ_H_ |
#define _SETJMP_DJ_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
typedef struct { |
unsigned long eax; |
unsigned long ebx; |
unsigned long ecx; |
unsigned long edx; |
unsigned long esi; |
unsigned long edi; |
unsigned long ebp; |
unsigned long esp; |
unsigned long eip; |
} jmp_buf[1]; |
extern int setjmp(jmp_buf); |
extern void longjmp(jmp_buf, int); |
#ifdef __cplusplus |
} |
#endif |
#endif |
/contrib/sdk/sources/libc/include/machine/setjmp.h |
---|
0,0 → 1,8 |
_BEGIN_STD_C |
#include "setjmp-dj.h" |
_END_STD_C |
/contrib/sdk/sources/libc/include/machine/stdlib.h |
---|
0,0 → 1,8 |
#ifndef _MACHSTDLIB_H_ |
#define _MACHSTDLIB_H_ |
/* place holder so platforms may add stdlib.h extensions */ |
#endif /* _MACHSTDLIB_H_ */ |
/contrib/sdk/sources/libc/include/machine/termios.h |
---|
0,0 → 1,0 |
#define __MAX_BAUD B4000000 |
/contrib/sdk/sources/libc/include/machine/time.h |
---|
0,0 → 1,19 |
#ifndef _MACHTIME_H_ |
#define _MACHTIME_H_ |
#if defined(__rtems__) |
#define _CLOCKS_PER_SEC_ sysconf(_SC_CLK_TCK) |
#else /* !__rtems__ */ |
#if defined(__arm__) || defined(__thumb__) |
#define _CLOCKS_PER_SEC_ 100 |
#endif |
#endif /* !__rtems__ */ |
#ifdef __SPU__ |
#include <sys/types.h> |
int nanosleep (const struct timespec *, struct timespec *); |
#endif |
#endif /* _MACHTIME_H_ */ |
/contrib/sdk/sources/libc/include/machine/types.h |
---|
0,0 → 1,30 |
#ifndef _MACHTYPES_H_ |
#define _MACHTYPES_H_ |
/* |
* The following section is RTEMS specific and is needed to more |
* closely match the types defined in the BSD machine/types.h. |
* This is needed to let the RTEMS/BSD TCP/IP stack compile. |
*/ |
#if defined(__rtems__) |
#include <machine/_types.h> |
#endif |
#define _CLOCK_T_ unsigned long /* clock() */ |
#define _TIME_T_ long /* time() */ |
#define _CLOCKID_T_ unsigned long |
#define _TIMER_T_ unsigned long |
#ifndef _HAVE_SYSTYPES |
typedef long int __off_t; |
typedef int __pid_t; |
#ifdef __GNUC__ |
__extension__ typedef long long int __loff_t; |
#else |
typedef long int __loff_t; |
#endif |
#endif |
#endif /* _MACHTYPES_H_ */ |
/contrib/sdk/sources/libc/include/malloc.h |
---|
0,0 → 1,169 |
/* malloc.h -- header file for memory routines. */ |
#ifndef _INCLUDE_MALLOC_H_ |
#define _INCLUDE_MALLOC_H_ |
#include <_ansi.h> |
#include <sys/reent.h> |
#define __need_size_t |
#include <stddef.h> |
/* include any machine-specific extensions */ |
#include <machine/malloc.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* This version of struct mallinfo must match the one in |
libc/stdlib/mallocr.c. */ |
struct mallinfo { |
int arena; /* total space allocated from system */ |
int ordblks; /* number of non-inuse chunks */ |
int smblks; /* unused -- always zero */ |
int hblks; /* number of mmapped regions */ |
int hblkhd; /* total space in mmapped regions */ |
int usmblks; /* unused -- always zero */ |
int fsmblks; /* unused -- always zero */ |
int uordblks; /* total allocated space */ |
int fordblks; /* total non-inuse space */ |
int keepcost; /* top-most, releasable (via malloc_trim) space */ |
}; |
/* The routines. */ |
extern _PTR malloc _PARAMS ((size_t)); |
#ifdef __CYGWIN__ |
#undef _malloc_r |
#define _malloc_r(r, s) malloc (s) |
#else |
extern _PTR _malloc_r _PARAMS ((struct _reent *, size_t)); |
#endif |
extern _VOID free _PARAMS ((_PTR)); |
#ifdef __CYGWIN__ |
#undef _free_r |
#define _free_r(r, p) free (p) |
#else |
extern _VOID _free_r _PARAMS ((struct _reent *, _PTR)); |
#endif |
extern _PTR realloc _PARAMS ((_PTR, size_t)); |
#ifdef __CYGWIN__ |
#undef _realloc_r |
#define _realloc_r(r, p, s) realloc (p, s) |
#else |
extern _PTR _realloc_r _PARAMS ((struct _reent *, _PTR, size_t)); |
#endif |
extern _PTR calloc _PARAMS ((size_t, size_t)); |
#ifdef __CYGWIN__ |
#undef _calloc_r |
#define _calloc_r(r, s1, s2) calloc (s1, s2); |
#else |
extern _PTR _calloc_r _PARAMS ((struct _reent *, size_t, size_t)); |
#endif |
extern _PTR memalign _PARAMS ((size_t, size_t)); |
#ifdef __CYGWIN__ |
#undef _memalign_r |
#define _memalign_r(r, s1, s2) memalign (s1, s2); |
#else |
extern _PTR _memalign_r _PARAMS ((struct _reent *, size_t, size_t)); |
#endif |
extern struct mallinfo mallinfo _PARAMS ((void)); |
#ifdef __CYGWIN__ |
#undef _mallinfo_r |
#define _mallinfo_r(r) mallinfo () |
#else |
extern struct mallinfo _mallinfo_r _PARAMS ((struct _reent *)); |
#endif |
extern void malloc_stats _PARAMS ((void)); |
#ifdef __CYGWIN__ |
#undef _malloc_stats_r |
#define _malloc_stats_r(r) malloc_stats () |
#else |
extern void _malloc_stats_r _PARAMS ((struct _reent *)); |
#endif |
extern int mallopt _PARAMS ((int, int)); |
#ifdef __CYGWIN__ |
#undef _mallopt_r |
#define _mallopt_r(i1, i2) mallopt (i1, i2) |
#else |
extern int _mallopt_r _PARAMS ((struct _reent *, int, int)); |
#endif |
extern size_t malloc_usable_size _PARAMS ((_PTR)); |
#ifdef __CYGWIN__ |
#undef _malloc_usable_size_r |
#define _malloc_usable_size_r(r, p) malloc_usable_size (p) |
#else |
extern size_t _malloc_usable_size_r _PARAMS ((struct _reent *, _PTR)); |
#endif |
/* These aren't too useful on an embedded system, but we define them |
anyhow. */ |
extern _PTR valloc _PARAMS ((size_t)); |
#ifdef __CYGWIN__ |
#undef _valloc_r |
#define _valloc_r(r, s) valloc (s) |
#else |
extern _PTR _valloc_r _PARAMS ((struct _reent *, size_t)); |
#endif |
extern _PTR pvalloc _PARAMS ((size_t)); |
#ifdef __CYGWIN__ |
#undef _pvalloc_r |
#define _pvalloc_r(r, s) pvalloc (s) |
#else |
extern _PTR _pvalloc_r _PARAMS ((struct _reent *, size_t)); |
#endif |
extern int malloc_trim _PARAMS ((size_t)); |
#ifdef __CYGWIN__ |
#undef _malloc_trim_r |
#define _malloc_trim_r(r, s) malloc_trim (s) |
#else |
extern int _malloc_trim_r _PARAMS ((struct _reent *, size_t)); |
#endif |
/* A compatibility routine for an earlier version of the allocator. */ |
extern _VOID mstats _PARAMS ((char *)); |
#ifdef __CYGWIN__ |
#undef _mstats_r |
#define _mstats_r(r, p) mstats (p) |
#else |
extern _VOID _mstats_r _PARAMS ((struct _reent *, char *)); |
#endif |
/* SVID2/XPG mallopt options */ |
#define M_MXFAST 1 /* UNUSED in this malloc */ |
#define M_NLBLKS 2 /* UNUSED in this malloc */ |
#define M_GRAIN 3 /* UNUSED in this malloc */ |
#define M_KEEP 4 /* UNUSED in this malloc */ |
/* mallopt options that actually do something */ |
#define M_TRIM_THRESHOLD -1 |
#define M_TOP_PAD -2 |
#define M_MMAP_THRESHOLD -3 |
#define M_MMAP_MAX -4 |
#ifndef __CYGWIN__ |
/* Some systems provide this, so do too for compatibility. */ |
extern void cfree _PARAMS ((_PTR)); |
#endif /* __CYGWIN__ */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* _INCLUDE_MALLOC_H_ */ |
/contrib/sdk/sources/libc/include/math.h |
---|
0,0 → 1,580 |
#ifndef _MATH_H_ |
#define _MATH_H_ |
#include <sys/reent.h> |
#include <machine/ieeefp.h> |
#include "_ansi.h" |
_BEGIN_STD_C |
/* __dmath, __fmath, and __ldmath are only here for backwards compatibility |
* in case any code used them. They are no longer used by Newlib, itself, |
* other than legacy. */ |
union __dmath |
{ |
double d; |
__ULong i[2]; |
}; |
union __fmath |
{ |
float f; |
__ULong i[1]; |
}; |
#if defined(_HAVE_LONG_DOUBLE) |
union __ldmath |
{ |
long double ld; |
__ULong i[4]; |
}; |
#endif |
/* Natural log of 2 */ |
#define _M_LN2 0.693147180559945309417 |
#if defined(__GNUC__) && \ |
( (__GNUC__ >= 4) || \ |
( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) ) |
/* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */ |
# ifndef HUGE_VAL |
# define HUGE_VAL (__builtin_huge_val()) |
# endif |
# ifndef HUGE_VALF |
# define HUGE_VALF (__builtin_huge_valf()) |
# endif |
# ifndef HUGE_VALL |
# define HUGE_VALL (__builtin_huge_vall()) |
# endif |
# ifndef INFINITY |
# define INFINITY (__builtin_inff()) |
# endif |
# ifndef NAN |
# define NAN (__builtin_nanf("")) |
# endif |
#else /* !gcc >= 3.3 */ |
/* No builtins. Use fixed defines instead. (All 3 HUGE plus the INFINITY |
* and NAN macros are required to be constant expressions. Using a variable-- |
* even a static const--does not meet this requirement, as it cannot be |
* evaluated at translation time.) |
* The infinities are done using numbers that are far in excess of |
* something that would be expected to be encountered in a floating-point |
* implementation. (A more certain way uses values from float.h, but that is |
* avoided because system includes are not supposed to include each other.) |
* This method might produce warnings from some compilers. (It does in |
* newer GCCs, but not for ones that would hit this #else.) If this happens, |
* please report details to the Newlib mailing list. */ |
#ifndef HUGE_VAL |
#define HUGE_VAL (1.0e999999999) |
#endif |
#ifndef HUGE_VALF |
#define HUGE_VALF (1.0e999999999F) |
#endif |
#if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE) |
#define HUGE_VALL (1.0e999999999L) |
#endif |
#if !defined(INFINITY) |
#define INFINITY (HUGE_VALF) |
#endif |
#if !defined(NAN) |
#if defined(__GNUC__) && defined(__cplusplus) |
/* Exception: older g++ versions warn about the divide by 0 used in the |
* normal case (even though older gccs do not). This trick suppresses the |
* warning, but causes errors for plain gcc, so is only used in the one |
* special case. */ |
static const union { __ULong __i[1]; float __d; } __Nanf = {0x7FC00000}; |
#define NAN (__Nanf.__d) |
#else |
#define NAN (0.0F/0.0F) |
#endif |
#endif |
#endif /* !gcc >= 3.3 */ |
/* Reentrant ANSI C functions. */ |
#ifndef __math_68881 |
extern double atan _PARAMS((double)); |
extern double cos _PARAMS((double)); |
extern double sin _PARAMS((double)); |
extern double tan _PARAMS((double)); |
extern double tanh _PARAMS((double)); |
extern double frexp _PARAMS((double, int *)); |
extern double modf _PARAMS((double, double *)); |
extern double ceil _PARAMS((double)); |
extern double fabs _PARAMS((double)); |
extern double floor _PARAMS((double)); |
#endif /* ! defined (__math_68881) */ |
/* Non reentrant ANSI C functions. */ |
#ifndef _REENT_ONLY |
#ifndef __math_68881 |
extern double acos _PARAMS((double)); |
extern double asin _PARAMS((double)); |
extern double atan2 _PARAMS((double, double)); |
extern double cosh _PARAMS((double)); |
extern double sinh _PARAMS((double)); |
extern double exp _PARAMS((double)); |
extern double ldexp _PARAMS((double, int)); |
extern double log _PARAMS((double)); |
extern double log10 _PARAMS((double)); |
extern double pow _PARAMS((double, double)); |
extern double sqrt _PARAMS((double)); |
extern double fmod _PARAMS((double, double)); |
#endif /* ! defined (__math_68881) */ |
#endif /* ! defined (_REENT_ONLY) */ |
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L |
/* ISO C99 types and macros. */ |
#ifndef FLT_EVAL_METHOD |
#define FLT_EVAL_METHOD 0 |
typedef float float_t; |
typedef double double_t; |
#endif /* FLT_EVAL_METHOD */ |
#define FP_NAN 0 |
#define FP_INFINITE 1 |
#define FP_ZERO 2 |
#define FP_SUBNORMAL 3 |
#define FP_NORMAL 4 |
#ifndef FP_ILOGB0 |
# define FP_ILOGB0 (-INT_MAX) |
#endif |
#ifndef FP_ILOGBNAN |
# define FP_ILOGBNAN INT_MAX |
#endif |
#ifndef MATH_ERRNO |
# define MATH_ERRNO 1 |
#endif |
#ifndef MATH_ERREXCEPT |
# define MATH_ERREXCEPT 2 |
#endif |
#ifndef math_errhandling |
# define math_errhandling MATH_ERRNO |
#endif |
extern int __isinff (float x); |
extern int __isinfd (double x); |
extern int __isnanf (float x); |
extern int __isnand (double x); |
extern int __fpclassifyf (float x); |
extern int __fpclassifyd (double x); |
extern int __signbitf (float x); |
extern int __signbitd (double x); |
#define fpclassify(__x) \ |
((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \ |
__fpclassifyd(__x)) |
#ifndef isfinite |
#define isfinite(__y) \ |
(__extension__ ({int __cy = fpclassify(__y); \ |
__cy != FP_INFINITE && __cy != FP_NAN;})) |
#endif |
/* Note: isinf and isnan were once functions in newlib that took double |
* arguments. C99 specifies that these names are reserved for macros |
* supporting multiple floating point types. Thus, they are |
* now defined as macros. Implementations of the old functions |
* taking double arguments still exist for compatibility purposes |
* (prototypes for them are in <ieeefp.h>). */ |
#ifndef isinf |
#define isinf(y) (fpclassify(y) == FP_INFINITE) |
#endif |
#ifndef isnan |
#define isnan(y) (fpclassify(y) == FP_NAN) |
#endif |
#define isnormal(y) (fpclassify(y) == FP_NORMAL) |
#define signbit(__x) \ |
((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \ |
__signbitd(__x)) |
#define isgreater(x,y) \ |
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
!isunordered(__x,__y) && (__x > __y);})) |
#define isgreaterequal(x,y) \ |
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
!isunordered(__x,__y) && (__x >= __y);})) |
#define isless(x,y) \ |
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
!isunordered(__x,__y) && (__x < __y);})) |
#define islessequal(x,y) \ |
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
!isunordered(__x,__y) && (__x <= __y);})) |
#define islessgreater(x,y) \ |
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ |
!isunordered(__x,__y) && (__x < __y || __x > __y);})) |
#define isunordered(a,b) \ |
(__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \ |
fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;})) |
/* Non ANSI double precision functions. */ |
extern double infinity _PARAMS((void)); |
extern double nan _PARAMS((const char *)); |
extern int finite _PARAMS((double)); |
extern double copysign _PARAMS((double, double)); |
extern double logb _PARAMS((double)); |
extern int ilogb _PARAMS((double)); |
extern double asinh _PARAMS((double)); |
extern double cbrt _PARAMS((double)); |
extern double nextafter _PARAMS((double, double)); |
extern double rint _PARAMS((double)); |
extern double scalbn _PARAMS((double, int)); |
extern double exp2 _PARAMS((double)); |
extern double scalbln _PARAMS((double, long int)); |
extern double tgamma _PARAMS((double)); |
extern double nearbyint _PARAMS((double)); |
extern long int lrint _PARAMS((double)); |
extern _LONG_LONG_TYPE int llrint _PARAMS((double)); |
extern double round _PARAMS((double)); |
extern long int lround _PARAMS((double)); |
extern long long int llround _PARAMS((double)); |
extern double trunc _PARAMS((double)); |
extern double remquo _PARAMS((double, double, int *)); |
extern double fdim _PARAMS((double, double)); |
extern double fmax _PARAMS((double, double)); |
extern double fmin _PARAMS((double, double)); |
extern double fma _PARAMS((double, double, double)); |
#ifndef __math_68881 |
extern double log1p _PARAMS((double)); |
extern double expm1 _PARAMS((double)); |
#endif /* ! defined (__math_68881) */ |
#ifndef _REENT_ONLY |
extern double acosh _PARAMS((double)); |
extern double atanh _PARAMS((double)); |
extern double remainder _PARAMS((double, double)); |
extern double gamma _PARAMS((double)); |
extern double lgamma _PARAMS((double)); |
extern double erf _PARAMS((double)); |
extern double erfc _PARAMS((double)); |
extern double log2 _PARAMS((double)); |
#if !defined(__cplusplus) |
#define log2(x) (log (x) / _M_LN2) |
#endif |
#ifndef __math_68881 |
extern double hypot _PARAMS((double, double)); |
#endif |
#endif /* ! defined (_REENT_ONLY) */ |
/* Single precision versions of ANSI functions. */ |
extern float atanf _PARAMS((float)); |
extern float cosf _PARAMS((float)); |
extern float sinf _PARAMS((float)); |
extern float tanf _PARAMS((float)); |
extern float tanhf _PARAMS((float)); |
extern float frexpf _PARAMS((float, int *)); |
extern float modff _PARAMS((float, float *)); |
extern float ceilf _PARAMS((float)); |
extern float fabsf _PARAMS((float)); |
extern float floorf _PARAMS((float)); |
#ifndef _REENT_ONLY |
extern float acosf _PARAMS((float)); |
extern float asinf _PARAMS((float)); |
extern float atan2f _PARAMS((float, float)); |
extern float coshf _PARAMS((float)); |
extern float sinhf _PARAMS((float)); |
extern float expf _PARAMS((float)); |
extern float ldexpf _PARAMS((float, int)); |
extern float logf _PARAMS((float)); |
extern float log10f _PARAMS((float)); |
extern float powf _PARAMS((float, float)); |
extern float sqrtf _PARAMS((float)); |
extern float fmodf _PARAMS((float, float)); |
#endif /* ! defined (_REENT_ONLY) */ |
/* Other single precision functions. */ |
extern float exp2f _PARAMS((float)); |
extern float scalblnf _PARAMS((float, long int)); |
extern float tgammaf _PARAMS((float)); |
extern float nearbyintf _PARAMS((float)); |
extern long int lrintf _PARAMS((float)); |
extern _LONG_LONG_TYPE llrintf _PARAMS((float)); |
extern float roundf _PARAMS((float)); |
extern long int lroundf _PARAMS((float)); |
extern long long int llroundf _PARAMS((float)); |
extern float truncf _PARAMS((float)); |
extern float remquof _PARAMS((float, float, int *)); |
extern float fdimf _PARAMS((float, float)); |
extern float fmaxf _PARAMS((float, float)); |
extern float fminf _PARAMS((float, float)); |
extern float fmaf _PARAMS((float, float, float)); |
extern float infinityf _PARAMS((void)); |
extern float nanf _PARAMS((const char *)); |
extern int finitef _PARAMS((float)); |
extern float copysignf _PARAMS((float, float)); |
extern float logbf _PARAMS((float)); |
extern int ilogbf _PARAMS((float)); |
extern float asinhf _PARAMS((float)); |
extern float cbrtf _PARAMS((float)); |
extern float nextafterf _PARAMS((float, float)); |
extern float rintf _PARAMS((float)); |
extern float scalbnf _PARAMS((float, int)); |
extern float log1pf _PARAMS((float)); |
extern float expm1f _PARAMS((float)); |
#ifndef _REENT_ONLY |
extern float acoshf _PARAMS((float)); |
extern float atanhf _PARAMS((float)); |
extern float remainderf _PARAMS((float, float)); |
extern float gammaf _PARAMS((float)); |
extern float lgammaf _PARAMS((float)); |
extern float erff _PARAMS((float)); |
extern float erfcf _PARAMS((float)); |
extern float log2f _PARAMS((float)); |
#if !defined(__cplusplus) |
#define log2f(x) (logf (x) / (float_t) _M_LN2) |
#endif |
extern float hypotf _PARAMS((float, float)); |
#endif /* ! defined (_REENT_ONLY) */ |
/* On platforms where long double equals double. */ |
#ifdef _LDBL_EQ_DBL |
/* Reentrant ANSI C functions. */ |
#ifndef __math_68881 |
extern long double atanl _PARAMS((long double)); |
extern long double cosl _PARAMS((long double)); |
extern long double sinl _PARAMS((long double)); |
extern long double tanl _PARAMS((long double)); |
extern long double tanhl _PARAMS((long double)); |
extern long double frexpl _PARAMS((long double value, int *)); |
extern long double modfl _PARAMS((long double, long double *)); |
extern long double ceill _PARAMS((long double)); |
extern long double fabsl _PARAMS((long double)); |
extern long double floorl _PARAMS((long double)); |
extern long double log1pl _PARAMS((long double)); |
extern long double expm1l _PARAMS((long double)); |
#endif /* ! defined (__math_68881) */ |
/* Non reentrant ANSI C functions. */ |
#ifndef _REENT_ONLY |
#ifndef __math_68881 |
extern long double acosl _PARAMS((long double)); |
extern long double asinl _PARAMS((long double)); |
extern long double atan2l _PARAMS((long double, long double)); |
extern long double coshl _PARAMS((long double)); |
extern long double sinhl _PARAMS((long double)); |
extern long double expl _PARAMS((long double)); |
extern long double ldexpl _PARAMS((long double, int)); |
extern long double logl _PARAMS((long double)); |
extern long double log10l _PARAMS((long double)); |
extern long double powl _PARAMS((long double, long double)); |
extern long double sqrtl _PARAMS((long double)); |
extern long double fmodl _PARAMS((long double, long double)); |
extern long double hypotl _PARAMS((long double, long double)); |
#endif /* ! defined (__math_68881) */ |
#endif /* ! defined (_REENT_ONLY) */ |
extern long double copysignl _PARAMS((long double, long double)); |
extern long double nanl _PARAMS((const char *)); |
extern int ilogbl _PARAMS((long double)); |
extern long double asinhl _PARAMS((long double)); |
extern long double cbrtl _PARAMS((long double)); |
extern long double nextafterl _PARAMS((long double, long double)); |
extern long double rintl _PARAMS((long double)); |
extern long double scalbnl _PARAMS((long double, int)); |
extern long double exp2l _PARAMS((long double)); |
extern long double scalblnl _PARAMS((long double, long)); |
extern long double tgammal _PARAMS((long double)); |
extern long double nearbyintl _PARAMS((long double)); |
extern long int lrintl _PARAMS((long double)); |
extern long long int llrintl _PARAMS((long double)); |
extern long double roundl _PARAMS((long double)); |
extern long lroundl _PARAMS((long double)); |
extern _LONG_LONG_TYPE int llroundl _PARAMS((long double)); |
extern long double truncl _PARAMS((long double)); |
extern long double remquol _PARAMS((long double, long double, int *)); |
extern long double fdiml _PARAMS((long double, long double)); |
extern long double fmaxl _PARAMS((long double, long double)); |
extern long double fminl _PARAMS((long double, long double)); |
extern long double fmal _PARAMS((long double, long double, long double)); |
#ifndef _REENT_ONLY |
extern long double acoshl _PARAMS((long double)); |
extern long double atanhl _PARAMS((long double)); |
extern long double remainderl _PARAMS((long double, long double)); |
extern long double lgammal _PARAMS((long double)); |
extern long double erfl _PARAMS((long double)); |
extern long double erfcl _PARAMS((long double)); |
#endif /* ! defined (_REENT_ONLY) */ |
#else /* !_LDBL_EQ_DBL */ |
#ifdef __i386__ |
/* Other long double precision functions. */ |
extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE)); |
extern long int lrintl _PARAMS((_LONG_DOUBLE)); |
extern _LONG_LONG_TYPE llrintl _PARAMS((_LONG_DOUBLE)); |
#endif /* __i386__ */ |
#endif /* !_LDBL_EQ_DBL */ |
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L */ |
#if !defined (__STRICT_ANSI__) || defined(__cplusplus) |
extern double drem _PARAMS((double, double)); |
extern void sincos _PARAMS((double, double *, double *)); |
extern double gamma_r _PARAMS((double, int *)); |
extern double lgamma_r _PARAMS((double, int *)); |
extern double y0 _PARAMS((double)); |
extern double y1 _PARAMS((double)); |
extern double yn _PARAMS((int, double)); |
extern double j0 _PARAMS((double)); |
extern double j1 _PARAMS((double)); |
extern double jn _PARAMS((int, double)); |
extern float dremf _PARAMS((float, float)); |
extern void sincosf _PARAMS((float, float *, float *)); |
extern float gammaf_r _PARAMS((float, int *)); |
extern float lgammaf_r _PARAMS((float, int *)); |
extern float y0f _PARAMS((float)); |
extern float y1f _PARAMS((float)); |
extern float ynf _PARAMS((int, float)); |
extern float j0f _PARAMS((float)); |
extern float j1f _PARAMS((float)); |
extern float jnf _PARAMS((int, float)); |
/* GNU extensions */ |
# ifndef exp10 |
extern double exp10 _PARAMS((double)); |
# endif |
# ifndef pow10 |
extern double pow10 _PARAMS((double)); |
# endif |
# ifndef exp10f |
extern float exp10f _PARAMS((float)); |
# endif |
# ifndef pow10f |
extern float pow10f _PARAMS((float)); |
# endif |
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) */ |
#ifndef __STRICT_ANSI__ |
/* The gamma functions use a global variable, signgam. */ |
#ifndef _REENT_ONLY |
#define signgam (*__signgam()) |
extern int *__signgam _PARAMS((void)); |
#endif /* ! defined (_REENT_ONLY) */ |
#define __signgam_r(ptr) _REENT_SIGNGAM(ptr) |
/* The exception structure passed to the matherr routine. */ |
/* We have a problem when using C++ since `exception' is a reserved |
name in C++. */ |
#ifdef __cplusplus |
struct __exception |
#else |
struct exception |
#endif |
{ |
int type; |
char *name; |
double arg1; |
double arg2; |
double retval; |
int err; |
}; |
#ifdef __cplusplus |
extern int matherr _PARAMS((struct __exception *e)); |
#else |
extern int matherr _PARAMS((struct exception *e)); |
#endif |
/* Values for the type field of struct exception. */ |
#define DOMAIN 1 |
#define SING 2 |
#define OVERFLOW 3 |
#define UNDERFLOW 4 |
#define TLOSS 5 |
#define PLOSS 6 |
/* Useful constants. */ |
#define MAXFLOAT 3.40282347e+38F |
#define M_E 2.7182818284590452354 |
#define M_LOG2E 1.4426950408889634074 |
#define M_LOG10E 0.43429448190325182765 |
#define M_LN2 _M_LN2 |
#define M_LN10 2.30258509299404568402 |
#define M_PI 3.14159265358979323846 |
#define M_TWOPI (M_PI * 2.0) |
#define M_PI_2 1.57079632679489661923 |
#define M_PI_4 0.78539816339744830962 |
#define M_3PI_4 2.3561944901923448370E0 |
#define M_SQRTPI 1.77245385090551602792981 |
#define M_1_PI 0.31830988618379067154 |
#define M_2_PI 0.63661977236758134308 |
#define M_2_SQRTPI 1.12837916709551257390 |
#define M_SQRT2 1.41421356237309504880 |
#define M_SQRT1_2 0.70710678118654752440 |
#define M_LN2LO 1.9082149292705877000E-10 |
#define M_LN2HI 6.9314718036912381649E-1 |
#define M_SQRT3 1.73205080756887719000 |
#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */ |
#define M_LOG2_E _M_LN2 |
#define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */ |
/* Global control over fdlibm error handling. */ |
enum __fdlibm_version |
{ |
__fdlibm_ieee = -1, |
__fdlibm_svid, |
__fdlibm_xopen, |
__fdlibm_posix |
}; |
#define _LIB_VERSION_TYPE enum __fdlibm_version |
#define _LIB_VERSION __fdlib_version |
extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION; |
#define _IEEE_ __fdlibm_ieee |
#define _SVID_ __fdlibm_svid |
#define _XOPEN_ __fdlibm_xopen |
#define _POSIX_ __fdlibm_posix |
#endif /* ! defined (__STRICT_ANSI__) */ |
_END_STD_C |
#ifdef __FAST_MATH__ |
#include <machine/fastmath.h> |
#endif |
#endif /* _MATH_H_ */ |
/contrib/sdk/sources/libc/include/newlib.h |
---|
0,0 → 1,173 |
/* newlib.h. Generated from newlib.hin by configure. */ |
/* newlib.hin. Manually edited from the output of autoheader to |
remove all PACKAGE_ macros which will collide with any user |
package using newlib header files and having its own package name, |
version, etc... */ |
#ifndef __NEWLIB_H__ |
#define __NEWLIB_H__ 1 |
/* EL/IX level */ |
/* #undef _ELIX_LEVEL */ |
/* Newlib version */ |
#define _NEWLIB_VERSION "1.19.0" |
/* C99 formats support (such as %a, %zu, ...) in IO functions like |
* printf/scanf enabled */ |
//#define _WANT_IO_C99_FORMATS |
#define __DYNAMIC_REENT__ |
/* long long type support in IO functions like printf/scanf enabled */ |
#define _WANT_IO_LONG_LONG |
/* Register application finalization function using atexit. */ |
/* #undef _WANT_REGISTER_FINI */ |
/* long double type support in IO functions like printf/scanf enabled */ |
/* #undef _WANT_IO_LONG_DOUBLE */ |
/* Positional argument support in printf functions enabled. */ |
/* #undef _WANT_IO_POS_ARGS */ |
/* Optional reentrant struct support. Used mostly on platforms with |
very restricted storage. */ |
/* #undef _WANT_REENT_SMALL */ |
/* Multibyte supported */ |
/* #undef _MB_CAPABLE */ |
/* MB_LEN_MAX */ |
#define _MB_LEN_MAX 1 |
/* ICONV enabled */ |
/* #undef _ICONV_ENABLED */ |
/* Enable ICONV external CCS files loading capabilities */ |
/* #undef _ICONV_ENABLE_EXTERNAL_CCS */ |
/* Define if the linker supports .preinit_array/.init_array/.fini_array |
* sections. */ |
#define HAVE_INITFINI_ARRAY 1 |
/* True if atexit() may dynamically allocate space for cleanup |
functions. */ |
#define _ATEXIT_DYNAMIC_ALLOC 1 |
/* True if long double supported. */ |
#define _HAVE_LONG_DOUBLE 1 |
/* True if long double supported and it is equal to double. */ |
/* #undef _LDBL_EQ_DBL */ |
/* |
* Iconv encodings enabled ("to" direction) |
*/ |
/* #undef _ICONV_TO_ENCODING_BIG5 */ |
/* #undef _ICONV_TO_ENCODING_CP775 */ |
/* #undef _ICONV_TO_ENCODING_CP850 */ |
/* #undef _ICONV_TO_ENCODING_CP852 */ |
/* #undef _ICONV_TO_ENCODING_CP855 */ |
/* #undef _ICONV_TO_ENCODING_CP866 */ |
/* #undef _ICONV_TO_ENCODING_EUC_JP */ |
/* #undef _ICONV_TO_ENCODING_EUC_TW */ |
/* #undef _ICONV_TO_ENCODING_EUC_KR */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_1 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_10 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_11 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_13 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_14 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_15 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_2 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_3 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_4 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_5 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_6 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_7 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_8 */ |
/* #undef _ICONV_TO_ENCODING_ISO_8859_9 */ |
/* #undef _ICONV_TO_ENCODING_ISO_IR_111 */ |
/* #undef _ICONV_TO_ENCODING_KOI8_R */ |
/* #undef _ICONV_TO_ENCODING_KOI8_RU */ |
/* #undef _ICONV_TO_ENCODING_KOI8_U */ |
/* #undef _ICONV_TO_ENCODING_KOI8_UNI */ |
/* #undef _ICONV_TO_ENCODING_UCS_2 */ |
/* #undef _ICONV_TO_ENCODING_UCS_2_INTERNAL */ |
/* #undef _ICONV_TO_ENCODING_UCS_2BE */ |
/* #undef _ICONV_TO_ENCODING_UCS_2LE */ |
/* #undef _ICONV_TO_ENCODING_UCS_4 */ |
/* #undef _ICONV_TO_ENCODING_UCS_4_INTERNAL */ |
/* #undef _ICONV_TO_ENCODING_UCS_4BE */ |
/* #undef _ICONV_TO_ENCODING_UCS_4LE */ |
/* #undef _ICONV_TO_ENCODING_US_ASCII */ |
/* #undef _ICONV_TO_ENCODING_UTF_16 */ |
/* #undef _ICONV_TO_ENCODING_UTF_16BE */ |
/* #undef _ICONV_TO_ENCODING_UTF_16LE */ |
/* #undef _ICONV_TO_ENCODING_UTF_8 */ |
/* #undef _ICONV_TO_ENCODING_WIN_1250 */ |
/* #undef _ICONV_TO_ENCODING_WIN_1251 */ |
/* #undef _ICONV_TO_ENCODING_WIN_1252 */ |
/* #undef _ICONV_TO_ENCODING_WIN_1253 */ |
/* #undef _ICONV_TO_ENCODING_WIN_1254 */ |
/* #undef _ICONV_TO_ENCODING_WIN_1255 */ |
/* #undef _ICONV_TO_ENCODING_WIN_1256 */ |
/* #undef _ICONV_TO_ENCODING_WIN_1257 */ |
/* #undef _ICONV_TO_ENCODING_WIN_1258 */ |
/* |
* Iconv encodings enabled ("from" direction) |
*/ |
/* #undef _ICONV_FROM_ENCODING_BIG5 */ |
/* #undef _ICONV_FROM_ENCODING_CP775 */ |
/* #undef _ICONV_FROM_ENCODING_CP850 */ |
/* #undef _ICONV_FROM_ENCODING_CP852 */ |
/* #undef _ICONV_FROM_ENCODING_CP855 */ |
/* #undef _ICONV_FROM_ENCODING_CP866 */ |
/* #undef _ICONV_FROM_ENCODING_EUC_JP */ |
/* #undef _ICONV_FROM_ENCODING_EUC_TW */ |
/* #undef _ICONV_FROM_ENCODING_EUC_KR */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_1 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_10 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_11 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_13 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_14 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_15 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_2 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_3 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_4 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_5 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_6 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_7 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_8 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_8859_9 */ |
/* #undef _ICONV_FROM_ENCODING_ISO_IR_111 */ |
/* #undef _ICONV_FROM_ENCODING_KOI8_R */ |
/* #undef _ICONV_FROM_ENCODING_KOI8_RU */ |
/* #undef _ICONV_FROM_ENCODING_KOI8_U */ |
/* #undef _ICONV_FROM_ENCODING_KOI8_UNI */ |
/* #undef _ICONV_FROM_ENCODING_UCS_2 */ |
/* #undef _ICONV_FROM_ENCODING_UCS_2_INTERNAL */ |
/* #undef _ICONV_FROM_ENCODING_UCS_2BE */ |
/* #undef _ICONV_FROM_ENCODING_UCS_2LE */ |
/* #undef _ICONV_FROM_ENCODING_UCS_4 */ |
/* #undef _ICONV_FROM_ENCODING_UCS_4_INTERNAL */ |
/* #undef _ICONV_FROM_ENCODING_UCS_4BE */ |
/* #undef _ICONV_FROM_ENCODING_UCS_4LE */ |
/* #undef _ICONV_FROM_ENCODING_US_ASCII */ |
/* #undef _ICONV_FROM_ENCODING_UTF_16 */ |
/* #undef _ICONV_FROM_ENCODING_UTF_16BE */ |
/* #undef _ICONV_FROM_ENCODING_UTF_16LE */ |
/* #undef _ICONV_FROM_ENCODING_UTF_8 */ |
/* #undef _ICONV_FROM_ENCODING_WIN_1250 */ |
/* #undef _ICONV_FROM_ENCODING_WIN_1251 */ |
/* #undef _ICONV_FROM_ENCODING_WIN_1252 */ |
/* #undef _ICONV_FROM_ENCODING_WIN_1253 */ |
/* #undef _ICONV_FROM_ENCODING_WIN_1254 */ |
/* #undef _ICONV_FROM_ENCODING_WIN_1255 */ |
/* #undef _ICONV_FROM_ENCODING_WIN_1256 */ |
/* #undef _ICONV_FROM_ENCODING_WIN_1257 */ |
/* #undef _ICONV_FROM_ENCODING_WIN_1258 */ |
#endif /* !__NEWLIB_H__ */ |
/contrib/sdk/sources/libc/include/paths.h |
---|
0,0 → 1,7 |
#ifndef _PATHS_H_ |
#define _PATHS_H_ |
#define _PATH_DEV "/dev/" |
#define _PATH_BSHELL "/bin/sh" |
#endif /* _PATHS_H_ */ |
/contrib/sdk/sources/libc/include/pixlib2.h |
---|
0,0 → 1,39 |
#ifndef __PIXLIB2_H__ |
#define __PIXLIB2_H__ |
#include <stdint.h> |
#define HW_BIT_BLIT (1<<0) /* BGRX blitter */ |
#define HW_TEX_BLIT (1<<1) /* stretch blit */ |
#define HW_VID_BLIT (1<<2) /* planar and packed video */ |
typedef struct |
{ |
uint32_t handle; |
uint8_t *data; |
uint32_t width; |
uint32_t height; |
uint32_t pitch; |
uint32_t max_width; |
uint32_t max_height; |
uint32_t flags; |
}bitmap_t; |
uint32_t init_pixlib(uint32_t flags); |
void done_pixlib(); |
int create_bitmap(bitmap_t *bitmap); |
int destroy_bitmap(bitmap_t *bitmap); |
int lock_bitmap(bitmap_t *bitmap); |
int resize_bitmap(bitmap_t *bitmap); |
int blit_bitmap(bitmap_t * bitmap, int dst_x, int dst_y, |
int w, int h, int src_x, int src_y); |
#endif |
/contrib/sdk/sources/libc/include/process.h |
---|
0,0 → 1,44 |
/* process.h. This file comes with MSDOS and WIN32 systems. */ |
#ifndef __PROCESS_H_ |
#define __PROCESS_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
int execl(const char *path, const char *argv0, ...); |
int execle(const char *path, const char *argv0, ... /*, char * const *envp */); |
int execlp(const char *path, const char *argv0, ...); |
int execlpe(const char *path, const char *argv0, ... /*, char * const *envp */); |
int execv(const char *path, char * const *argv); |
int execve(const char *path, char * const *argv, char * const *envp); |
int execvp(const char *path, char * const *argv); |
int execvpe(const char *path, char * const *argv, char * const *envp); |
int spawnl(int mode, const char *path, const char *argv0, ...); |
int spawnle(int mode, const char *path, const char *argv0, ... /*, char * const *envp */); |
int spawnlp(int mode, const char *path, const char *argv0, ...); |
int spawnlpe(int mode, const char *path, const char *argv0, ... /*, char * const *envp */); |
int spawnv(int mode, const char *path, const char * const *argv); |
int spawnve(int mode, const char *path, const char * const *argv, const char * const *envp); |
int spawnvp(int mode, const char *path, const char * const *argv); |
int spawnvpe(int mode, const char *path, const char * const *argv, const char * const *envp); |
int cwait(int *, int, int); |
#define _P_WAIT 1 |
#define _P_NOWAIT 2 /* always generates error */ |
#define _P_OVERLAY 3 |
#define _P_NOWAITO 4 |
#define _P_DETACH 5 |
#define WAIT_CHILD 1 |
#ifdef __cplusplus |
} |
#endif |
#endif |
/contrib/sdk/sources/libc/include/pthread.h |
---|
0,0 → 1,359 |
/* pthread.h |
* |
* Written by Joel Sherrill <joel@OARcorp.com>. |
* |
* COPYRIGHT (c) 1989-2010. |
* On-Line Applications Research Corporation (OAR). |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION |
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS |
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
* $Id: pthread.h,v 1.9 2010/12/08 14:44:06 corinna Exp $ |
*/ |
#ifndef __PTHREAD_h |
#define __PTHREAD_h |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <unistd.h> |
#if defined(_POSIX_THREADS) |
#include <sys/types.h> |
#include <time.h> |
#include <sys/sched.h> |
/* Register Fork Handlers */ |
int _EXFUN(pthread_atfork,(void (*prepare)(void), void (*parent)(void), |
void (*child)(void))); |
/* Mutex Initialization Attributes, P1003.1c/Draft 10, p. 81 */ |
int _EXFUN(pthread_mutexattr_init, (pthread_mutexattr_t *__attr)); |
int _EXFUN(pthread_mutexattr_destroy, (pthread_mutexattr_t *__attr)); |
int _EXFUN(pthread_mutexattr_getpshared, |
(_CONST pthread_mutexattr_t *__attr, int *__pshared)); |
int _EXFUN(pthread_mutexattr_setpshared, |
(pthread_mutexattr_t *__attr, int __pshared)); |
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) |
/* Single UNIX Specification 2 Mutex Attributes types */ |
int _EXFUN(pthread_mutexattr_gettype, |
(_CONST pthread_mutexattr_t *__attr, int *__kind)); |
int _EXFUN(pthread_mutexattr_settype, |
(pthread_mutexattr_t *__attr, int __kind)); |
#endif |
/* Initializing and Destroying a Mutex, P1003.1c/Draft 10, p. 87 */ |
int _EXFUN(pthread_mutex_init, |
(pthread_mutex_t *__mutex, _CONST pthread_mutexattr_t *__attr)); |
int _EXFUN(pthread_mutex_destroy, (pthread_mutex_t *__mutex)); |
/* This is used to statically initialize a pthread_mutex_t. Example: |
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; |
*/ |
#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF) |
/* Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93 |
NOTE: P1003.4b/D8 adds pthread_mutex_timedlock(), p. 29 */ |
int _EXFUN(pthread_mutex_lock, (pthread_mutex_t *__mutex)); |
int _EXFUN(pthread_mutex_trylock, (pthread_mutex_t *__mutex)); |
int _EXFUN(pthread_mutex_unlock, (pthread_mutex_t *__mutex)); |
#if defined(_POSIX_TIMEOUTS) |
int _EXFUN(pthread_mutex_timedlock, |
(pthread_mutex_t *__mutex, _CONST struct timespec *__timeout)); |
#endif /* _POSIX_TIMEOUTS */ |
/* Condition Variable Initialization Attributes, P1003.1c/Draft 10, p. 96 */ |
int _EXFUN(pthread_condattr_init, (pthread_condattr_t *__attr)); |
int _EXFUN(pthread_condattr_destroy, (pthread_condattr_t *__attr)); |
int _EXFUN(pthread_condattr_getpshared, |
(_CONST pthread_condattr_t *__attr, int *__pshared)); |
int _EXFUN(pthread_condattr_setpshared, |
(pthread_condattr_t *__attr, int __pshared)); |
/* Initializing and Destroying a Condition Variable, P1003.1c/Draft 10, p. 87 */ |
int _EXFUN(pthread_cond_init, |
(pthread_cond_t *__cond, _CONST pthread_condattr_t *__attr)); |
int _EXFUN(pthread_cond_destroy, (pthread_cond_t *__mutex)); |
/* This is used to statically initialize a pthread_cond_t. Example: |
pthread_cond_t cond = PTHREAD_COND_INITIALIZER; |
*/ |
#define PTHREAD_COND_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF) |
/* Broadcasting and Signaling a Condition, P1003.1c/Draft 10, p. 101 */ |
int _EXFUN(pthread_cond_signal, (pthread_cond_t *__cond)); |
int _EXFUN(pthread_cond_broadcast, (pthread_cond_t *__cond)); |
/* Waiting on a Condition, P1003.1c/Draft 10, p. 105 */ |
int _EXFUN(pthread_cond_wait, |
(pthread_cond_t *__cond, pthread_mutex_t *__mutex)); |
int _EXFUN(pthread_cond_timedwait, |
(pthread_cond_t *__cond, pthread_mutex_t *__mutex, |
_CONST struct timespec *__abstime)); |
#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) |
/* Thread Creation Scheduling Attributes, P1003.1c/Draft 10, p. 120 */ |
int _EXFUN(pthread_attr_setscope, |
(pthread_attr_t *__attr, int __contentionscope)); |
int _EXFUN(pthread_attr_getscope, |
(_CONST pthread_attr_t *__attr, int *__contentionscope)); |
int _EXFUN(pthread_attr_setinheritsched, |
(pthread_attr_t *__attr, int __inheritsched)); |
int _EXFUN(pthread_attr_getinheritsched, |
(_CONST pthread_attr_t *__attr, int *__inheritsched)); |
int _EXFUN(pthread_attr_setschedpolicy, |
(pthread_attr_t *__attr, int __policy)); |
int _EXFUN(pthread_attr_getschedpolicy, |
(_CONST pthread_attr_t *__attr, int *__policy)); |
#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */ |
int _EXFUN(pthread_attr_setschedparam, |
(pthread_attr_t *__attr, _CONST struct sched_param *__param)); |
int _EXFUN(pthread_attr_getschedparam, |
(_CONST pthread_attr_t *__attr, struct sched_param *__param)); |
#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) |
/* Dynamic Thread Scheduling Parameters Access, P1003.1c/Draft 10, p. 124 */ |
int _EXFUN(pthread_getschedparam, |
(pthread_t __pthread, int *__policy, struct sched_param *__param)); |
int _EXFUN(pthread_setschedparam, |
(pthread_t __pthread, int __policy, struct sched_param *__param)); |
#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */ |
#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) |
/* Mutex Initialization Scheduling Attributes, P1003.1c/Draft 10, p. 128 */ |
int _EXFUN(pthread_mutexattr_setprotocol, |
(pthread_mutexattr_t *__attr, int __protocol)); |
int _EXFUN(pthread_mutexattr_getprotocol, |
(_CONST pthread_mutexattr_t *__attr, int *__protocol)); |
int _EXFUN(pthread_mutexattr_setprioceiling, |
(pthread_mutexattr_t *__attr, int __prioceiling)); |
int _EXFUN(pthread_mutexattr_getprioceiling, |
(_CONST pthread_mutexattr_t *__attr, int *__prioceiling)); |
#endif /* _POSIX_THREAD_PRIO_INHERIT || _POSIX_THREAD_PRIO_PROTECT */ |
#if defined(_POSIX_THREAD_PRIO_PROTECT) |
/* Change the Priority Ceiling of a Mutex, P1003.1c/Draft 10, p. 131 */ |
int _EXFUN(pthread_mutex_setprioceiling, |
(pthread_mutex_t *__mutex, int __prioceiling, int *__old_ceiling)); |
int _EXFUN(pthread_mutex_getprioceiling, |
(pthread_mutex_t *__mutex, int *__prioceiling)); |
#endif /* _POSIX_THREAD_PRIO_PROTECT */ |
/* Thread Creation Attributes, P1003.1c/Draft 10, p, 140 */ |
int _EXFUN(pthread_attr_init, (pthread_attr_t *__attr)); |
int _EXFUN(pthread_attr_destroy, (pthread_attr_t *__attr)); |
int _EXFUN(pthread_attr_setstack, (pthread_attr_t *attr, |
void *__stackaddr, size_t __stacksize)); |
int _EXFUN(pthread_attr_getstack, (_CONST pthread_attr_t *attr, |
void **__stackaddr, size_t *__stacksize)); |
int _EXFUN(pthread_attr_getstacksize, |
(_CONST pthread_attr_t *__attr, size_t *__stacksize)); |
int _EXFUN(pthread_attr_setstacksize, |
(pthread_attr_t *__attr, size_t __stacksize)); |
int _EXFUN(pthread_attr_getstackaddr, |
(_CONST pthread_attr_t *__attr, void **__stackaddr)); |
int _EXFUN(pthread_attr_setstackaddr, |
(pthread_attr_t *__attr, void *__stackaddr)); |
int _EXFUN(pthread_attr_getdetachstate, |
(_CONST pthread_attr_t *__attr, int *__detachstate)); |
int _EXFUN(pthread_attr_setdetachstate, |
(pthread_attr_t *__attr, int __detachstate)); |
int _EXFUN(pthread_attr_getguardsize, |
(_CONST pthread_attr_t *__attr, size_t *__guardsize)); |
int _EXFUN(pthread_attr_setguardsize, |
(pthread_attr_t *__attr, size_t __guardsize)); |
/* Thread Creation, P1003.1c/Draft 10, p. 144 */ |
int _EXFUN(pthread_create, |
(pthread_t *__pthread, _CONST pthread_attr_t *__attr, |
void *(*__start_routine)( void * ), void *__arg)); |
/* Wait for Thread Termination, P1003.1c/Draft 10, p. 147 */ |
int _EXFUN(pthread_join, (pthread_t __pthread, void **__value_ptr)); |
/* Detaching a Thread, P1003.1c/Draft 10, p. 149 */ |
int _EXFUN(pthread_detach, (pthread_t __pthread)); |
/* Thread Termination, p1003.1c/Draft 10, p. 150 */ |
void _EXFUN(pthread_exit, (void *__value_ptr)); |
/* Get Calling Thread's ID, p1003.1c/Draft 10, p. XXX */ |
pthread_t _EXFUN(pthread_self, (void)); |
/* Compare Thread IDs, p1003.1c/Draft 10, p. 153 */ |
int _EXFUN(pthread_equal, (pthread_t __t1, pthread_t __t2)); |
/* Dynamic Package Initialization */ |
/* This is used to statically initialize a pthread_once_t. Example: |
pthread_once_t once = PTHREAD_ONCE_INIT; |
NOTE: This is named inconsistently -- it should be INITIALIZER. */ |
#define PTHREAD_ONCE_INIT { 1, 0 } /* is initialized and not run */ |
int _EXFUN(pthread_once, |
(pthread_once_t *__once_control, void (*__init_routine)(void))); |
/* Thread-Specific Data Key Create, P1003.1c/Draft 10, p. 163 */ |
int _EXFUN(pthread_key_create, |
(pthread_key_t *__key, void (*__destructor)( void * ))); |
/* Thread-Specific Data Management, P1003.1c/Draft 10, p. 165 */ |
int _EXFUN(pthread_setspecific, |
(pthread_key_t __key, _CONST void *__value)); |
void * _EXFUN(pthread_getspecific, (pthread_key_t __key)); |
/* Thread-Specific Data Key Deletion, P1003.1c/Draft 10, p. 167 */ |
int _EXFUN(pthread_key_delete, (pthread_key_t __key)); |
/* Execution of a Thread, P1003.1c/Draft 10, p. 181 */ |
#define PTHREAD_CANCEL_ENABLE 0 |
#define PTHREAD_CANCEL_DISABLE 1 |
#define PTHREAD_CANCEL_DEFERRED 0 |
#define PTHREAD_CANCEL_ASYNCHRONOUS 1 |
#define PTHREAD_CANCELED ((void *) -1) |
int _EXFUN(pthread_cancel, (pthread_t __pthread)); |
/* Setting Cancelability State, P1003.1c/Draft 10, p. 183 */ |
int _EXFUN(pthread_setcancelstate, (int __state, int *__oldstate)); |
int _EXFUN(pthread_setcanceltype, (int __type, int *__oldtype)); |
void _EXFUN(pthread_testcancel, (void)); |
/* Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184 */ |
void _EXFUN(pthread_cleanup_push, |
(void (*__routine)( void * ), void *__arg)); |
void _EXFUN(pthread_cleanup_pop, (int __execute)); |
#if defined(_POSIX_THREAD_CPUTIME) |
/* Accessing a Thread CPU-time Clock, P1003.4b/D8, p. 58 */ |
int _EXFUN(pthread_getcpuclockid, |
(pthread_t __pthread_id, clockid_t *__clock_id)); |
#endif /* defined(_POSIX_THREAD_CPUTIME) */ |
#endif /* defined(_POSIX_THREADS) */ |
#if defined(_POSIX_BARRIERS) |
int _EXFUN(pthread_barrierattr_init, (pthread_barrierattr_t *__attr)); |
int _EXFUN(pthread_barrierattr_destroy, (pthread_barrierattr_t *__attr)); |
int _EXFUN(pthread_barrierattr_getpshared, |
(_CONST pthread_barrierattr_t *__attr, int *__pshared)); |
int _EXFUN(pthread_barrierattr_setpshared, |
(pthread_barrierattr_t *__attr, int __pshared)); |
#define PTHREAD_BARRIER_SERIAL_THREAD -1 |
int _EXFUN(pthread_barrier_init, |
(pthread_barrier_t *__barrier, |
_CONST pthread_barrierattr_t *__attr, unsigned __count)); |
int _EXFUN(pthread_barrier_destroy, (pthread_barrier_t *__barrier)); |
int _EXFUN(pthread_barrier_wait,(pthread_barrier_t *__barrier)); |
#endif /* defined(_POSIX_BARRIERS) */ |
#if defined(_POSIX_SPIN_LOCKS) |
int _EXFUN(pthread_spin_init, |
(pthread_spinlock_t *__spinlock, int __pshared)); |
int _EXFUN(pthread_spin_destroy, (pthread_spinlock_t *__spinlock)); |
int _EXFUN(pthread_spin_lock, (pthread_spinlock_t *__spinlock)); |
int _EXFUN(pthread_spin_trylock, (pthread_spinlock_t *__spinlock)); |
int _EXFUN(pthread_spin_unlock, (pthread_spinlock_t *__spinlock)); |
#endif /* defined(_POSIX_SPIN_LOCKS) */ |
#if defined(_POSIX_READER_WRITER_LOCKS) |
int _EXFUN(pthread_rwlockattr_init, (pthread_rwlockattr_t *__attr)); |
int _EXFUN(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *__attr)); |
int _EXFUN(pthread_rwlockattr_getpshared, |
(_CONST pthread_rwlockattr_t *__attr, int *__pshared)); |
int _EXFUN(pthread_rwlockattr_setpshared, |
(pthread_rwlockattr_t *__attr, int __pshared)); |
int _EXFUN(pthread_rwlock_init, |
(pthread_rwlock_t *__rwlock, _CONST pthread_rwlockattr_t *__attr)); |
int _EXFUN(pthread_rwlock_destroy, (pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_rdlock,(pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_tryrdlock,(pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_timedrdlock, |
(pthread_rwlock_t *__rwlock, _CONST struct timespec *__abstime)); |
int _EXFUN(pthread_rwlock_unlock,(pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_wrlock,(pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_trywrlock,(pthread_rwlock_t *__rwlock)); |
int _EXFUN(pthread_rwlock_timedwrlock, |
(pthread_rwlock_t *__rwlock, _CONST struct timespec *__abstime)); |
#endif /* defined(_POSIX_READER_WRITER_LOCKS) */ |
#ifdef __cplusplus |
} |
#endif |
#endif |
/* end of include file */ |
/contrib/sdk/sources/libc/include/pwd.h |
---|
0,0 → 1,78 |
/*- |
* Copyright (c) 1989 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)pwd.h 5.13 (Berkeley) 5/28/91 |
*/ |
#ifndef _PWD_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _PWD_H_ |
#include <sys/types.h> |
#ifndef _POSIX_SOURCE |
#define _PATH_PASSWD "/etc/passwd" |
#define _PASSWORD_LEN 128 /* max length, not counting NULL */ |
#endif |
struct passwd { |
char *pw_name; /* user name */ |
char *pw_passwd; /* encrypted password */ |
uid_t pw_uid; /* user uid */ |
gid_t pw_gid; /* user gid */ |
char *pw_comment; /* comment */ |
char *pw_gecos; /* Honeywell login info */ |
char *pw_dir; /* home directory */ |
char *pw_shell; /* default shell */ |
}; |
#ifndef __INSIDE_CYGWIN__ |
struct passwd *getpwuid (uid_t); |
struct passwd *getpwnam (const char *); |
int getpwnam_r (const char *, struct passwd *, |
char *, size_t , struct passwd **); |
int getpwuid_r (uid_t, struct passwd *, char *, |
size_t, struct passwd **); |
#ifndef _POSIX_SOURCE |
struct passwd *getpwent (void); |
void setpwent (void); |
void endpwent (void); |
#endif |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* _PWD_H_ */ |
/contrib/sdk/sources/libc/include/reent.h |
---|
0,0 → 1,199 |
/* This header file provides the reentrancy. */ |
/* The reentrant system calls here serve two purposes: |
1) Provide reentrant versions of the system calls the ANSI C library |
requires. |
2) Provide these system calls in a namespace clean way. |
It is intended that *all* system calls that the ANSI C library needs |
be declared here. It documents them all in one place. All library access |
to the system is via some form of these functions. |
The target may provide the needed syscalls by any of the following: |
1) Define the reentrant versions of the syscalls directly. |
(eg: _open_r, _close_r, etc.). Please keep the namespace clean. |
When you do this, set "syscall_dir" to "syscalls" and add |
-DREENTRANT_SYSCALLS_PROVIDED to newlib_cflags in configure.host. |
2) Define namespace clean versions of the system calls by prefixing |
them with '_' (eg: _open, _close, etc.). Technically, there won't be |
true reentrancy at the syscall level, but the library will be namespace |
clean. |
When you do this, set "syscall_dir" to "syscalls" in configure.host. |
3) Define or otherwise provide the regular versions of the syscalls |
(eg: open, close, etc.). The library won't be reentrant nor namespace |
clean, but at least it will work. |
When you do this, add -DMISSING_SYSCALL_NAMES to newlib_cflags in |
configure.host. |
4) Define or otherwise provide the regular versions of the syscalls, |
and do not supply functional interfaces for any of the reentrant |
calls. With this method, the reentrant syscalls are redefined to |
directly call the regular system call without the reentrancy argument. |
When you do this, specify both -DREENTRANT_SYSCALLS_PROVIDED and |
-DMISSING_SYSCALL_NAMES via newlib_cflags in configure.host and do |
not specify "syscall_dir". |
Stubs of the reentrant versions of the syscalls exist in the libc/reent |
source directory and are provided if REENTRANT_SYSCALLS_PROVIDED isn't |
defined. These stubs call the native system calls: _open, _close, etc. |
if MISSING_SYSCALL_NAMES is *not* defined, otherwise they call the |
non-underscored versions: open, close, etc. when MISSING_SYSCALL_NAMES |
*is* defined. |
By default, newlib functions call the reentrant syscalls internally, |
passing a reentrancy structure as an argument. This reentrancy structure |
contains data that is thread-specific. For example, the errno value is |
kept in the reentrancy structure. If multiple threads exist, each will |
keep a separate errno value which is intuitive since the application flow |
cannot check for failure reliably otherwise. |
The reentrant syscalls are either provided by the platform, by the |
libc/reent stubs, or in the case of both MISSING_SYSCALL_NAMES and |
REENTRANT_SYSCALLS_PROVIDED being defined, the calls are redefined to |
simply call the regular syscalls with no reentrancy struct argument. |
A single-threaded application does not need to worry about the reentrancy |
structure. It is used internally. |
A multi-threaded application needs either to manually manage reentrancy |
structures or use dynamic reentrancy. |
Manually managing reentrancy structures entails calling special reentrant |
versions of newlib functions that have an additional reentrancy argument. |
For example, _printf_r. By convention, the first argument is the |
reentrancy structure. By default, the normal version of the function |
uses the default reentrancy structure: _REENT. The reentrancy structure |
is passed internally, eventually to the reentrant syscalls themselves. |
How the structures are stored and accessed in this model is up to the |
application. |
Dynamic reentrancy is specified by the __DYNAMIC_REENT__ flag. This |
flag denotes setting up a macro to replace _REENT with a function call |
to __getreent(). This function needs to be implemented by the platform |
and it is meant to return the reentrancy structure for the current |
thread. When the regular C functions (e.g. printf) go to call internal |
routines with the default _REENT structure, they end up calling with |
the reentrancy structure for the thread. Thus, application code does not |
need to call the _r routines nor worry about reentrancy structures. */ |
/* WARNING: All identifiers here must begin with an underscore. This file is |
included by stdio.h and others and we therefore must only use identifiers |
in the namespace allotted to us. */ |
#ifndef _REENT_H_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _REENT_H_ |
#include <sys/reent.h> |
#include <sys/_types.h> |
#include <machine/types.h> |
#define __need_size_t |
#define __need_ptrdiff_t |
#include <stddef.h> |
/* FIXME: not namespace clean */ |
struct stat; |
struct tms; |
struct timeval; |
struct timezone; |
typedef struct |
{ |
char *name; |
unsigned int offset; |
int (*write)(const char*, const void *, size_t, size_t, size_t*); |
}__file_handle; |
#if defined(REENTRANT_SYSCALLS_PROVIDED) && defined(MISSING_SYSCALL_NAMES) |
#define _close_r(__reent, __fd) close(__fd) |
#define _execve_r(__reent, __f, __arg, __env) execve(__f, __arg, __env) |
#define _fcntl_r(__reent, __fd, __cmd, __arg) fcntl(__fd, __cmd, __arg) |
#define _fork_r(__reent) fork() |
#define _fstat_r(__reent, __fdes, __stat) fstat(__fdes, __stat) |
#define _getpid_r(__reent) getpid() |
#define _isatty_r(__reent, __desc) isatty(__desc) |
#define _kill_r(__reent, __pid, __signal) kill(__pid, __signal) |
#define _link_r(__reent, __oldpath, __newpath) link(__oldpath, __newpath) |
#define _lseek_r(__reent, __fdes, __off, __w) lseek(__fdes, __off, __w) |
#define _mkdir_r(__reent, __path, __m) mkdir(__path, __m) |
#define _open_r(__reent, __path, __flag, __m) open(__path, __flag, __m) |
#define _read_r(__reent, __fd, __buff, __cnt) read(__fd, __buff, __cnt) |
#define _rename_r(__reent, __old, __new) rename(__old, __new) |
#define _sbrk_r(__reent, __incr) sbrk(__incr) |
#define _stat_r(__reent, __path, __buff) stat(__path, __buff) |
#define _times_r(__reent, __time) times(__time) |
#define _unlink_r(__reent, __path) unlink(__path) |
#define _wait_r(__reent, __status) wait(__status) |
#define _write_r(__reent, __fd, __buff, __cnt) write(__fd, __buff, __cnt) |
#define _gettimeofday_r(__reent, __tp, __tzp) gettimeofday(__tp, __tzp) |
#ifdef __LARGE64_FILES |
#define _lseek64_r(__reent, __fd, __off, __w) lseek64(__fd, __off, __w) |
#define _fstat64_r(__reent, __fd, __buff) fstat64(__fd, __buff) |
#define _open64_r(__reent, __path, __flag, __m) open64(__path, __flag, __m) |
#endif |
#else |
/* Reentrant versions of system calls. */ |
extern int _close_r _PARAMS ((struct _reent *, int)); |
extern int _execve_r _PARAMS ((struct _reent *, const char *, char *const *, char *const *)); |
extern int _fcntl_r _PARAMS ((struct _reent *, int, int, int)); |
extern int _fork_r _PARAMS ((struct _reent *)); |
extern int _fstat_r _PARAMS ((struct _reent *, int, struct stat *)); |
static inline int _getpid_r (struct _reent *r) |
{ |
int pid; |
(void)r; |
__asm__ __volatile__( |
"movl %%fs:0, %0 \n\t" |
:"=r"(pid)); |
return pid; |
} |
extern int _isatty_r _PARAMS ((struct _reent *, int)); |
extern int _kill_r _PARAMS ((struct _reent *, int, int)); |
extern int _link_r _PARAMS ((struct _reent *, const char *, const char *)); |
extern _off_t _lseek_r _PARAMS ((struct _reent *, int, _off_t, int)); |
extern int _mkdir_r _PARAMS ((struct _reent *, const char *, int)); |
extern int _open_r _PARAMS ((struct _reent *, const char *, int, int)); |
extern _ssize_t _read_r _PARAMS ((struct _reent *, int, void *, size_t)); |
extern int _rename_r _PARAMS ((struct _reent *, const char *, const char *)); |
extern void *_sbrk_r _PARAMS ((struct _reent *, ptrdiff_t)); |
extern int _stat_r _PARAMS ((struct _reent *, const char *, struct stat *)); |
extern _CLOCK_T_ _times_r _PARAMS ((struct _reent *, struct tms *)); |
extern int _unlink_r _PARAMS ((struct _reent *, const char *)); |
extern int _wait_r _PARAMS ((struct _reent *, int *)); |
extern _ssize_t _write_r _PARAMS ((struct _reent *, int, const void *, size_t)); |
/* This one is not guaranteed to be available on all targets. */ |
extern int _gettimeofday_r _PARAMS ((struct _reent *, struct timeval *__tp, void *__tzp)); |
#ifdef __LARGE64_FILES |
#if defined(__CYGWIN__) && defined(_COMPILING_NEWLIB) |
#define stat64 __stat64 |
#endif |
struct stat64; |
extern _off64_t _lseek64_r _PARAMS ((struct _reent *, int, _off64_t, int)); |
extern int _fstat64_r _PARAMS ((struct _reent *, int, struct stat64 *)); |
extern int _open64_r _PARAMS ((struct _reent *, const char *, int, int)); |
extern int _stat64_r _PARAMS ((struct _reent *, const char *, struct stat64 *)); |
#endif |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* _REENT_H_ */ |
/contrib/sdk/sources/libc/include/regdef.h |
---|
0,0 → 1,7 |
/* regdef.h -- define register names. */ |
/* This is a standard include file for MIPS targets. Other target |
probably don't define it, and attempts to include this file will |
fail. */ |
#include <machine/regdef.h> |
/contrib/sdk/sources/libc/include/regex.h |
---|
0,0 → 1,102 |
/*- |
* Copyright (c) 1992 Henry Spencer. |
* Copyright (c) 1992, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Henry Spencer of the University of Toronto. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* @(#)regex.h 8.2 (Berkeley) 1/3/94 |
* $FreeBSD: src/include/regex.h,v 1.4 2002/03/23 17:24:53 imp Exp $ |
*/ |
#ifndef _REGEX_H_ |
#define _REGEX_H_ |
#include <sys/cdefs.h> |
/* types */ |
typedef off_t regoff_t; |
typedef struct { |
int re_magic; |
size_t re_nsub; /* number of parenthesized subexpressions */ |
__const char *re_endp; /* end pointer for REG_PEND */ |
struct re_guts *re_g; /* none of your business :-) */ |
} regex_t; |
typedef struct { |
regoff_t rm_so; /* start of match */ |
regoff_t rm_eo; /* end of match */ |
} regmatch_t; |
/* regcomp() flags */ |
#define REG_BASIC 0000 |
#define REG_EXTENDED 0001 |
#define REG_ICASE 0002 |
#define REG_NOSUB 0004 |
#define REG_NEWLINE 0010 |
#define REG_NOSPEC 0020 |
#define REG_PEND 0040 |
#define REG_DUMP 0200 |
/* regerror() flags */ |
#define REG_NOMATCH 1 |
#define REG_BADPAT 2 |
#define REG_ECOLLATE 3 |
#define REG_ECTYPE 4 |
#define REG_EESCAPE 5 |
#define REG_ESUBREG 6 |
#define REG_EBRACK 7 |
#define REG_EPAREN 8 |
#define REG_EBRACE 9 |
#define REG_BADBR 10 |
#define REG_ERANGE 11 |
#define REG_ESPACE 12 |
#define REG_BADRPT 13 |
#define REG_EMPTY 14 |
#define REG_ASSERT 15 |
#define REG_INVARG 16 |
#define REG_ATOI 255 /* convert name to number (!) */ |
#define REG_ITOA 0400 /* convert number to name (!) */ |
/* regexec() flags */ |
#define REG_NOTBOL 00001 |
#define REG_NOTEOL 00002 |
#define REG_STARTEND 00004 |
#define REG_TRACE 00400 /* tracing of execution */ |
#define REG_LARGE 01000 /* force large representation */ |
#define REG_BACKR 02000 /* force use of backref code */ |
__BEGIN_DECLS |
int regcomp(regex_t *, const char *, int); |
size_t regerror(int, const regex_t *, char *, size_t); |
int regexec(const regex_t *, const char *, size_t, regmatch_t [], int); |
void regfree(regex_t *); |
__END_DECLS |
#endif /* !_REGEX_H_ */ |
/contrib/sdk/sources/libc/include/rpc/types.h |
---|
0,0 → 1,85 |
/* |
* Copyright (c) 2009, Sun Microsystems, Inc. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are met: |
* - Redistributions of source code must retain the above copyright notice, |
* this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright notice, |
* this list of conditions and the following disclaimer in the documentation |
* and/or other materials provided with the distribution. |
* - Neither the name of Sun Microsystems, Inc. nor the names of its |
* contributors may be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
* POSSIBILITY OF SUCH DAMAGE. |
* |
* from: @(#)types.h 1.18 87/07/24 SMI |
* from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC |
* $FreeBSD: src/include/rpc/types.h,v 1.10.6.1 2003/12/18 00:59:50 peter Exp $ |
* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $ |
*/ |
/* |
* Rpc additions to <sys/types.h> |
*/ |
#ifndef _RPC_TYPES_H |
#define _RPC_TYPES_H |
#include <stdint.h> |
#include <sys/types.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
#if defined(___int64_t_defined) |
typedef u_int64_t u_quad_t; |
typedef int64_t quad_t; |
#endif /* ___int64_t_defined */ |
typedef int32_t bool_t; |
typedef int32_t enum_t; |
typedef u_int32_t rpcprog_t; |
typedef u_int32_t rpcvers_t; |
typedef u_int32_t rpcproc_t; |
typedef u_int32_t rpcprot_t; |
typedef u_int32_t rpcport_t; |
typedef int32_t rpc_inline_t; |
#ifndef NULL |
# define NULL 0 |
#endif |
#define __dontcare__ -1 |
#ifndef FALSE |
# define FALSE 0 |
#endif |
#ifndef TRUE |
# define TRUE 1 |
#endif |
#ifndef mem_alloc |
#define mem_alloc(bsize) calloc(1, bsize) |
#endif |
#ifndef mem_free |
#define mem_free(ptr, bsize) free(ptr) |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* !_RPC_TYPES_H */ |
/contrib/sdk/sources/libc/include/rpc/xdr.h |
---|
0,0 → 1,389 |
/* |
* Copyright (c) 2009, Sun Microsystems, Inc. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are met: |
* - Redistributions of source code must retain the above copyright notice, |
* this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright notice, |
* this list of conditions and the following disclaimer in the documentation |
* and/or other materials provided with the distribution. |
* - Neither the name of Sun Microsystems, Inc. nor the names of its |
* contributors may be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
* POSSIBILITY OF SUCH DAMAGE. |
* |
* from: @(#)xdr.h 1.19 87/04/22 SMI |
* from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC |
* $FreeBSD: src/include/rpc/xdr.h,v 1.23 2003/03/07 13:19:40 nectar Exp $ |
* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $ |
*/ |
/* |
* xdr.h, External Data Representation Serialization Routines. |
* |
* Copyright (C) 1984, Sun Microsystems, Inc. |
*/ |
#ifndef _RPC_XDR_H |
#define _RPC_XDR_H |
#include <_ansi.h> |
#include <rpc/types.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* |
* XDR provides a conventional way for converting between C data |
* types and an external bit-string representation. Library supplied |
* routines provide for the conversion on built-in C data types. These |
* routines and utility routines defined here are used to help implement |
* a type encode/decode routine for each user-defined type. |
* |
* Each data type provides a single procedure which takes two arguments: |
* |
* bool_t |
* xdrproc(XDR *xdrs, <type> *argresp) |
* |
* xdrs is an instance of a XDR handle, to which or from which the data |
* type is to be converted. argresp is a pointer to the structure to be |
* converted. The XDR handle contains an operation field which indicates |
* which of the operations (ENCODE, DECODE * or FREE) is to be performed. |
* |
* XDR_DECODE may allocate space if the pointer argresp is null. This |
* data can be freed with the XDR_FREE operation. |
* |
* We write only one procedure per data type to make it easy |
* to keep the encode and decode procedures for a data type consistent. |
* In many cases the same code performs all operations on a user defined type, |
* because all the hard work is done in the component type routines. |
* decode as a series of calls on the nested data types. |
*/ |
/* |
* Xdr operations. XDR_ENCODE causes the type to be encoded into the |
* stream. XDR_DECODE causes the type to be extracted from the stream. |
* XDR_FREE can be used to release the space allocated by an XDR_DECODE |
* request. |
*/ |
enum xdr_op |
{ |
XDR_ENCODE = 0, |
XDR_DECODE = 1, |
XDR_FREE = 2 |
}; |
/* |
* This is the number of bytes per unit of external data. |
*/ |
#define BYTES_PER_XDR_UNIT (4) |
#if 1 |
/* faster version when BYTES_PER_XDR_UNIT is a power of two */ |
# define RNDUP(x) (((x) + BYTES_PER_XDR_UNIT - 1) & ~(BYTES_PER_XDR_UNIT - 1)) |
#else /* old version */ |
#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ |
* BYTES_PER_XDR_UNIT) |
#endif |
/* |
* The XDR handle. |
* Contains operation which is being applied to the stream, |
* an operations vector for the particular implementation (e.g. see xdr_mem.c), |
* and two private fields for the use of the particular implementation. |
*/ |
typedef struct __rpc_xdr |
{ |
enum xdr_op x_op; /* operation; fast additional param */ |
_CONST struct xdr_ops |
{ |
/* get a long from underlying stream */ |
bool_t _EXFNPTR (x_getlong, (struct __rpc_xdr *, long *)); |
/* put a long to " */ |
bool_t _EXFNPTR (x_putlong, (struct __rpc_xdr *, _CONST long *)); |
/* get some bytes from " */ |
bool_t _EXFNPTR (x_getbytes, (struct __rpc_xdr *, char *, u_int)); |
/* put some bytes to " */ |
bool_t _EXFNPTR (x_putbytes, (struct __rpc_xdr *, _CONST char *, u_int)); |
/* returns bytes off from beginning */ |
u_int _EXFNPTR (x_getpostn, (struct __rpc_xdr *)); |
/* lets you reposition the stream */ |
bool_t _EXFNPTR (x_setpostn, (struct __rpc_xdr *, u_int)); |
/* buf quick ptr to buffered data */ |
int32_t * _EXFNPTR (x_inline, (struct __rpc_xdr *, u_int)); |
/* free privates of this xdr_stream */ |
void _EXFNPTR (x_destroy, (struct __rpc_xdr *)); |
/* get an int32 from this xdr_stream */ |
bool_t _EXFNPTR (x_getint32, (struct __rpc_xdr *, int32_t *)); |
/* put an int32 to the underlying stream */ |
bool_t _EXFNPTR (x_putint32, (struct __rpc_xdr *, _CONST int32_t *)); |
} *x_ops; |
char *x_public; /* users' data */ |
void *x_private; /* pointer to private data */ |
char *x_base; /* private used for position info */ |
u_int x_handy; /* extra private word */ |
} XDR; |
/* |
* A xdrproc_t exists for each data type which is to be encoded or decoded. |
* |
* The second argument to the xdrproc_t is a pointer to an opaque pointer. |
* The opaque pointer generally points to a structure of the data type |
* to be decoded. If this pointer is 0, then the type routines should |
* allocate dynamic storage of the appropriate size and return it. |
* bool_t (*xdrproc_t)(XDR *, some_type *) |
*/ |
typedef bool_t _EXFNPTR(xdrproc_t, (XDR *, ...)); |
/* |
* Operations defined on a XDR handle |
* |
* XDR *xdrs; |
* long *longp; |
* char *addr; |
* u_int len; |
* u_int pos; |
*/ |
#define XDR_GETINT32(xdrs, int32p) \ |
(*(xdrs)->x_ops->x_getint32)(xdrs, int32p) |
#define xdr_getint32(xdrs, int32p) \ |
(*(xdrs)->x_ops->x_getint32)(xdrs, int32p) |
#define XDR_PUTINT32(xdrs, int32p) \ |
(*(xdrs)->x_ops->x_putint32)(xdrs, int32p) |
#define xdr_putint32(xdrs, int32p) \ |
(*(xdrs)->x_ops->x_putint32)(xdrs, int32p) |
#define XDR_GETLONG(xdrs, longp) \ |
(*(xdrs)->x_ops->x_getlong)(xdrs, longp) |
#define xdr_getlong(xdrs, longp) \ |
(*(xdrs)->x_ops->x_getlong)(xdrs, longp) |
#define XDR_PUTLONG(xdrs, longp) \ |
(*(xdrs)->x_ops->x_putlong)(xdrs, longp) |
#define xdr_putlong(xdrs, longp) \ |
(*(xdrs)->x_ops->x_putlong)(xdrs, longp) |
#define XDR_GETBYTES(xdrs, addr, len) \ |
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) |
#define xdr_getbytes(xdrs, addr, len) \ |
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) |
#define XDR_PUTBYTES(xdrs, addr, len) \ |
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) |
#define xdr_putbytes(xdrs, addr, len) \ |
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) |
#define XDR_GETPOS(xdrs) \ |
(*(xdrs)->x_ops->x_getpostn)(xdrs) |
#define xdr_getpos(xdrs) \ |
(*(xdrs)->x_ops->x_getpostn)(xdrs) |
#define XDR_SETPOS(xdrs, pos) \ |
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos) |
#define xdr_setpos(xdrs, pos) \ |
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos) |
#define XDR_INLINE(xdrs, len) \ |
(*(xdrs)->x_ops->x_inline)(xdrs, len) |
#define xdr_inline(xdrs, len) \ |
(*(xdrs)->x_ops->x_inline)(xdrs, len) |
#define XDR_DESTROY(xdrs) \ |
do { \ |
if ((xdrs)->x_ops->x_destroy) \ |
(*(xdrs)->x_ops->x_destroy)(xdrs); \ |
} while (0) |
#define xdr_destroy(xdrs) \ |
do { \ |
if ((xdrs)->x_ops->x_destroy) \ |
(*(xdrs)->x_ops->x_destroy)(xdrs); \ |
} while (0) |
/* |
* Solaris strips the '_t' from these types -- not sure why. |
* But, let's be compatible. |
*/ |
#define xdr_rpcvers(xdrs, versp) xdr_u_int32(xdrs, versp) |
#define xdr_rpcprog(xdrs, progp) xdr_u_int32(xdrs, progp) |
#define xdr_rpcproc(xdrs, procp) xdr_u_int32(xdrs, procp) |
#define xdr_rpcprot(xdrs, protp) xdr_u_int32(xdrs, protp) |
#define xdr_rpcport(xdrs, portp) xdr_u_int32(xdrs, portp) |
/* |
* Support struct for discriminated unions. |
* You create an array of xdrdiscrim structures, terminated with |
* an entry with a null procedure pointer. The xdr_union routine gets |
* the discriminant value and then searches the array of structures |
* for a matching value. If a match is found the associated xdr routine |
* is called to handle that part of the union. If there is |
* no match, then a default routine may be called. |
* If there is no match and no default routine it is an error. |
*/ |
#define NULL_xdrproc_t ((xdrproc_t)0) |
struct xdr_discrim |
{ |
int value; |
xdrproc_t proc; |
}; |
/* |
* In-line routines for fast encode/decode of primitive data types. |
* Caveat emptor: these use single memory cycles to get the |
* data from the underlying buffer, and will fail to operate |
* properly if the data is not aligned. The standard way to use these |
* is to say: |
* if ((buf = XDR_INLINE(xdrs, count)) == NULL) |
* return (FALSE); |
* <<< macro calls >>> |
* where ``count'' is the number of bytes of data occupied |
* by the primitive data types. |
* |
* N.B. and frozen for all time: each data type here uses 4 bytes |
* of external representation. |
*/ |
#define IXDR_GET_INT32(buf) ((int32_t)ntohl((u_int32_t)*(buf)++)) |
#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) |
#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) |
#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) |
/* Warning: inline long routines are broken for 64 bit platforms. |
* Because the other inline routines below are implemented in terms |
* of them, they are all also broken for 64 bit platforms. |
*/ |
#define IXDR_GET_LONG(buf) ((long)ntohl((u_int32_t)*(buf)++)) |
#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) |
#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) |
#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), (v)) |
#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) |
#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) |
#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) |
#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) |
#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), (v)) |
#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), (v)) |
#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) |
#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) |
/* |
* These are the "generic" xdr routines. |
*/ |
extern bool_t _EXFUN (xdr_void, (void)); |
extern bool_t _EXFUN (xdr_short, (XDR *, short *)); |
extern bool_t _EXFUN (xdr_u_short, (XDR *, u_short *)); |
extern bool_t _EXFUN (xdr_int, (XDR *, int *)); |
extern bool_t _EXFUN (xdr_u_int, (XDR *, u_int *)); |
extern bool_t _EXFUN (xdr_long, (XDR *, long *)); |
extern bool_t _EXFUN (xdr_u_long, (XDR *, u_long *)); |
extern bool_t _EXFUN (xdr_int8_t, (XDR *, int8_t *)); |
extern bool_t _EXFUN (xdr_uint8_t, (XDR *, uint8_t *)); |
extern bool_t _EXFUN (xdr_u_int8_t, (XDR *, u_int8_t *)); |
extern bool_t _EXFUN (xdr_int16_t, (XDR *, int16_t *)); |
extern bool_t _EXFUN (xdr_uint16_t, (XDR *, uint16_t *)); |
extern bool_t _EXFUN (xdr_u_int16_t, (XDR *, u_int16_t *)); |
extern bool_t _EXFUN (xdr_int32_t, (XDR *, int32_t *)); |
extern bool_t _EXFUN (xdr_uint32_t, (XDR *, uint32_t *)); |
extern bool_t _EXFUN (xdr_u_int32_t, (XDR *, u_int32_t *)); |
#if defined(___int64_t_defined) |
extern bool_t _EXFUN (xdr_int64_t, (XDR *, int64_t *)); |
extern bool_t _EXFUN (xdr_uint64_t, (XDR *, uint64_t *)); |
extern bool_t _EXFUN (xdr_u_int64_t, (XDR *, u_int64_t *)); |
#endif /* ___int64_t_defined */ |
extern bool_t _EXFUN (xdr_bool, (XDR *, bool_t *)); |
extern bool_t _EXFUN (xdr_enum, (XDR *, enum_t *)); |
extern bool_t _EXFUN (xdr_array, (XDR *, char **, u_int *, u_int, u_int, xdrproc_t)); |
extern bool_t _EXFUN (xdr_bytes, (XDR *, char **, u_int *, u_int)); |
extern bool_t _EXFUN (xdr_opaque, (XDR *, char *, u_int)); |
extern bool_t _EXFUN (xdr_string, (XDR *, char **, u_int)); |
extern bool_t _EXFUN (xdr_union, (XDR *, enum_t *, char *, |
_CONST struct xdr_discrim *, xdrproc_t)); |
extern bool_t _EXFUN (xdr_char, (XDR *, char *)); |
extern bool_t _EXFUN (xdr_u_char, (XDR *, u_char *)); |
extern bool_t _EXFUN (xdr_vector, (XDR *, char *, u_int, u_int, xdrproc_t)); |
extern bool_t _EXFUN (xdr_float, (XDR *, float *)); |
extern bool_t _EXFUN (xdr_double, (XDR *, double *)); |
/* extern bool_t _EXFUN (xdr_quadruple, (XDR *, long double *)); */ |
extern bool_t _EXFUN (xdr_reference, (XDR *, char **, u_int, xdrproc_t)); |
extern bool_t _EXFUN (xdr_pointer, (XDR *, char **, u_int, xdrproc_t)); |
extern bool_t _EXFUN (xdr_wrapstring, (XDR *, char **)); |
#if defined(___int64_t_defined) |
extern bool_t _EXFUN (xdr_hyper, (XDR *, quad_t *)); |
extern bool_t _EXFUN (xdr_u_hyper, (XDR *, u_quad_t *)); |
extern bool_t _EXFUN (xdr_longlong_t, (XDR *, quad_t *)); |
extern bool_t _EXFUN (xdr_u_longlong_t, (XDR *, u_quad_t *)); |
#endif /* ___int64_t_defined */ |
extern u_long _EXFUN (xdr_sizeof, (xdrproc_t, void *)); |
/* |
* Common opaque bytes objects used by many rpc protocols; |
* declared here due to commonality. |
*/ |
#define MAX_NETOBJ_SZ 1024 |
struct netobj |
{ |
u_int n_len; |
char *n_bytes; |
}; |
typedef struct netobj netobj; |
extern bool_t _EXFUN (xdr_netobj, (XDR *, struct netobj *)); |
/* |
* These are the public routines for the various implementations of |
* xdr streams. |
*/ |
/* XDR using memory buffers */ |
extern void _EXFUN (xdrmem_create, (XDR *, char *, u_int, enum xdr_op)); |
/* XDR using stdio library */ |
#if defined(_STDIO_H_) |
extern void _EXFUN (xdrstdio_create, (XDR *, FILE *, enum xdr_op)); |
#endif |
/* XDR pseudo records for tcp */ |
extern void _EXFUN (xdrrec_create, (XDR *, u_int, u_int, void *, |
int _EXPARM (, (void *, void *, int)), |
int _EXPARM (, (void *, void *, int)))); |
/* make end of xdr record */ |
extern bool_t _EXFUN (xdrrec_endofrecord, (XDR *, bool_t)); |
/* move to beginning of next record */ |
extern bool_t _EXFUN (xdrrec_skiprecord, (XDR *)); |
/* true if no more input */ |
extern bool_t _EXFUN (xdrrec_eof, (XDR *)); |
extern u_int _EXFUN (xdrrec_readbytes, (XDR *, caddr_t, u_int)); |
/* free memory buffers for xdr */ |
extern void _EXFUN (xdr_free, (xdrproc_t, void *)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* !_RPC_XDR_H */ |
/contrib/sdk/sources/libc/include/sched.h |
---|
0,0 → 1,97 |
/* |
* Written by Joel Sherrill <joel@OARcorp.com>. |
* |
* COPYRIGHT (c) 1989-2010. |
* On-Line Applications Research Corporation (OAR). |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION |
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS |
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
* $Id: sched.h,v 1.2 2010/04/01 18:33:33 jjohnstn Exp $ |
*/ |
#ifndef _SCHED_H_ |
#define _SCHED_H_ |
#include <sys/types.h> |
#include <sys/sched.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
#if defined(_POSIX_PRIORITY_SCHEDULING) |
/* |
* XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1803 |
*/ |
int sched_setparam( |
pid_t __pid, |
const struct sched_param *__param |
); |
/* |
* XBD 13 - Set Scheduling Parameters, P1003.1b-2008, p. 1800 |
*/ |
int sched_getparam( |
pid_t __pid, |
struct sched_param *__param |
); |
/* |
* XBD 13 - Set Scheduling Policy and Scheduling Parameters, |
* P1003.1b-2008, p. 1805 |
*/ |
int sched_setscheduler( |
pid_t __pid, |
int __policy, |
const struct sched_param *__param |
); |
/* |
* XBD 13 - Get Scheduling Policy, P1003.1b-2008, p. 1801 |
*/ |
int sched_getscheduler( |
pid_t __pid |
); |
/* |
* XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1799 |
*/ |
int sched_get_priority_max( |
int __policy |
); |
int sched_get_priority_min( |
int __policy |
); |
/* |
* XBD 13 - Get Scheduling Parameter Limits, P1003.1b-2008, p. 1802 |
*/ |
int sched_rr_get_interval( |
pid_t __pid, |
struct timespec *__interval |
); |
#endif /* _POSIX_PRIORITY_SCHEDULING */ |
#if defined(_POSIX_THREADS) || defined(_POSIX_PRIORITY_SCHEDULING) |
/* |
* XBD 13 - Yield Processor, P1003.1b-2008, p. 1807 |
*/ |
int sched_yield( void ); |
#endif /* _POSIX_THREADS or _POSIX_PRIORITY_SCHEDULING */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* _SCHED_H_ */ |
/contrib/sdk/sources/libc/include/search.h |
---|
0,0 → 1,59 |
/* $NetBSD: search.h,v 1.12 1999/02/22 10:34:28 christos Exp $ */ |
/* $FreeBSD: src/include/search.h,v 1.4 2002/03/23 17:24:53 imp Exp $ */ |
/* |
* Written by J.T. Conklin <jtc@netbsd.org> |
* Public domain. |
*/ |
#ifndef _SEARCH_H_ |
#define _SEARCH_H_ |
#include <sys/cdefs.h> |
#include <machine/ansi.h> |
#include <sys/types.h> |
typedef struct entry { |
char *key; |
void *data; |
} ENTRY; |
typedef enum { |
FIND, ENTER |
} ACTION; |
typedef enum { |
preorder, |
postorder, |
endorder, |
leaf |
} VISIT; |
#ifdef _SEARCH_PRIVATE |
typedef struct node { |
char *key; |
struct node *llink, *rlink; |
} node_t; |
#endif |
struct hsearch_data |
{ |
struct internal_head *htable; |
size_t htablesize; |
}; |
__BEGIN_DECLS |
int hcreate(size_t); |
void hdestroy(void); |
ENTRY *hsearch(ENTRY, ACTION); |
int hcreate_r(size_t, struct hsearch_data *); |
void hdestroy_r(struct hsearch_data *); |
int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); |
void *tdelete(const void *, void **, int (*)(const void *, const void *)); |
void tdestroy (void *, void (*)(void *)); |
void *tfind(const void *, void **, int (*)(const void *, const void *)); |
void *tsearch(const void *, void **, int (*)(const void *, const void *)); |
void twalk(const void *, void (*)(const void *, VISIT, int)); |
__END_DECLS |
#endif /* !_SEARCH_H_ */ |
/contrib/sdk/sources/libc/include/setjmp.h |
---|
0,0 → 1,20 |
/* |
setjmp.h |
stubs for future use. |
*/ |
#ifndef _SETJMP_H_ |
#define _SETJMP_H_ |
#include "_ansi.h" |
#include <machine/setjmp.h> |
_BEGIN_STD_C |
void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval)); |
int _EXFUN(setjmp,(jmp_buf __jmpb)); |
_END_STD_C |
#endif /* _SETJMP_H_ */ |
/contrib/sdk/sources/libc/include/signal.h |
---|
0,0 → 1,32 |
#ifndef _SIGNAL_H_ |
#define _SIGNAL_H_ |
#include "_ansi.h" |
#include <sys/signal.h> |
_BEGIN_STD_C |
typedef int sig_atomic_t; /* Atomic entity type (ANSI) */ |
#ifndef _POSIX_SOURCE |
typedef _sig_func_ptr sig_t; /* BSD naming */ |
typedef _sig_func_ptr sighandler_t; /* glibc naming */ |
#endif /* !_POSIX_SOURCE */ |
#define SIG_DFL ((_sig_func_ptr)0) /* Default action */ |
#define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */ |
#define SIG_ERR ((_sig_func_ptr)-1) /* Error return */ |
struct _reent; |
_sig_func_ptr _EXFUN(_signal_r, (struct _reent *, int, _sig_func_ptr)); |
int _EXFUN(_raise_r, (struct _reent *, int)); |
#ifndef _REENT_ONLY |
_sig_func_ptr _EXFUN(signal, (int, _sig_func_ptr)); |
int _EXFUN(raise, (int)); |
void _EXFUN(psignal, (int, const char *)); |
#endif |
_END_STD_C |
#endif /* _SIGNAL_H_ */ |
/contrib/sdk/sources/libc/include/sound.h |
---|
0,0 → 1,143 |
#ifndef _SOUND_H_ |
#define _SOUND_H_ |
#ifdef __cplusplus |
extern "C" |
{ |
#endif |
#define SOUND_VERSION 0x0101 |
#define PCM_ALL 0 |
#define PCM_OUT 0x08000000 |
#define PCM_RING 0x10000000 |
#define PCM_STATIC 0x20000000 |
#define PCM_FLOAT 0x40000000 |
#define PCM_FILTER 0x80000000 |
#define PCM_2_16_48 1 |
#define PCM_1_16_48 2 |
#define PCM_2_16_44 3 |
#define PCM_1_16_44 4 |
#define PCM_2_16_32 5 |
#define PCM_1_16_32 6 |
#define PCM_2_16_24 7 |
#define PCM_1_16_24 8 |
#define PCM_2_16_22 9 |
#define PCM_1_16_22 10 |
#define PCM_2_16_16 11 |
#define PCM_1_16_16 12 |
#define PCM_2_16_12 13 |
#define PCM_1_16_12 14 |
#define PCM_2_16_11 15 |
#define PCM_1_16_11 16 |
#define PCM_2_16_8 17 |
#define PCM_1_16_8 18 |
#define PCM_2_8_48 19 |
#define PCM_1_8_48 20 |
#define PCM_2_8_44 21 |
#define PCM_1_8_44 22 |
#define PCM_2_8_32 23 |
#define PCM_1_8_32 24 |
#define PCM_2_8_24 25 |
#define PCM_1_8_24 26 |
#define PCM_2_8_22 27 |
#define PCM_1_8_22 28 |
#define PCM_2_8_16 29 |
#define PCM_1_8_16 30 |
#define PCM_2_8_12 31 |
#define PCM_1_8_12 32 |
#define PCM_2_8_11 33 |
#define PCM_1_8_11 34 |
#define PCM_2_8_8 35 |
#define PCM_1_8_8 36 |
#define SRV_GETVERSION 0 |
#define SND_CREATE_BUFF 1 |
#define SND_DESTROY_BUFF 2 |
#define SND_SETFORMAT 3 |
#define SND_GETFORMAT 4 |
#define SND_RESET 5 |
#define SND_SETPOS 6 |
#define SND_GETPOS 7 |
#define SND_SETBUFF 8 |
#define SND_OUT 9 |
#define SND_PLAY 10 |
#define SND_STOP 11 |
#define SND_SETVOLUME 12 |
#define SND_GETVOLUME 13 |
#define SND_SETPAN 14 |
#define SND_GETPAN 15 |
#define SND_GETBUFFSIZE 16 |
#define SND_GETFREESPACE 17 |
#define SND_SETTIMEBASE 18 |
#define SND_GETTIMESTAMP 19 |
#define SND_RESET_ALL 3 |
#define PLAY_SYNC 0x80000000 |
typedef unsigned int SNDBUF; |
int _stdcall InitSound(int *version); |
int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf); |
int _stdcall DestroyBuffer(SNDBUF hBuff); |
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format); |
int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format); |
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags); |
int _stdcall SetBufferPos(SNDBUF hBuff, int offset); |
int _stdcall GetBufferPos(SNDBUF hBuff, int *offset); |
int _stdcall GetBufferSize(SNDBUF hBuff, int *size); |
int _stdcall GetBufferFree(SNDBUF hBuff, int *free); |
int _stdcall SetBuffer(SNDBUF hBuff,void* buff, |
int offs, int size); |
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size); |
int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags); |
int _stdcall StopBuffer(SNDBUF hBuff); |
int _stdcall SetVolume(SNDBUF hBuff, int left, int right); |
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right); |
int _stdcall SetPan(SNDBUF hBuff, int pan); |
int _stdcall GetPan(SNDBUF hBuff, int *pan); |
int _stdcall GetMasterVol(int* vol); |
int _stdcall SetMasterVol(int vol); |
int _stdcall SetTimeBase(SNDBUF hBuff, double base); |
int _stdcall GetTimeStamp(SNDBUF hBuff, double *stamp); |
int _stdcall GetDevTime(int *stamp); |
typedef struct |
{ |
unsigned int riff_id; |
unsigned int riff_size; |
unsigned int riff_format; |
unsigned int fmt_id; |
unsigned int fmt_size; |
unsigned short int wFormatTag; |
unsigned short int nChannels; |
unsigned int nSamplesPerSec; |
unsigned int nAvgBytesPerSec; |
unsigned short int nBlockAlign; |
unsigned short int wBitsPerSample; |
unsigned int data_id; |
unsigned int data_size; |
} WAVEHEADER; |
unsigned int _stdcall test_wav(WAVEHEADER *hdr); |
#ifdef __cplusplus |
extern "C" |
} |
#endif |
#endif //_SOUND_H_ |
/contrib/sdk/sources/libc/include/stdint.h |
---|
0,0 → 1,497 |
/* |
* Copyright (c) 2004, 2005 by |
* Ralf Corsepius, Ulm/Germany. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#ifndef _STDINT_H |
#define _STDINT_H |
#ifdef __cplusplus |
extern "C" { |
#endif |
#if defined(__GNUC__) && \ |
( (__GNUC__ >= 4) || \ |
( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2) ) ) |
/* gcc > 3.2 implicitly defines the values we are interested */ |
#define __STDINT_EXP(x) __##x##__ |
#else |
#define __STDINT_EXP(x) x |
#include <limits.h> |
#endif |
/* Check if "long long" is 64bit wide */ |
/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */ |
#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \ |
|| ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) ) |
#define __have_longlong64 1 |
#endif |
/* Check if "long" is 64bit or 32bit wide */ |
#if __STDINT_EXP(LONG_MAX) > 0x7fffffff |
#define __have_long64 1 |
#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__) |
#define __have_long32 1 |
#define __have_long64 0 |
#endif |
#if __STDINT_EXP(SCHAR_MAX) == 0x7f |
typedef signed char int8_t ; |
typedef unsigned char uint8_t ; |
#define __int8_t_defined 1 |
#endif |
#if __int8_t_defined |
typedef signed char int_least8_t; |
typedef unsigned char uint_least8_t; |
#define __int_least8_t_defined 1 |
#endif |
#if __STDINT_EXP(SHRT_MAX) == 0x7fff |
typedef signed short int16_t; |
typedef unsigned short uint16_t; |
#define __int16_t_defined 1 |
#elif __STDINT_EXP(INT_MAX) == 0x7fff |
typedef signed int int16_t; |
typedef unsigned int uint16_t; |
#define __int16_t_defined 1 |
#elif __STDINT_EXP(SCHAR_MAX) == 0x7fff |
typedef signed char int16_t; |
typedef unsigned char uint16_t; |
#define __int16_t_defined 1 |
#endif |
#if __int16_t_defined |
typedef int16_t int_least16_t; |
typedef uint16_t uint_least16_t; |
#define __int_least16_t_defined 1 |
#if !__int_least8_t_defined |
typedef int16_t int_least8_t; |
typedef uint16_t uint_least8_t; |
#define __int_least8_t_defined 1 |
#endif |
#endif |
//#if __have_long32 |
//typedef signed long int32_t; |
//typedef unsigned long uint32_t; |
//#define __int32_t_defined 1 |
//#elif __STDINT_EXP(INT_MAX) == 0x7fffffffL |
typedef signed int int32_t; |
typedef unsigned int uint32_t; |
#define __int32_t_defined 1 |
//#elif __STDINT_EXP(SHRT_MAX) == 0x7fffffffL |
//typedef signed short int32_t; |
//typedef unsigned short uint32_t; |
//#define __int32_t_defined 1 |
//#elif __STDINT_EXP(SCHAR_MAX) == 0x7fffffffL |
//typedef signed char int32_t; |
//typedef unsigned char uint32_t; |
//#define __int32_t_defined 1 |
//#endif |
#if __int32_t_defined |
typedef int32_t int_least32_t; |
typedef uint32_t uint_least32_t; |
#define __int_least32_t_defined 1 |
#if !__int_least8_t_defined |
typedef int32_t int_least8_t; |
typedef uint32_t uint_least8_t; |
#define __int_least8_t_defined 1 |
#endif |
#if !__int_least16_t_defined |
typedef int32_t int_least16_t; |
typedef uint32_t uint_least16_t; |
#define __int_least16_t_defined 1 |
#endif |
#endif |
#if __have_long64 |
typedef signed long int64_t; |
typedef unsigned long uint64_t; |
#define __int64_t_defined 1 |
#elif __have_longlong64 |
typedef signed long long int64_t; |
typedef unsigned long long uint64_t; |
#define __int64_t_defined 1 |
#elif __STDINT_EXP(INT_MAX) > 0x7fffffff |
typedef signed int int64_t; |
typedef unsigned int uint64_t; |
#define __int64_t_defined 1 |
#endif |
#if __int64_t_defined |
typedef int64_t int_least64_t; |
typedef uint64_t uint_least64_t; |
#define __int_least64_t_defined 1 |
#if !__int_least8_t_defined |
typedef int64_t int_least8_t; |
typedef uint64_t uint_least8_t; |
#define __int_least8_t_defined 1 |
#endif |
#if !__int_least16_t_defined |
typedef int64_t int_least16_t; |
typedef uint64_t uint_least16_t; |
#define __int_least16_t_defined 1 |
#endif |
#if !__int_least32_t_defined |
typedef int64_t int_least32_t; |
typedef uint64_t uint_least32_t; |
#define __int_least32_t_defined 1 |
#endif |
#endif |
/* |
* Fastest minimum-width integer types |
* |
* Assume int to be the fastest type for all types with a width |
* less than __INT_MAX__ rsp. INT_MAX |
*/ |
#if __STDINT_EXP(INT_MAX) >= 0x7f |
typedef signed int int_fast8_t; |
typedef unsigned int uint_fast8_t; |
#define __int_fast8_t_defined 1 |
#endif |
#if __STDINT_EXP(INT_MAX) >= 0x7fff |
typedef signed int int_fast16_t; |
typedef unsigned int uint_fast16_t; |
#define __int_fast16_t_defined 1 |
#endif |
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff |
typedef signed int int_fast32_t; |
typedef unsigned int uint_fast32_t; |
#define __int_fast32_t_defined 1 |
#endif |
#if __STDINT_EXP(INT_MAX) > 0x7fffffff |
typedef signed int int_fast64_t; |
typedef unsigned int uint_fast64_t; |
#define __int_fast64_t_defined 1 |
#else |
#define __int_fast64_t_defined 0 |
#endif |
/* |
* Fall back to [u]int_least<N>_t for [u]int_fast<N>_t types |
* not having been defined, yet. |
* Leave undefined, if [u]int_least<N>_t should not be available. |
*/ |
#if !__int_fast8_t_defined |
#if __int_least8_t_defined |
typedef int_least8_t int_fast8_t; |
typedef uint_least8_t uint_fast8_t; |
#define __int_fast8_t_defined 1 |
#endif |
#endif |
#if !__int_fast16_t_defined |
#if __int_least16_t_defined |
typedef int_least16_t int_fast16_t; |
typedef uint_least16_t uint_fast16_t; |
#define __int_fast16_t_defined 1 |
#endif |
#endif |
#if !__int_fast32_t_defined |
#if __int_least32_t_defined |
typedef int_least32_t int_fast32_t; |
typedef uint_least32_t uint_fast32_t; |
#define __int_fast32_t_defined 1 |
#endif |
#endif |
#if !__int_fast64_t_defined |
#if __int_least64_t_defined |
typedef int_least64_t int_fast64_t; |
typedef uint_least64_t uint_fast64_t; |
#undef __int_fast64_t_defined |
#define __int_fast64_t_defined 1 |
#endif |
#endif |
/* Greatest-width integer types */ |
/* Modern GCCs provide __INTMAX_TYPE__ */ |
#if defined(__INTMAX_TYPE__) |
typedef __INTMAX_TYPE__ intmax_t; |
#elif __have_longlong64 |
typedef signed long long intmax_t; |
#else |
typedef signed long intmax_t; |
#endif |
/* Modern GCCs provide __UINTMAX_TYPE__ */ |
#if defined(__UINTMAX_TYPE__) |
typedef __UINTMAX_TYPE__ uintmax_t; |
#elif __have_longlong64 |
typedef unsigned long long uintmax_t; |
#else |
typedef unsigned long uintmax_t; |
#endif |
/* |
* GCC doesn't provide an appropriate macro for [u]intptr_t |
* For now, use __PTRDIFF_TYPE__ |
*/ |
#if defined(__PTRDIFF_TYPE__) |
typedef signed __PTRDIFF_TYPE__ intptr_t; |
typedef unsigned __PTRDIFF_TYPE__ uintptr_t; |
#define INTPTR_MAX PTRDIFF_MAX |
#define INTPTR_MIN PTRDIFF_MIN |
#ifdef __UINTPTR_MAX__ |
#define UINTPTR_MAX __UINTPTR_MAX__ |
#else |
#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1) |
#endif |
#else |
/* |
* Fallback to hardcoded values, |
* should be valid on cpu's with 32bit int/32bit void* |
*/ |
typedef signed long intptr_t; |
typedef unsigned long uintptr_t; |
#define INTPTR_MAX __STDINT_EXP(LONG_MAX) |
#define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1) |
#define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1) |
#endif |
/* Limits of Specified-Width Integer Types */ |
#if __int8_t_defined |
#define INT8_MIN -128 |
#define INT8_MAX 127 |
#define UINT8_MAX 255 |
#endif |
#if __int_least8_t_defined |
#define INT_LEAST8_MIN -128 |
#define INT_LEAST8_MAX 127 |
#define UINT_LEAST8_MAX 255 |
#else |
#error required type int_least8_t missing |
#endif |
#if __int16_t_defined |
#define INT16_MIN -32768 |
#define INT16_MAX 32767 |
#define UINT16_MAX 65535 |
#endif |
#if __int_least16_t_defined |
#define INT_LEAST16_MIN -32768 |
#define INT_LEAST16_MAX 32767 |
#define UINT_LEAST16_MAX 65535 |
#else |
#error required type int_least16_t missing |
#endif |
#if __int32_t_defined |
#if __have_long32 |
#define INT32_MIN (-2147483647L-1) |
#define INT32_MAX 2147483647L |
#define UINT32_MAX 4294967295UL |
#else |
#define INT32_MIN (-2147483647-1) |
#define INT32_MAX 2147483647 |
#define UINT32_MAX 4294967295U |
#endif |
#endif |
#if __int_least32_t_defined |
#if __have_long32 |
#define INT_LEAST32_MIN (-2147483647L-1) |
#define INT_LEAST32_MAX 2147483647L |
#define UINT_LEAST32_MAX 4294967295UL |
#else |
#define INT_LEAST32_MIN (-2147483647-1) |
#define INT_LEAST32_MAX 2147483647 |
#define UINT_LEAST32_MAX 4294967295U |
#endif |
#else |
#error required type int_least32_t missing |
#endif |
#if __int64_t_defined |
#if __have_long64 |
#define INT64_MIN (-9223372036854775807L-1L) |
#define INT64_MAX 9223372036854775807L |
#define UINT64_MAX 18446744073709551615U |
#elif __have_longlong64 |
#define INT64_MIN (-9223372036854775807LL-1LL) |
#define INT64_MAX 9223372036854775807LL |
#define UINT64_MAX 18446744073709551615ULL |
#endif |
#endif |
#if __int_least64_t_defined |
#if __have_long64 |
#define INT_LEAST64_MIN (-9223372036854775807L-1L) |
#define INT_LEAST64_MAX 9223372036854775807L |
#define UINT_LEAST64_MAX 18446744073709551615U |
#elif __have_longlong64 |
#define INT_LEAST64_MIN (-9223372036854775807LL-1LL) |
#define INT_LEAST64_MAX 9223372036854775807LL |
#define UINT_LEAST64_MAX 18446744073709551615ULL |
#endif |
#endif |
#if __int_fast8_t_defined |
#if __STDINT_EXP(INT_MAX) >= 0x7f |
#define INT_FAST8_MIN (-__STDINT_EXP(INT_MAX)-1) |
#define INT_FAST8_MAX __STDINT_EXP(INT_MAX) |
#define UINT_FAST8_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
#else |
#define INT_FAST8_MIN INT_LEAST8_MIN |
#define INT_FAST8_MAX INT_LEAST8_MAX |
#define UINT_FAST8_MAX UINT_LEAST8_MAX |
#endif |
#endif |
#if __int_fast16_t_defined |
#if __STDINT_EXP(INT_MAX) >= 0x7fff |
#define INT_FAST16_MIN (-__STDINT_EXP(INT_MAX)-1) |
#define INT_FAST16_MAX __STDINT_EXP(INT_MAX) |
#define UINT_FAST16_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
#else |
#define INT_FAST16_MIN INT_LEAST16_MIN |
#define INT_FAST16_MAX INT_LEAST16_MAX |
#define UINT_FAST16_MAX UINT_LEAST16_MAX |
#endif |
#endif |
#if __int_fast32_t_defined |
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff |
#define INT_FAST32_MIN (-__STDINT_EXP(INT_MAX)-1) |
#define INT_FAST32_MAX __STDINT_EXP(INT_MAX) |
#define UINT_FAST32_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
#else |
#define INT_FAST32_MIN INT_LEAST32_MIN |
#define INT_FAST32_MAX INT_LEAST32_MAX |
#define UINT_FAST32_MAX UINT_LEAST32_MAX |
#endif |
#endif |
#if __int_fast64_t_defined |
#if __STDINT_EXP(INT_MAX) > 0x7fffffff |
#define INT_FAST64_MIN (-__STDINT_EXP(INT_MAX)-1) |
#define INT_FAST64_MAX __STDINT_EXP(INT_MAX) |
#define UINT_FAST64_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
#else |
#define INT_FAST64_MIN INT_LEAST64_MIN |
#define INT_FAST64_MAX INT_LEAST64_MAX |
#define UINT_FAST64_MAX UINT_LEAST64_MAX |
#endif |
#endif |
#ifdef __INTMAX_MAX__ |
#define INTMAX_MAX __INTMAX_MAX__ |
#define INTMAX_MIN (-INTMAX_MAX - 1) |
#elif defined(__INTMAX_TYPE__) |
/* All relevant GCC versions prefer long to long long for intmax_t. */ |
#define INTMAX_MAX INT64_MAX |
#define INTMAX_MIN INT64_MIN |
#endif |
#ifdef __UINTMAX_MAX__ |
#define UINTMAX_MAX __UINTMAX_MAX__ |
#elif defined(__UINTMAX_TYPE__) |
/* All relevant GCC versions prefer long to long long for intmax_t. */ |
#define UINTMAX_MAX UINT64_MAX |
#endif |
/* This must match size_t in stddef.h, currently long unsigned int */ |
#ifdef __SIZE_MAX__ |
#define SIZE_MAX __SIZE_MAX__ |
#else |
#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1) |
#endif |
/* This must match sig_atomic_t in <signal.h> (currently int) */ |
#define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1) |
#define SIG_ATOMIC_MAX __STDINT_EXP(INT_MAX) |
/* This must match ptrdiff_t in <stddef.h> (currently long int) */ |
#ifdef __PTRDIFF_MAX__ |
#define PTRDIFF_MAX __PTRDIFF_MAX__ |
#else |
#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX) |
#endif |
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1) |
#ifdef __WCHAR_MAX__ |
#define WCHAR_MAX __WCHAR_MAX__ |
#endif |
#ifdef __WCHAR_MIN__ |
#define WCHAR_MIN __WCHAR_MIN__ |
#endif |
/* wint_t is unsigned int on almost all GCC targets. */ |
#ifdef __WINT_MAX__ |
#define WINT_MAX __WINT_MAX__ |
#else |
#define WINT_MAX (__STDINT_EXP(INT_MAX) * 2U + 1U) |
#endif |
#ifdef __WINT_MIN__ |
#define WINT_MIN __WINT_MIN__ |
#else |
#define WINT_MIN 0U |
#endif |
/** Macros for minimum-width integer constant expressions */ |
#define INT8_C(x) x |
#if __STDINT_EXP(INT_MAX) > 0x7f |
#define UINT8_C(x) x |
#else |
#define UINT8_C(x) x##U |
#endif |
#define INT16_C(x) x |
#if __STDINT_EXP(INT_MAX) > 0x7fff |
#define UINT16_C(x) x |
#else |
#define UINT16_C(x) x##U |
#endif |
#if __have_long32 |
#define INT32_C(x) x##L |
#define UINT32_C(x) x##UL |
#else |
#define INT32_C(x) x |
#define UINT32_C(x) x##U |
#endif |
#if __int64_t_defined |
#if __have_long64 |
#define INT64_C(x) x##L |
#define UINT64_C(x) x##UL |
#else |
#define INT64_C(x) x##LL |
#define UINT64_C(x) x##ULL |
#endif |
#endif |
/** Macros for greatest-width integer constant expression */ |
#if __have_long64 |
#define INTMAX_C(x) x##L |
#define UINTMAX_C(x) x##UL |
#else |
#define INTMAX_C(x) x##LL |
#define UINTMAX_C(x) x##ULL |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* _STDINT_H */ |
/contrib/sdk/sources/libc/include/stdio.h |
---|
0,0 → 1,685 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
* |
* @(#)stdio.h 5.3 (Berkeley) 3/15/86 |
*/ |
/* |
* NB: to fit things in six character monocase externals, the |
* stdio code uses the prefix `__s' for stdio objects, typically |
* followed by a three-character attempt at a mnemonic. |
*/ |
#ifndef _STDIO_H_ |
#define _STDIO_H_ |
#include "_ansi.h" |
#define _FSTDIO /* ``function stdio'' */ |
#define __need_size_t |
#include <stddef.h> |
#define __need___va_list |
#include <stdarg.h> |
/* |
* <sys/reent.h> defines __FILE, _fpos_t. |
* They must be defined there because struct _reent needs them (and we don't |
* want reent.h to include this file. |
*/ |
#include <sys/reent.h> |
#include <sys/types.h> |
_BEGIN_STD_C |
typedef __FILE FILE; |
#ifdef __CYGWIN__ |
typedef _fpos64_t fpos_t; |
#else |
typedef _fpos_t fpos_t; |
#ifdef __LARGE64_FILES |
typedef _fpos64_t fpos64_t; |
#endif |
#endif /* !__CYGWIN__ */ |
#include <sys/stdio.h> |
#define __SLBF 0x0001 /* line buffered */ |
#define __SNBF 0x0002 /* unbuffered */ |
#define __SRD 0x0004 /* OK to read */ |
#define __SWR 0x0008 /* OK to write */ |
/* RD and WR are never simultaneously asserted */ |
#define __SRW 0x0010 /* open for reading & writing */ |
#define __SEOF 0x0020 /* found EOF */ |
#define __SERR 0x0040 /* found error */ |
#define __SMBF 0x0080 /* _buf is from malloc */ |
#define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */ |
#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ |
#define __SOPT 0x0400 /* do fseek() optimisation */ |
#define __SNPT 0x0800 /* do not do fseek() optimisation */ |
#define __SOFF 0x1000 /* set iff _offset is in fact correct */ |
#define __SORD 0x2000 /* true => stream orientation (byte/wide) decided */ |
#if defined(__CYGWIN__) |
# define __SCLE 0x4000 /* convert line endings CR/LF <-> NL */ |
#endif |
#define __SL64 0x8000 /* is 64-bit offset large file */ |
/* _flags2 flags */ |
#define __SWID 0x2000 /* true => stream orientation wide, false => byte, only valid if __SORD in _flags is true */ |
/* |
* The following three definitions are for ANSI C, which took them |
* from System V, which stupidly took internal interface macros and |
* made them official arguments to setvbuf(), without renaming them. |
* Hence, these ugly _IOxxx names are *supposed* to appear in user code. |
* |
* Although these happen to match their counterparts above, the |
* implementation does not rely on that (so these could be renumbered). |
*/ |
#define _IOFBF 0 /* setvbuf should set fully buffered */ |
#define _IOLBF 1 /* setvbuf should set line buffered */ |
#define _IONBF 2 /* setvbuf should set unbuffered */ |
#ifndef NULL |
#define NULL 0 |
#endif |
#define EOF (-1) |
#ifdef __BUFSIZ__ |
#define BUFSIZ __BUFSIZ__ |
#else |
#define BUFSIZ 1024 |
#endif |
#ifdef __FOPEN_MAX__ |
#define FOPEN_MAX __FOPEN_MAX__ |
#else |
#define FOPEN_MAX 20 |
#endif |
#ifdef __FILENAME_MAX__ |
#define FILENAME_MAX __FILENAME_MAX__ |
#else |
#define FILENAME_MAX 1024 |
#endif |
#ifdef __L_tmpnam__ |
#define L_tmpnam __L_tmpnam__ |
#else |
#define L_tmpnam FILENAME_MAX |
#endif |
#ifndef __STRICT_ANSI__ |
#define P_tmpdir "/tmp" |
#endif |
#ifndef SEEK_SET |
#define SEEK_SET 0 /* set file offset to offset */ |
#endif |
#ifndef SEEK_CUR |
#define SEEK_CUR 1 /* set file offset to current plus offset */ |
#endif |
#ifndef SEEK_END |
#define SEEK_END 2 /* set file offset to EOF plus offset */ |
#endif |
#define TMP_MAX 26 |
#ifndef _REENT_ONLY |
#define stdin (_REENT->_stdin) |
#define stdout (_REENT->_stdout) |
#define stderr (_REENT->_stderr) |
#else /* _REENT_ONLY */ |
#define stdin (_impure_ptr->_stdin) |
#define stdout (_impure_ptr->_stdout) |
#define stderr (_impure_ptr->_stderr) |
#endif /* _REENT_ONLY */ |
#define _stdin_r(x) ((x)->_stdin) |
#define _stdout_r(x) ((x)->_stdout) |
#define _stderr_r(x) ((x)->_stderr) |
/* |
* Functions defined in ANSI C standard. |
*/ |
#ifndef __VALIST |
#ifdef __GNUC__ |
#define __VALIST __gnuc_va_list |
#else |
#define __VALIST char* |
#endif |
#endif |
FILE * _EXFUN(tmpfile, (void)); |
char * _EXFUN(tmpnam, (char *)); |
int _EXFUN(fclose, (FILE *)); |
int _EXFUN(fflush, (FILE *)); |
FILE * _EXFUN(freopen, (const char *, const char *, FILE *)); |
void _EXFUN(setbuf, (FILE *, char *)); |
int _EXFUN(setvbuf, (FILE *, char *, int, size_t)); |
int _EXFUN(fprintf, (FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(fscanf, (FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
int _EXFUN(printf, (const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 1, 2)))); |
int _EXFUN(scanf, (const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 1, 2)))); |
int _EXFUN(sscanf, (const char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
int _EXFUN(vfprintf, (FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(vprintf, (const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 1, 0)))); |
int _EXFUN(vsprintf, (char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(fgetc, (FILE *)); |
char * _EXFUN(fgets, (char *, int, FILE *)); |
int _EXFUN(fputc, (int, FILE *)); |
int _EXFUN(fputs, (const char *, FILE *)); |
int _EXFUN(getc, (FILE *)); |
int _EXFUN(getchar, (void)); |
char * _EXFUN(gets, (char *)); |
int _EXFUN(putc, (int, FILE *)); |
int _EXFUN(putchar, (int)); |
int _EXFUN(puts, (const char *)); |
int _EXFUN(ungetc, (int, FILE *)); |
size_t _EXFUN(fread, (_PTR, size_t _size, size_t _n, FILE *)); |
size_t _EXFUN(fwrite, (const _PTR , size_t _size, size_t _n, FILE *)); |
#ifdef _COMPILING_NEWLIB |
int _EXFUN(fgetpos, (FILE *, _fpos_t *)); |
#else |
int _EXFUN(fgetpos, (FILE *, fpos_t *)); |
#endif |
int _EXFUN(fseek, (FILE *, long, int)); |
#ifdef _COMPILING_NEWLIB |
int _EXFUN(fsetpos, (FILE *, const _fpos_t *)); |
#else |
int _EXFUN(fsetpos, (FILE *, const fpos_t *)); |
#endif |
long _EXFUN(ftell, ( FILE *)); |
void _EXFUN(rewind, (FILE *)); |
void _EXFUN(clearerr, (FILE *)); |
int _EXFUN(feof, (FILE *)); |
int _EXFUN(ferror, (FILE *)); |
void _EXFUN(perror, (const char *)); |
#ifndef _REENT_ONLY |
FILE * _EXFUN(fopen, (const char *_name, const char *_type)); |
int _EXFUN(sprintf, (char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(remove, (const char *)); |
int _EXFUN(rename, (const char *, const char *)); |
#endif |
#if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K) |
#ifdef _COMPILING_NEWLIB |
int _EXFUN(fseeko, (FILE *, _off_t, int)); |
_off_t _EXFUN(ftello, ( FILE *)); |
#else |
int _EXFUN(fseeko, (FILE *, off_t, int)); |
off_t _EXFUN(ftello, ( FILE *)); |
#endif |
#endif |
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) |
#ifndef _REENT_ONLY |
int _EXFUN(asiprintf, (char **, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
char * _EXFUN(asniprintf, (char *, size_t *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
char * _EXFUN(asnprintf, (char *, size_t *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(asprintf, (char **, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
#ifndef diprintf |
int _EXFUN(diprintf, (int, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
#endif |
int _EXFUN(fcloseall, (_VOID)); |
int _EXFUN(fiprintf, (FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(fiscanf, (FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
int _EXFUN(iprintf, (const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 1, 2)))); |
int _EXFUN(iscanf, (const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 1, 2)))); |
int _EXFUN(siprintf, (char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(siscanf, (const char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
int _EXFUN(snprintf, (char *, size_t, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(sniprintf, (char *, size_t, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
char * _EXFUN(tempnam, (const char *, const char *)); |
int _EXFUN(vasiprintf, (char **, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
char * _EXFUN(vasniprintf, (char *, size_t *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
char * _EXFUN(vasnprintf, (char *, size_t *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(vasprintf, (char **, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(vdiprintf, (int, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
int _EXFUN(vfscanf, (FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
int _EXFUN(viprintf, (const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 1, 0)))); |
int _EXFUN(viscanf, (const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 1, 0)))); |
int _EXFUN(vscanf, (const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 1, 0)))); |
int _EXFUN(vsiprintf, (char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(vsiscanf, (const char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(vsscanf, (const char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
#endif /* !_REENT_ONLY */ |
#endif /* !__STRICT_ANSI__ */ |
/* |
* Routines in POSIX 1003.1:2001. |
*/ |
#ifndef __STRICT_ANSI__ |
#ifndef _REENT_ONLY |
FILE * _EXFUN(fdopen, (int, const char *)); |
#endif |
int _EXFUN(fileno, (FILE *)); |
int _EXFUN(getw, (FILE *)); |
int _EXFUN(pclose, (FILE *)); |
FILE * _EXFUN(popen, (const char *, const char *)); |
int _EXFUN(putw, (int, FILE *)); |
void _EXFUN(setbuffer, (FILE *, char *, int)); |
int _EXFUN(setlinebuf, (FILE *)); |
int _EXFUN(getc_unlocked, (FILE *)); |
int _EXFUN(getchar_unlocked, (void)); |
void _EXFUN(flockfile, (FILE *)); |
int _EXFUN(ftrylockfile, (FILE *)); |
void _EXFUN(funlockfile, (FILE *)); |
int _EXFUN(putc_unlocked, (int, FILE *)); |
int _EXFUN(putchar_unlocked, (int)); |
#endif /* ! __STRICT_ANSI__ */ |
/* |
* Routines in POSIX 1003.1:200x. |
*/ |
#ifndef __STRICT_ANSI__ |
# ifndef _REENT_ONLY |
# ifndef dprintf |
int _EXFUN(dprintf, (int, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
# endif |
FILE * _EXFUN(fmemopen, (void *, size_t, const char *)); |
/* getdelim - see __getdelim for now */ |
/* getline - see __getline for now */ |
FILE * _EXFUN(open_memstream, (char **, size_t *)); |
#if defined (__CYGWIN__) |
int _EXFUN(renameat, (int, const char *, int, const char *)); |
#endif |
int _EXFUN(vdprintf, (int, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
# endif |
#endif |
/* |
* Recursive versions of the above. |
*/ |
int _EXFUN(_asiprintf_r, (struct _reent *, char **, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
char * _EXFUN(_asniprintf_r, (struct _reent *, char *, size_t *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
char * _EXFUN(_asnprintf_r, (struct _reent *, char *, size_t *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
int _EXFUN(_asprintf_r, (struct _reent *, char **, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_diprintf_r, (struct _reent *, int, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_dprintf_r, (struct _reent *, int, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_fclose_r, (struct _reent *, FILE *)); |
int _EXFUN(_fcloseall_r, (struct _reent *)); |
FILE * _EXFUN(_fdopen_r, (struct _reent *, int, const char *)); |
int _EXFUN(_fflush_r, (struct _reent *, FILE *)); |
int _EXFUN(_fgetc_r, (struct _reent *, FILE *)); |
char * _EXFUN(_fgets_r, (struct _reent *, char *, int, FILE *)); |
#ifdef _COMPILING_NEWLIB |
int _EXFUN(_fgetpos_r, (struct _reent *, FILE *, _fpos_t *)); |
int _EXFUN(_fsetpos_r, (struct _reent *, FILE *, const _fpos_t *)); |
#else |
int _EXFUN(_fgetpos_r, (struct _reent *, FILE *, fpos_t *)); |
int _EXFUN(_fsetpos_r, (struct _reent *, FILE *, const fpos_t *)); |
#endif |
int _EXFUN(_fiprintf_r, (struct _reent *, FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_fiscanf_r, (struct _reent *, FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
FILE * _EXFUN(_fmemopen_r, (struct _reent *, void *, size_t, const char *)); |
FILE * _EXFUN(_fopen_r, (struct _reent *, const char *, const char *)); |
FILE * _EXFUN(_freopen_r, (struct _reent *, const char *, const char *, FILE *)); |
int _EXFUN(_fprintf_r, (struct _reent *, FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_fpurge_r, (struct _reent *, FILE *)); |
int _EXFUN(_fputc_r, (struct _reent *, int, FILE *)); |
int _EXFUN(_fputs_r, (struct _reent *, const char *, FILE *)); |
size_t _EXFUN(_fread_r, (struct _reent *, _PTR, size_t _size, size_t _n, FILE *)); |
int _EXFUN(_fscanf_r, (struct _reent *, FILE *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
int _EXFUN(_fseek_r, (struct _reent *, FILE *, long, int)); |
int _EXFUN(_fseeko_r,(struct _reent *, FILE *, _off_t, int)); |
long _EXFUN(_ftell_r, (struct _reent *, FILE *)); |
_off_t _EXFUN(_ftello_r,(struct _reent *, FILE *)); |
void _EXFUN(_rewind_r, (struct _reent *, FILE *)); |
size_t _EXFUN(_fwrite_r, (struct _reent *, const _PTR , size_t _size, size_t _n, FILE *)); |
int _EXFUN(_getc_r, (struct _reent *, FILE *)); |
int _EXFUN(_getc_unlocked_r, (struct _reent *, FILE *)); |
int _EXFUN(_getchar_r, (struct _reent *)); |
int _EXFUN(_getchar_unlocked_r, (struct _reent *)); |
char * _EXFUN(_gets_r, (struct _reent *, char *)); |
int _EXFUN(_iprintf_r, (struct _reent *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(_iscanf_r, (struct _reent *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
FILE * _EXFUN(_open_memstream_r, (struct _reent *, char **, size_t *)); |
void _EXFUN(_perror_r, (struct _reent *, const char *)); |
int _EXFUN(_printf_r, (struct _reent *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); |
int _EXFUN(_putc_r, (struct _reent *, int, FILE *)); |
int _EXFUN(_putc_unlocked_r, (struct _reent *, int, FILE *)); |
int _EXFUN(_putchar_unlocked_r, (struct _reent *, int)); |
int _EXFUN(_putchar_r, (struct _reent *, int)); |
int _EXFUN(_puts_r, (struct _reent *, const char *)); |
int _EXFUN(_remove_r, (struct _reent *, const char *)); |
int _EXFUN(_rename_r, (struct _reent *, |
const char *_old, const char *_new)); |
int _EXFUN(_scanf_r, (struct _reent *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); |
int _EXFUN(_siprintf_r, (struct _reent *, char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_siscanf_r, (struct _reent *, const char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
int _EXFUN(_sniprintf_r, (struct _reent *, char *, size_t, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
int _EXFUN(_snprintf_r, (struct _reent *, char *, size_t, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 4, 5)))); |
int _EXFUN(_sprintf_r, (struct _reent *, char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); |
int _EXFUN(_sscanf_r, (struct _reent *, const char *, const char *, ...) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 4)))); |
char * _EXFUN(_tempnam_r, (struct _reent *, const char *, const char *)); |
FILE * _EXFUN(_tmpfile_r, (struct _reent *)); |
char * _EXFUN(_tmpnam_r, (struct _reent *, char *)); |
int _EXFUN(_ungetc_r, (struct _reent *, int, FILE *)); |
int _EXFUN(_vasiprintf_r, (struct _reent *, char **, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
char * _EXFUN(_vasniprintf_r, (struct _reent*, char *, size_t *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
char * _EXFUN(_vasnprintf_r, (struct _reent*, char *, size_t *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
int _EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vdiprintf_r, (struct _reent *, int, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vdprintf_r, (struct _reent *, int, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vfiscanf_r, (struct _reent *, FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
int _EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vfscanf_r, (struct _reent *, FILE *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
int _EXFUN(_viprintf_r, (struct _reent *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(_viscanf_r, (struct _reent *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
int _EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); |
int _EXFUN(_vscanf_r, (struct _reent *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); |
int _EXFUN(_vsiprintf_r, (struct _reent *, char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vsiscanf_r, (struct _reent *, const char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
int _EXFUN(_vsniprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
int _EXFUN(_vsnprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 4, 0)))); |
int _EXFUN(_vsprintf_r, (struct _reent *, char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_vsscanf_r, (struct _reent *, const char *, const char *, __VALIST) |
_ATTRIBUTE ((__format__ (__scanf__, 3, 0)))); |
/* Other extensions. */ |
int _EXFUN(fpurge, (FILE *)); |
ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *)); |
ssize_t _EXFUN(__getline, (char **, size_t *, FILE *)); |
#ifdef __LARGE64_FILES |
#if !defined(__CYGWIN__) || defined(_COMPILING_NEWLIB) |
FILE * _EXFUN(fdopen64, (int, const char *)); |
FILE * _EXFUN(fopen64, (const char *, const char *)); |
FILE * _EXFUN(freopen64, (_CONST char *, _CONST char *, FILE *)); |
_off64_t _EXFUN(ftello64, (FILE *)); |
_off64_t _EXFUN(fseeko64, (FILE *, _off64_t, int)); |
int _EXFUN(fgetpos64, (FILE *, _fpos64_t *)); |
int _EXFUN(fsetpos64, (FILE *, const _fpos64_t *)); |
FILE * _EXFUN(tmpfile64, (void)); |
FILE * _EXFUN(_fdopen64_r, (struct _reent *, int, const char *)); |
FILE * _EXFUN(_fopen64_r, (struct _reent *,const char *, const char *)); |
FILE * _EXFUN(_freopen64_r, (struct _reent *, _CONST char *, _CONST char *, FILE *)); |
_off64_t _EXFUN(_ftello64_r, (struct _reent *, FILE *)); |
_off64_t _EXFUN(_fseeko64_r, (struct _reent *, FILE *, _off64_t, int)); |
int _EXFUN(_fgetpos64_r, (struct _reent *, FILE *, _fpos64_t *)); |
int _EXFUN(_fsetpos64_r, (struct _reent *, FILE *, const _fpos64_t *)); |
FILE * _EXFUN(_tmpfile64_r, (struct _reent *)); |
#endif /* !__CYGWIN__ */ |
#endif /* __LARGE64_FILES */ |
/* |
* Routines internal to the implementation. |
*/ |
int _EXFUN(__srget_r, (struct _reent *, FILE *)); |
int _EXFUN(__swbuf_r, (struct _reent *, int, FILE *)); |
/* |
* Stdio function-access interface. |
*/ |
#ifndef __STRICT_ANSI__ |
# ifdef __LARGE64_FILES |
FILE *_EXFUN(funopen,(const _PTR __cookie, |
int (*__readfn)(_PTR __c, char *__buf, int __n), |
int (*__writefn)(_PTR __c, const char *__buf, int __n), |
_fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence), |
int (*__closefn)(_PTR __c))); |
FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie, |
int (*__readfn)(_PTR __c, char *__buf, int __n), |
int (*__writefn)(_PTR __c, const char *__buf, int __n), |
_fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence), |
int (*__closefn)(_PTR __c))); |
# else |
FILE *_EXFUN(funopen,(const _PTR __cookie, |
int (*__readfn)(_PTR __cookie, char *__buf, int __n), |
int (*__writefn)(_PTR __cookie, const char *__buf, int __n), |
fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence), |
int (*__closefn)(_PTR __cookie))); |
FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie, |
int (*__readfn)(_PTR __cookie, char *__buf, int __n), |
int (*__writefn)(_PTR __cookie, const char *__buf, int __n), |
fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence), |
int (*__closefn)(_PTR __cookie))); |
# endif /* !__LARGE64_FILES */ |
# define fropen(__cookie, __fn) funopen(__cookie, __fn, (int (*)())0, \ |
(fpos_t (*)())0, (int (*)())0) |
# define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \ |
(fpos_t (*)())0, (int (*)())0) |
typedef ssize_t cookie_read_function_t(void *__cookie, char *__buf, size_t __n); |
typedef ssize_t cookie_write_function_t(void *__cookie, const char *__buf, |
size_t __n); |
# ifdef __LARGE64_FILES |
typedef int cookie_seek_function_t(void *__cookie, _off64_t *__off, |
int __whence); |
# else |
typedef int cookie_seek_function_t(void *__cookie, off_t *__off, int __whence); |
# endif /* !__LARGE64_FILES */ |
typedef int cookie_close_function_t(void *__cookie); |
typedef struct |
{ |
/* These four struct member names are dictated by Linux; hopefully, |
they don't conflict with any macros. */ |
cookie_read_function_t *read; |
cookie_write_function_t *write; |
cookie_seek_function_t *seek; |
cookie_close_function_t *close; |
} cookie_io_functions_t; |
FILE *_EXFUN(fopencookie,(void *__cookie, |
const char *__mode, cookie_io_functions_t __functions)); |
FILE *_EXFUN(_fopencookie_r,(struct _reent *, void *__cookie, |
const char *__mode, cookie_io_functions_t __functions)); |
#endif /* ! __STRICT_ANSI__ */ |
#ifndef __CUSTOM_FILE_IO__ |
/* |
* The __sfoo macros are here so that we can |
* define function versions in the C library. |
*/ |
#define __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++)) |
#ifdef __SCLE |
/* For a platform with CR/LF, additional logic is required by |
__sgetc_r which would otherwise simply be a macro; therefore we |
use an inlined function. The function is only meant to be inlined |
in place as used and the function body should never be emitted. |
There are two possible means to this end when compiling with GCC, |
one when compiling with a standard C99 compiler, and for other |
compilers we're just stuck. At the moment, this issue only |
affects the Cygwin target, so we'll most likely be using GCC. */ |
_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p); |
_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p) |
{ |
int __c = __sgetc_raw_r(__ptr, __p); |
if ((__p->_flags & __SCLE) && (__c == '\r')) |
{ |
int __c2 = __sgetc_raw_r(__ptr, __p); |
if (__c2 == '\n') |
__c = __c2; |
else |
ungetc(__c2, __p); |
} |
return __c; |
} |
#else |
#define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p) |
#endif |
#ifdef _never /* __GNUC__ */ |
/* If this inline is actually used, then systems using coff debugging |
info get hopelessly confused. 21sept93 rich@cygnus.com. */ |
_ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { |
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) |
return (*_p->_p++ = _c); |
else |
return (__swbuf_r(_ptr, _c, _p)); |
} |
#else |
/* |
* This has been tuned to generate reasonable code on the vax using pcc |
*/ |
#define __sputc_raw_r(__ptr, __c, __p) \ |
(--(__p)->_w < 0 ? \ |
(__p)->_w >= (__p)->_lbfsize ? \ |
(*(__p)->_p = (__c)), *(__p)->_p != '\n' ? \ |
(int)*(__p)->_p++ : \ |
__swbuf_r(__ptr, '\n', __p) : \ |
__swbuf_r(__ptr, (int)(__c), __p) : \ |
(*(__p)->_p = (__c), (int)*(__p)->_p++)) |
#ifdef __SCLE |
#define __sputc_r(__ptr, __c, __p) \ |
((((__p)->_flags & __SCLE) && ((__c) == '\n')) \ |
? __sputc_raw_r(__ptr, '\r', (__p)) : 0 , \ |
__sputc_raw_r((__ptr), (__c), (__p))) |
#else |
#define __sputc_r(__ptr, __c, __p) __sputc_raw_r(__ptr, __c, __p) |
#endif |
#endif |
#define __sfeof(p) (((p)->_flags & __SEOF) != 0) |
#define __sferror(p) (((p)->_flags & __SERR) != 0) |
#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) |
#define __sfileno(p) ((p)->_file) |
#ifndef _REENT_SMALL |
#define feof(p) __sfeof(p) |
#define ferror(p) __sferror(p) |
#define clearerr(p) __sclearerr(p) |
#endif |
#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */ |
#define fileno(p) __sfileno(p) |
#endif |
#ifndef __CYGWIN__ |
#ifndef lint |
#define getc(fp) __sgetc_r(_REENT, fp) |
#define putc(x, fp) __sputc_r(_REENT, x, fp) |
#endif /* lint */ |
#endif /* __CYGWIN__ */ |
#ifndef __STRICT_ANSI__ |
/* fast always-buffered version, true iff error */ |
#define fast_putc(x,p) (--(p)->_w < 0 ? \ |
__swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0)) |
#define L_cuserid 9 /* posix says it goes in stdio.h :( */ |
#ifdef __CYGWIN__ |
#define L_ctermid 16 |
#endif |
#endif |
#endif /* !__CUSTOM_FILE_IO__ */ |
#define getchar() getc(stdin) |
#define putchar(x) putc(x, stdout) |
_END_STD_C |
#endif /* _STDIO_H_ */ |
/contrib/sdk/sources/libc/include/stdio_ext.h |
---|
0,0 → 1,22 |
/* |
* stdio_ext.h |
* |
* Definitions for I/O internal operations, originally from Solaris. |
*/ |
#ifndef _STDIO_EXT_H_ |
#define _STDIO_EXT_H_ |
#ifdef __rtems__ |
#error "<stdio_ext.h> not supported" |
#endif |
#include <stdio.h> |
_BEGIN_STD_C |
void _EXFUN(__fpurge,(FILE *)); |
_END_STD_C |
#endif /* _STDIO_EXT_H_ */ |
/contrib/sdk/sources/libc/include/stdlib.h |
---|
0,0 → 1,226 |
/* |
* stdlib.h |
* |
* Definitions for common types, variables, and functions. |
*/ |
#ifndef _STDLIB_H_ |
#define _STDLIB_H_ |
#include <machine/ieeefp.h> |
#include "_ansi.h" |
#define __need_size_t |
#define __need_wchar_t |
#include <stddef.h> |
#include <sys/reent.h> |
#include <machine/stdlib.h> |
#ifndef __STRICT_ANSI__ |
#include <alloca.h> |
#endif |
#ifdef __CYGWIN__ |
#include <cygwin/stdlib.h> |
#endif |
_BEGIN_STD_C |
typedef struct |
{ |
int quot; /* quotient */ |
int rem; /* remainder */ |
} div_t; |
typedef struct |
{ |
long quot; /* quotient */ |
long rem; /* remainder */ |
} ldiv_t; |
#ifndef __STRICT_ANSI__ |
typedef struct |
{ |
long long int quot; /* quotient */ |
long long int rem; /* remainder */ |
} lldiv_t; |
#endif |
#ifndef NULL |
#define NULL 0 |
#endif |
#define EXIT_FAILURE 1 |
#define EXIT_SUCCESS 0 |
#define RAND_MAX __RAND_MAX |
int _EXFUN(__locale_mb_cur_max,(_VOID)); |
#define MB_CUR_MAX __locale_mb_cur_max() |
_VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn))); |
int _EXFUN(abs,(int)); |
int _EXFUN(atexit,(_VOID (*__func)(_VOID))); |
double _EXFUN(atof,(const char *__nptr)); |
#ifndef __STRICT_ANSI__ |
float _EXFUN(atoff,(const char *__nptr)); |
#endif |
int _EXFUN(atoi,(const char *__nptr)); |
int _EXFUN(_atoi_r,(struct _reent *, const char *__nptr)); |
long _EXFUN(atol,(const char *__nptr)); |
long _EXFUN(_atol_r,(struct _reent *, const char *__nptr)); |
_PTR _EXFUN(bsearch,(const _PTR __key, |
const _PTR __base, |
size_t __nmemb, |
size_t __size, |
int _EXFNPTR(_compar,(const _PTR, const _PTR)))); |
_PTR _EXFUN_NOTHROW(calloc,(size_t __nmemb, size_t __size)); |
div_t _EXFUN(div,(int __numer, int __denom)); |
_VOID _EXFUN(exit,(int __status) _ATTRIBUTE ((noreturn))); |
_VOID _EXFUN_NOTHROW(free,(_PTR)); |
char * _EXFUN(getenv,(const char *__string)); |
char * _EXFUN(_getenv_r,(struct _reent *, const char *__string)); |
char * _EXFUN(_findenv,(_CONST char *, int *)); |
char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *)); |
#ifndef __STRICT_ANSI__ |
extern char *suboptarg; /* getsubopt(3) external variable */ |
int _EXFUN(getsubopt,(char **, char * const *, char **)); |
#endif |
long _EXFUN(labs,(long)); |
ldiv_t _EXFUN(ldiv,(long __numer, long __denom)); |
_PTR _EXFUN_NOTHROW(malloc,(size_t __size)); |
int _EXFUN(mblen,(const char *, size_t)); |
int _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, _mbstate_t *)); |
int _EXFUN(mbtowc,(wchar_t *, const char *, size_t)); |
int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *)); |
int _EXFUN(wctomb,(char *, wchar_t)); |
int _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, _mbstate_t *)); |
size_t _EXFUN(mbstowcs,(wchar_t *, const char *, size_t)); |
size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *)); |
size_t _EXFUN(wcstombs,(char *, const wchar_t *, size_t)); |
size_t _EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, _mbstate_t *)); |
#ifndef __STRICT_ANSI__ |
#ifndef _REENT_ONLY |
char * _EXFUN(mkdtemp,(char *)); |
int _EXFUN(mkostemp,(char *, int)); |
int _EXFUN(mkostemps,(char *, int, int)); |
int _EXFUN(mkstemp,(char *)); |
int _EXFUN(mkstemps,(char *, int)); |
char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead")))); |
#endif |
char * _EXFUN(_mkdtemp_r, (struct _reent *, char *)); |
int _EXFUN(_mkostemp_r, (struct _reent *, char *, int)); |
int _EXFUN(_mkostemps_r, (struct _reent *, char *, int, int)); |
int _EXFUN(_mkstemp_r, (struct _reent *, char *)); |
int _EXFUN(_mkstemps_r, (struct _reent *, char *, int)); |
char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead")))); |
#endif |
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR))); |
int _EXFUN(rand,(_VOID)); |
_PTR _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size)); |
#ifndef __STRICT_ANSI__ |
_PTR _EXFUN(reallocf,(_PTR __r, size_t __size)); |
#endif |
_VOID _EXFUN(srand,(unsigned __seed)); |
double _EXFUN(strtod,(const char *__n, char **__end_PTR)); |
double _EXFUN(_strtod_r,(struct _reent *,const char *__n, char **__end_PTR)); |
float _EXFUN(strtof,(const char *__n, char **__end_PTR)); |
#ifndef __STRICT_ANSI__ |
/* the following strtodf interface is deprecated...use strtof instead */ |
# ifndef strtodf |
# define strtodf strtof |
# endif |
#endif |
long _EXFUN(strtol,(const char *__n, char **__end_PTR, int __base)); |
long _EXFUN(_strtol_r,(struct _reent *,const char *__n, char **__end_PTR, int __base)); |
unsigned long _EXFUN(strtoul,(const char *__n, char **__end_PTR, int __base)); |
unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__n, char **__end_PTR, int __base)); |
int _EXFUN(system,(const char *__string)); |
#ifndef __STRICT_ANSI__ |
long _EXFUN(a64l,(const char *__input)); |
char * _EXFUN(l64a,(long __input)); |
char * _EXFUN(_l64a_r,(struct _reent *,long __input)); |
int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg)); |
_VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((noreturn))); |
int _EXFUN(putenv,(char *__string)); |
int _EXFUN(_putenv_r,(struct _reent *, char *__string)); |
_PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t)); |
int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite)); |
int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite)); |
char * _EXFUN(gcvt,(double,int,char *)); |
char * _EXFUN(gcvtf,(float,int,char *)); |
char * _EXFUN(fcvt,(double,int,int *,int *)); |
char * _EXFUN(fcvtf,(float,int,int *,int *)); |
char * _EXFUN(ecvt,(double,int,int *,int *)); |
char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *)); |
char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *)); |
char * _EXFUN(ecvtf,(float,int,int *,int *)); |
char * _EXFUN(dtoa,(double, int, int, int *, int*, char**)); |
int _EXFUN(rand_r,(unsigned *__seed)); |
double _EXFUN(drand48,(_VOID)); |
double _EXFUN(_drand48_r,(struct _reent *)); |
double _EXFUN(erand48,(unsigned short [3])); |
double _EXFUN(_erand48_r,(struct _reent *, unsigned short [3])); |
long _EXFUN(jrand48,(unsigned short [3])); |
long _EXFUN(_jrand48_r,(struct _reent *, unsigned short [3])); |
_VOID _EXFUN(lcong48,(unsigned short [7])); |
_VOID _EXFUN(_lcong48_r,(struct _reent *, unsigned short [7])); |
long _EXFUN(lrand48,(_VOID)); |
long _EXFUN(_lrand48_r,(struct _reent *)); |
long _EXFUN(mrand48,(_VOID)); |
long _EXFUN(_mrand48_r,(struct _reent *)); |
long _EXFUN(nrand48,(unsigned short [3])); |
long _EXFUN(_nrand48_r,(struct _reent *, unsigned short [3])); |
unsigned short * |
_EXFUN(seed48,(unsigned short [3])); |
unsigned short * |
_EXFUN(_seed48_r,(struct _reent *, unsigned short [3])); |
_VOID _EXFUN(srand48,(long)); |
_VOID _EXFUN(_srand48_r,(struct _reent *, long)); |
long long _EXFUN(atoll,(const char *__nptr)); |
long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr)); |
long long _EXFUN(llabs,(long long)); |
lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom)); |
long long _EXFUN(strtoll,(const char *__n, char **__end_PTR, int __base)); |
long long _EXFUN(_strtoll_r,(struct _reent *, const char *__n, char **__end_PTR, int __base)); |
unsigned long long _EXFUN(strtoull,(const char *__n, char **__end_PTR, int __base)); |
unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__n, char **__end_PTR, int __base)); |
#ifndef __CYGWIN__ |
_VOID _EXFUN(cfree,(_PTR)); |
int _EXFUN(unsetenv,(const char *__string)); |
int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string)); |
#endif |
#ifdef __rtems__ |
int _EXFUN(posix_memalign,(void **, size_t, size_t)); |
#endif |
#endif /* ! __STRICT_ANSI__ */ |
char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**)); |
#ifndef __CYGWIN__ |
_PTR _EXFUN_NOTHROW(_malloc_r,(struct _reent *, size_t)); |
_PTR _EXFUN_NOTHROW(_calloc_r,(struct _reent *, size_t, size_t)); |
_VOID _EXFUN_NOTHROW(_free_r,(struct _reent *, _PTR)); |
_PTR _EXFUN_NOTHROW(_realloc_r,(struct _reent *, _PTR, size_t)); |
_VOID _EXFUN(_mstats_r,(struct _reent *, char *)); |
#endif |
int _EXFUN(_system_r,(struct _reent *, const char *)); |
_VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *)); |
/* On platforms where long double equals double. */ |
#ifdef _LDBL_EQ_DBL |
extern long double strtold (const char *, char **); |
extern long double wcstold (const wchar_t *, wchar_t **); |
#endif /* _LDBL_EQ_DBL */ |
_END_STD_C |
#endif /* _STDLIB_H_ */ |
/contrib/sdk/sources/libc/include/string.h |
---|
0,0 → 1,136 |
/* |
* string.h |
* |
* Definitions for memory and string functions. |
*/ |
#ifndef _STRING_H_ |
#define _STRING_H_ |
#include "_ansi.h" |
#include <sys/reent.h> |
#include <sys/cdefs.h> |
#define __need_size_t |
#include <stddef.h> |
#ifndef NULL |
#define NULL 0 |
#endif |
_BEGIN_STD_C |
_PTR _EXFUN(memchr,(const _PTR, int, size_t)); |
int _EXFUN(memcmp,(const _PTR, const _PTR, size_t)); |
_PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t)); |
_PTR _EXFUN(memmove,(_PTR, const _PTR, size_t)); |
_PTR _EXFUN(memset,(_PTR, int, size_t)); |
char *_EXFUN(strcat,(char *, const char *)); |
char *_EXFUN(strchr,(const char *, int)); |
int _EXFUN(strcmp,(const char *, const char *)); |
int _EXFUN(strcoll,(const char *, const char *)); |
char *_EXFUN(strcpy,(char *, const char *)); |
size_t _EXFUN(strcspn,(const char *, const char *)); |
char *_EXFUN(strerror,(int)); |
size_t _EXFUN(strlen,(const char *)); |
char *_EXFUN(strncat,(char *, const char *, size_t)); |
int _EXFUN(strncmp,(const char *, const char *, size_t)); |
char *_EXFUN(strncpy,(char *, const char *, size_t)); |
char *_EXFUN(strpbrk,(const char *, const char *)); |
char *_EXFUN(strrchr,(const char *, int)); |
size_t _EXFUN(strspn,(const char *, const char *)); |
char *_EXFUN(strstr,(const char *, const char *)); |
#ifndef _REENT_ONLY |
char *_EXFUN(strtok,(char *, const char *)); |
#endif |
size_t _EXFUN(strxfrm,(char *, const char *, size_t)); |
#ifndef __STRICT_ANSI__ |
char *_EXFUN(strtok_r,(char *, const char *, char **)); |
int _EXFUN(bcmp,(const void *, const void *, size_t)); |
void _EXFUN(bcopy,(const void *, void *, size_t)); |
void _EXFUN(bzero,(void *, size_t)); |
int _EXFUN(ffs,(int)); |
char *_EXFUN(index,(const char *, int)); |
_PTR _EXFUN(memccpy,(_PTR, const _PTR, int, size_t)); |
_PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t)); |
_PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t)); |
char *_EXFUN(rindex,(const char *, int)); |
char *_EXFUN(stpcpy,(char *, const char *)); |
char *_EXFUN(stpncpy,(char *, const char *, size_t)); |
int _EXFUN(strcasecmp,(const char *, const char *)); |
char *_EXFUN(strcasestr,(const char *, const char *)); |
char *_EXFUN(strchrnul,(const char *, int)); |
char *_EXFUN(strdup,(const char *)); |
char *_EXFUN(_strdup_r,(struct _reent *, const char *)); |
char *_EXFUN(strndup,(const char *, size_t)); |
char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t)); |
/* There are two common strerror_r variants. If you request |
_GNU_SOURCE, you get the GNU version; otherwise you get the POSIX |
version. POSIX requires that #undef strerror_r will still let you |
invoke the underlying function, but that requires gcc support. */ |
#ifdef _GNU_SOURCE |
char *_EXFUN(strerror_r,(int, char *, size_t)); |
#else |
# ifdef __GNUC__ |
int _EXFUN(strerror_r,(int, char *, size_t)) __asm__ (__ASMNAME ("__xpg_strerror_r")); |
# else |
int _EXFUN(__xpg_strerror_r,(int, char *, size_t)); |
# define strerror_r __xpg_strerror_r |
# endif |
#endif |
size_t _EXFUN(strlcat,(char *, const char *, size_t)); |
size_t _EXFUN(strlcpy,(char *, const char *, size_t)); |
int _EXFUN(strncasecmp,(const char *, const char *, size_t)); |
size_t _EXFUN(strnlen,(const char *, size_t)); |
char *_EXFUN(strsep,(char **, const char *)); |
char *_EXFUN(strlwr,(char *)); |
char *_EXFUN(strupr,(char *)); |
#ifndef DEFS_H /* Kludge to work around problem compiling in gdb */ |
char *_EXFUN(strsignal, (int __signo)); |
#endif |
#ifdef __CYGWIN__ |
int _EXFUN(strtosigno, (const char *__name)); |
#endif |
/* Recursive version of strerror. */ |
char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *)); |
#if defined _GNU_SOURCE && defined __GNUC__ |
#define strdupa(__s) \ |
(__extension__ ({const char *__in = (__s); \ |
size_t __len = strlen (__in) + 1; \ |
char * __out = (char *) __builtin_alloca (__len); \ |
(char *) memcpy (__out, __in, __len);})) |
#define strndupa(__s, __n) \ |
(__extension__ ({const char *__in = (__s); \ |
size_t __len = strnlen (__in, (__n)) + 1; \ |
char *__out = (char *) __builtin_alloca (__len); \ |
__out[__len-1] = '\0'; \ |
(char *) memcpy (__out, __in, __len-1);})) |
#endif /* _GNU_SOURCE && __GNUC__ */ |
/* These function names are used on Windows and perhaps other systems. */ |
#ifndef strcmpi |
#define strcmpi strcasecmp |
#endif |
#ifndef stricmp |
#define stricmp strcasecmp |
#endif |
#ifndef strncmpi |
#define strncmpi strncasecmp |
#endif |
#ifndef strnicmp |
#define strnicmp strncasecmp |
#endif |
#endif /* ! __STRICT_ANSI__ */ |
#include <sys/string.h> |
_END_STD_C |
#endif /* _STRING_H_ */ |
/contrib/sdk/sources/libc/include/strings.h |
---|
0,0 → 1,35 |
/* |
* strings.h |
* |
* Definitions for string operations. |
*/ |
#ifndef _STRINGS_H_ |
#define _STRINGS_H_ |
#include "_ansi.h" |
#include <sys/reent.h> |
#include <sys/types.h> /* for size_t */ |
_BEGIN_STD_C |
#if !defined __STRICT_ANSI__ && _POSIX_VERSION < 200809L |
/* |
* Marked LEGACY in Open Group Base Specifications Issue 6/IEEE Std 1003.1-2004 |
* Removed from Open Group Base Specifications Issue 7/IEEE Std 1003.1-2008 |
*/ |
int _EXFUN(bcmp,(const void *, const void *, size_t)); |
void _EXFUN(bcopy,(const void *, void *, size_t)); |
void _EXFUN(bzero,(void *, size_t)); |
char *_EXFUN(index,(const char *, int)); |
char *_EXFUN(rindex,(const char *, int)); |
#endif /* ! __STRICT_ANSI__ */ |
int _EXFUN(ffs,(int)); |
int _EXFUN(strcasecmp,(const char *, const char *)); |
int _EXFUN(strncasecmp,(const char *, const char *, size_t)); |
_END_STD_C |
#endif /* _STRINGS_H_ */ |
/contrib/sdk/sources/libc/include/tar.h |
---|
0,0 → 1,39 |
/* |
* tar.h |
*/ |
#ifndef _TAR_H |
#define _TAR_H |
/* General definitions */ |
#define TMAGIC "ustar" /* ustar plus null byte. */ |
#define TMAGLEN 6 /* Length of the above. */ |
#define TVERSION "00" /* 00 without a null byte. */ |
#define TVERSLEN 2 /* Length of the above. */ |
/* Typeflag field definitions */ |
#define REGTYPE '0' /* Regular file. */ |
#define AREGTYPE '\0' /* Regular file. */ |
#define LNKTYPE '1' /* Link. */ |
#define SYMTYPE '2' /* Symbolic link. */ |
#define CHRTYPE '3' /* Character special. */ |
#define BLKTYPE '4' /* Block special. */ |
#define DIRTYPE '5' /* Directory. */ |
#define FIFOTYPE '6' /* FIFO special. */ |
#define CONTTYPE '7' /* Reserved. */ |
/* Mode field bit definitions (octal) */ |
#define TSUID 04000 /* Set UID on execution. */ |
#define TSGID 02000 /* Set GID on execution. */ |
#define TSVTX 01000 /* On directories, restricted deletion flag. */ |
#define TUREAD 00400 /* Read by owner. */ |
#define TUWRITE 00200 /* Write by owner. */ |
#define TUEXEC 00100 /* Execute/search by owner. */ |
#define TGREAD 00040 /* Read by group. */ |
#define TGWRITE 00020 /* Write by group. */ |
#define TGEXEC 00010 /* Execute/search by group. */ |
#define TOREAD 00004 /* Read by other. */ |
#define TOWRITE 00002 /* Write by other. */ |
#define TOEXEC 00001 /* Execute/search by other. */ |
#endif |
/contrib/sdk/sources/libc/include/termios.h |
---|
0,0 → 1,7 |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <sys/termios.h> |
#ifdef __cplusplus |
} |
#endif |
/contrib/sdk/sources/libc/include/time.h |
---|
0,0 → 1,277 |
/* |
* time.h |
* |
* Struct and function declarations for dealing with time. |
*/ |
#ifndef _TIME_H_ |
#define _TIME_H_ |
#include "_ansi.h" |
#include <sys/reent.h> |
#ifndef NULL |
#define NULL 0 |
#endif |
/* Get _CLOCKS_PER_SEC_ */ |
#include <machine/time.h> |
#ifndef _CLOCKS_PER_SEC_ |
#define _CLOCKS_PER_SEC_ 1000 |
#endif |
#define CLOCKS_PER_SEC _CLOCKS_PER_SEC_ |
#define CLK_TCK CLOCKS_PER_SEC |
#define __need_size_t |
#include <stddef.h> |
#include <sys/types.h> |
_BEGIN_STD_C |
struct tm |
{ |
int tm_sec; |
int tm_min; |
int tm_hour; |
int tm_mday; |
int tm_mon; |
int tm_year; |
int tm_wday; |
int tm_yday; |
int tm_isdst; |
}; |
clock_t _EXFUN(clock, (void)); |
double _EXFUN(difftime, (time_t _time2, time_t _time1)); |
time_t _EXFUN(mktime, (struct tm *_timeptr)); |
time_t _EXFUN(time, (time_t *_timer)); |
#ifndef _REENT_ONLY |
char *_EXFUN(asctime, (const struct tm *_tblock)); |
char *_EXFUN(ctime, (const time_t *_time)); |
struct tm *_EXFUN(gmtime, (const time_t *_timer)); |
struct tm *_EXFUN(localtime,(const time_t *_timer)); |
#endif |
size_t _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t)); |
char *_EXFUN(asctime_r, (const struct tm *, char *)); |
char *_EXFUN(ctime_r, (const time_t *, char *)); |
struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *)); |
struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *)); |
_END_STD_C |
#ifdef __cplusplus |
extern "C" { |
#endif |
#ifndef __STRICT_ANSI__ |
char *_EXFUN(strptime, (const char *, const char *, struct tm *)); |
_VOID _EXFUN(tzset, (_VOID)); |
_VOID _EXFUN(_tzset_r, (struct _reent *)); |
typedef struct __tzrule_struct |
{ |
char ch; |
int m; |
int n; |
int d; |
int s; |
time_t change; |
long offset; /* Match type of _timezone. */ |
} __tzrule_type; |
typedef struct __tzinfo_struct |
{ |
int __tznorth; |
int __tzyear; |
__tzrule_type __tzrule[2]; |
} __tzinfo_type; |
__tzinfo_type *_EXFUN (__gettzinfo, (_VOID)); |
/* getdate functions */ |
#ifdef HAVE_GETDATE |
#ifndef _REENT_ONLY |
#define getdate_err (*__getdate_err()) |
int *_EXFUN(__getdate_err,(_VOID)); |
struct tm * _EXFUN(getdate, (const char *)); |
/* getdate_err is set to one of the following values to indicate the error. |
1 the DATEMSK environment variable is null or undefined, |
2 the template file cannot be opened for reading, |
3 failed to get file status information, |
4 the template file is not a regular file, |
5 an error is encountered while reading the template file, |
6 memory allication failed (not enough memory available), |
7 there is no line in the template that matches the input, |
8 invalid input specification */ |
#endif /* !_REENT_ONLY */ |
/* getdate_r returns the error code as above */ |
int _EXFUN(getdate_r, (const char *, struct tm *)); |
#endif /* HAVE_GETDATE */ |
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */ |
extern __IMPORT long _timezone; |
extern __IMPORT int _daylight; |
extern __IMPORT char *_tzname[2]; |
/* POSIX defines the external tzname being defined in time.h */ |
#ifndef tzname |
#define tzname _tzname |
#endif |
#endif /* !__STRICT_ANSI__ */ |
#ifdef __cplusplus |
} |
#endif |
#include <sys/features.h> |
#ifdef __CYGWIN__ |
#include <cygwin/time.h> |
#endif /*__CYGWIN__*/ |
#if defined(_POSIX_TIMERS) |
#include <signal.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* Clocks, P1003.1b-1993, p. 263 */ |
int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp)); |
int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp)); |
int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res)); |
/* Create a Per-Process Timer, P1003.1b-1993, p. 264 */ |
int _EXFUN(timer_create, |
(clockid_t clock_id, struct sigevent *evp, timer_t *timerid)); |
/* Delete a Per_process Timer, P1003.1b-1993, p. 266 */ |
int _EXFUN(timer_delete, (timer_t timerid)); |
/* Per-Process Timers, P1003.1b-1993, p. 267 */ |
int _EXFUN(timer_settime, |
(timer_t timerid, int flags, const struct itimerspec *value, |
struct itimerspec *ovalue)); |
int _EXFUN(timer_gettime, (timer_t timerid, struct itimerspec *value)); |
int _EXFUN(timer_getoverrun, (timer_t timerid)); |
/* High Resolution Sleep, P1003.1b-1993, p. 269 */ |
int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _POSIX_TIMERS */ |
#if defined(_POSIX_CLOCK_SELECTION) |
#ifdef __cplusplus |
extern "C" { |
#endif |
int _EXFUN(clock_nanosleep, |
(clockid_t clock_id, int flags, const struct timespec *rqtp, |
struct timespec *rmtp)); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _POSIX_CLOCK_SELECTION */ |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */ |
/* values for the clock enable attribute */ |
#define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */ |
#define CLOCK_DISABLED 0 /* clock is disabled */ |
/* values for the pthread cputime_clock_allowed attribute */ |
#define CLOCK_ALLOWED 1 /* If a thread is created with this value a */ |
/* CPU-time clock attached to that thread */ |
/* shall be accessible. */ |
#define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */ |
/* thread shall not have a CPU-time clock */ |
/* accessible. */ |
/* Manifest Constants, P1003.1b-1993, p. 262 */ |
#define CLOCK_REALTIME (clockid_t)1 |
/* Flag indicating time is "absolute" with respect to the clock |
associated with a time. */ |
#define TIMER_ABSTIME 4 |
/* Manifest Constants, P1003.4b/D8, p. 55 */ |
#if defined(_POSIX_CPUTIME) |
/* When used in a clock or timer function call, this is interpreted as |
the identifier of the CPU_time clock associated with the PROCESS |
making the function call. */ |
#define CLOCK_PROCESS_CPUTIME_ID (clockid_t)2 |
#endif |
#if defined(_POSIX_THREAD_CPUTIME) |
/* When used in a clock or timer function call, this is interpreted as |
the identifier of the CPU_time clock associated with the THREAD |
making the function call. */ |
#define CLOCK_THREAD_CPUTIME_ID (clockid_t)3 |
#endif |
#if defined(_POSIX_MONOTONIC_CLOCK) |
/* The identifier for the system-wide monotonic clock, which is defined |
* as a clock whose value cannot be set via clock_settime() and which |
* cannot have backward clock jumps. */ |
#define CLOCK_MONOTONIC (clockid_t)4 |
#endif |
#if defined(_POSIX_CPUTIME) |
/* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */ |
int _EXFUN(clock_getcpuclockid, (pid_t pid, clockid_t *clock_id)); |
#endif /* _POSIX_CPUTIME */ |
#if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME) |
/* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */ |
int _EXFUN(clock_setenable_attr, (clockid_t clock_id, int attr)); |
int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr)); |
#endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* _TIME_H_ */ |
/contrib/sdk/sources/libc/include/unctrl.h |
---|
0,0 → 1,46 |
/* From curses.h. */ |
/* |
* Copyright (c) 1981, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#ifndef _UNCTRL_H_ |
#define _UNCTRL_H_ |
#include <_ansi.h> |
#define unctrl(c) __unctrl[(c) & 0xff] |
#define unctrllen(ch) __unctrllen[(ch) & 0xff] |
extern __IMPORT _CONST char * _CONST __unctrl[256]; /* Control strings. */ |
extern __IMPORT _CONST char __unctrllen[256]; /* Control strings length. */ |
#endif /* _UNCTRL_H_ */ |
/contrib/sdk/sources/libc/include/unistd.h |
---|
0,0 → 1,6 |
#ifndef _UNISTD_H_ |
#define _UNISTD_H_ |
# include <sys/unistd.h> |
#endif /* _UNISTD_H_ */ |
/contrib/sdk/sources/libc/include/utime.h |
---|
0,0 → 1,12 |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <_ansi.h> |
/* The utime function is defined in libc/sys/<arch>/sys if it exists. */ |
#include <sys/utime.h> |
#ifdef __cplusplus |
} |
#endif |
/contrib/sdk/sources/libc/include/utmp.h |
---|
0,0 → 1,8 |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include <sys/utmp.h> |
#ifdef __cplusplus |
} |
#endif |
/contrib/sdk/sources/libc/include/wchar.h |
---|
0,0 → 1,195 |
#ifndef _WCHAR_H_ |
#define _WCHAR_H_ |
#include <_ansi.h> |
#include <sys/reent.h> |
#define __need_size_t |
#define __need_wchar_t |
#define __need_wint_t |
#include <stddef.h> |
#define __need___va_list |
#include <stdarg.h> |
/* For _mbstate_t definition. */ |
#include <sys/_types.h> |
/* For __STDC_ISO_10646__ */ |
#include <sys/features.h> |
#ifndef NULL |
#define NULL 0 |
#endif |
#ifndef WEOF |
# define WEOF ((wint_t)-1) |
#endif |
#ifndef WCHAR_MIN |
#define WCHAR_MIN 0 |
#endif |
#ifndef WCHAR_MAX |
#ifdef __WCHAR_MAX__ |
#define WCHAR_MAX __WCHAR_MAX__ |
#else |
#define WCHAR_MAX 0x7fffffffu |
#endif |
#endif |
_BEGIN_STD_C |
/* As required by POSIX.1-2008, declare tm as incomplete type. |
The actual definition is in time.h. */ |
struct tm; |
#ifndef _MBSTATE_T |
#define _MBSTATE_T |
typedef _mbstate_t mbstate_t; |
#endif /* _MBSTATE_T */ |
wint_t _EXFUN(btowc, (int)); |
int _EXFUN(wctob, (wint_t)); |
size_t _EXFUN(mbrlen, (const char * , size_t, mbstate_t *)); |
size_t _EXFUN(mbrtowc, (wchar_t * , const char * , size_t, mbstate_t *)); |
size_t _EXFUN(_mbrtowc_r, (struct _reent *, wchar_t * , const char * , |
size_t, mbstate_t *)); |
int _EXFUN(mbsinit, (const mbstate_t *)); |
size_t _EXFUN(mbsnrtowcs, (wchar_t * , const char ** , size_t, size_t, |
mbstate_t *)); |
size_t _EXFUN(_mbsnrtowcs_r, (struct _reent *, wchar_t * , const char ** , |
size_t, size_t, mbstate_t *)); |
size_t _EXFUN(mbsrtowcs, (wchar_t * , const char ** , size_t, mbstate_t *)); |
size_t _EXFUN(_mbsrtowcs_r, (struct _reent *, wchar_t * , const char ** , size_t, mbstate_t *)); |
size_t _EXFUN(wcrtomb, (char * , wchar_t, mbstate_t *)); |
size_t _EXFUN(_wcrtomb_r, (struct _reent *, char * , wchar_t, mbstate_t *)); |
size_t _EXFUN(wcsnrtombs, (char * , const wchar_t ** , size_t, size_t, |
mbstate_t *)); |
size_t _EXFUN(_wcsnrtombs_r, (struct _reent *, char * , const wchar_t ** , |
size_t, size_t, mbstate_t *)); |
size_t _EXFUN(wcsrtombs, (char * , const wchar_t ** , size_t, mbstate_t *)); |
size_t _EXFUN(_wcsrtombs_r, (struct _reent *, char * , const wchar_t ** , |
size_t, mbstate_t *)); |
int _EXFUN(wcscasecmp, (const wchar_t *, const wchar_t *)); |
wchar_t *_EXFUN(wcscat, (wchar_t * , const wchar_t *)); |
wchar_t *_EXFUN(wcschr, (const wchar_t *, wchar_t)); |
int _EXFUN(wcscmp, (const wchar_t *, const wchar_t *)); |
int _EXFUN(wcscoll, (const wchar_t *, const wchar_t *)); |
wchar_t *_EXFUN(wcscpy, (wchar_t * , const wchar_t *)); |
wchar_t *_EXFUN(wcpcpy, (wchar_t * , const wchar_t *)); |
wchar_t *_EXFUN(wcsdup, (const wchar_t *)); |
wchar_t *_EXFUN(_wcsdup_r, (struct _reent *, const wchar_t * )); |
size_t _EXFUN(wcscspn, (const wchar_t *, const wchar_t *)); |
size_t _EXFUN(wcsftime, (wchar_t *, size_t, const wchar_t *, const struct tm *)); |
size_t _EXFUN(wcslcat, (wchar_t *, const wchar_t *, size_t)); |
size_t _EXFUN(wcslcpy, (wchar_t *, const wchar_t *, size_t)); |
size_t _EXFUN(wcslen, (const wchar_t *)); |
int _EXFUN(wcsncasecmp, (const wchar_t *, const wchar_t *, size_t)); |
wchar_t *_EXFUN(wcsncat, (wchar_t * , const wchar_t * , size_t)); |
int _EXFUN(wcsncmp, (const wchar_t *, const wchar_t *, size_t)); |
wchar_t *_EXFUN(wcsncpy, (wchar_t * , const wchar_t * , size_t)); |
wchar_t *_EXFUN(wcpncpy, (wchar_t * , const wchar_t * , size_t)); |
size_t _EXFUN(wcsnlen, (const wchar_t *, size_t)); |
wchar_t *_EXFUN(wcspbrk, (const wchar_t *, const wchar_t *)); |
wchar_t *_EXFUN(wcsrchr, (const wchar_t *, wchar_t)); |
size_t _EXFUN(wcsspn, (const wchar_t *, const wchar_t *)); |
wchar_t *_EXFUN(wcsstr, (const wchar_t *, const wchar_t *)); |
wchar_t *_EXFUN(wcstok, (wchar_t *, const wchar_t *, wchar_t **)); |
double _EXFUN(wcstod, (const wchar_t *, wchar_t **)); |
double _EXFUN(_wcstod_r, (struct _reent *, const wchar_t *, wchar_t **)); |
float _EXFUN(wcstof, (const wchar_t *, wchar_t **)); |
float _EXFUN(_wcstof_r, (struct _reent *, const wchar_t *, wchar_t **)); |
int _EXFUN(wcswidth, (const wchar_t *, size_t)); |
size_t _EXFUN(wcsxfrm, (wchar_t *, const wchar_t *, size_t)); |
int _EXFUN(wcwidth, (const wchar_t)); |
wchar_t *_EXFUN(wmemchr, (const wchar_t *, wchar_t, size_t)); |
int _EXFUN(wmemcmp, (const wchar_t *, const wchar_t *, size_t)); |
wchar_t *_EXFUN(wmemcpy, (wchar_t * , const wchar_t * , size_t)); |
wchar_t *_EXFUN(wmemmove, (wchar_t *, const wchar_t *, size_t)); |
wchar_t *_EXFUN(wmemset, (wchar_t *, wchar_t, size_t)); |
long _EXFUN(wcstol, (const wchar_t *, wchar_t **, int)); |
long long _EXFUN(wcstoll, (const wchar_t *, wchar_t **, int)); |
unsigned long _EXFUN(wcstoul, (const wchar_t *, wchar_t **, int)); |
unsigned long long _EXFUN(wcstoull, (const wchar_t *, wchar_t **, int)); |
long _EXFUN(_wcstol_r, (struct _reent *, const wchar_t *, wchar_t **, int)); |
long long _EXFUN(_wcstoll_r, (struct _reent *, const wchar_t *, wchar_t **, int)); |
unsigned long _EXFUN(_wcstoul_r, (struct _reent *, const wchar_t *, wchar_t **, int)); |
unsigned long long _EXFUN(_wcstoull_r, (struct _reent *, const wchar_t *, wchar_t **, int)); |
wint_t _EXFUN(fgetwc, (__FILE *)); |
wchar_t *_EXFUN(fgetws, (wchar_t *, int, __FILE *)); |
wint_t _EXFUN(fputwc, (wchar_t, __FILE *)); |
int _EXFUN(fputws, (const wchar_t *, __FILE *)); |
int _EXFUN (fwide, (__FILE *, int)); |
wint_t _EXFUN (getwc, (__FILE *)); |
wint_t _EXFUN (getwchar, (void)); |
wint_t _EXFUN(putwc, (wchar_t, __FILE *)); |
wint_t _EXFUN(putwchar, (wchar_t)); |
wint_t _EXFUN (ungetwc, (wint_t wc, __FILE *)); |
wint_t _EXFUN(_fgetwc_r, (struct _reent *, __FILE *)); |
wchar_t *_EXFUN(_fgetws_r, (struct _reent *, wchar_t *, int, __FILE *)); |
wint_t _EXFUN(_fputwc_r, (struct _reent *, wchar_t, __FILE *)); |
int _EXFUN(_fputws_r, (struct _reent *, const wchar_t *, __FILE *)); |
int _EXFUN (_fwide_r, (struct _reent *, __FILE *, int)); |
wint_t _EXFUN (_getwc_r, (struct _reent *, __FILE *)); |
wint_t _EXFUN (_getwchar_r, (struct _reent *ptr)); |
wint_t _EXFUN(_putwc_r, (struct _reent *, wchar_t, __FILE *)); |
wint_t _EXFUN(_putwchar_r, (struct _reent *, wchar_t)); |
wint_t _EXFUN (_ungetwc_r, (struct _reent *, wint_t wc, __FILE *)); |
__FILE *_EXFUN (open_wmemstream, (wchar_t **, size_t *)); |
__FILE *_EXFUN (_open_wmemstream_r, (struct _reent *, wchar_t **, size_t *)); |
#ifndef __VALIST |
#ifdef __GNUC__ |
#define __VALIST __gnuc_va_list |
#else |
#define __VALIST char* |
#endif |
#endif |
int _EXFUN(fwprintf, (__FILE *, const wchar_t *, ...)); |
int _EXFUN(swprintf, (wchar_t *, size_t, const wchar_t *, ...)); |
int _EXFUN(vfwprintf, (__FILE *, const wchar_t *, __VALIST)); |
int _EXFUN(vswprintf, (wchar_t *, size_t, const wchar_t *, __VALIST)); |
int _EXFUN(vwprintf, (const wchar_t *, __VALIST)); |
int _EXFUN(wprintf, (const wchar_t *, ...)); |
int _EXFUN(_fwprintf_r, (struct _reent *, __FILE *, const wchar_t *, ...)); |
int _EXFUN(_swprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, ...)); |
int _EXFUN(_vfwprintf_r, (struct _reent *, __FILE *, const wchar_t *, __VALIST)); |
int _EXFUN(_vswprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, __VALIST)); |
int _EXFUN(_vwprintf_r, (struct _reent *, const wchar_t *, __VALIST)); |
int _EXFUN(_wprintf_r, (struct _reent *, const wchar_t *, ...)); |
int _EXFUN(fwscanf, (__FILE *, const wchar_t *, ...)); |
int _EXFUN(swscanf, (const wchar_t *, const wchar_t *, ...)); |
int _EXFUN(vfwscanf, (__FILE *, const wchar_t *, __VALIST)); |
int _EXFUN(vswscanf, (const wchar_t *, const wchar_t *, __VALIST)); |
int _EXFUN(vwscanf, (const wchar_t *, __VALIST)); |
int _EXFUN(wscanf, (const wchar_t *, ...)); |
int _EXFUN(_fwscanf_r, (struct _reent *, __FILE *, const wchar_t *, ...)); |
int _EXFUN(_swscanf_r, (struct _reent *, const wchar_t *, const wchar_t *, ...)); |
int _EXFUN(_vfwscanf_r, (struct _reent *, __FILE *, const wchar_t *, __VALIST)); |
int _EXFUN(_vswscanf_r, (struct _reent *, const wchar_t *, const wchar_t *, __VALIST)); |
int _EXFUN(_vwscanf_r, (struct _reent *, const wchar_t *, __VALIST)); |
int _EXFUN(_wscanf_r, (struct _reent *, const wchar_t *, ...)); |
#define getwc(fp) fgetwc(fp) |
#define putwc(wc,fp) fputwc((wc), (fp)) |
#ifndef _REENT_ONLY |
#define getwchar() fgetwc(_REENT->_stdin) |
#define putwchar(wc) fputwc((wc), _REENT->_stdout) |
#else |
#define getwchar() fgetwc(_impure_ptr->_stdin) |
#define putwchar(wc) fputwc((wc), _impure_ptr->_stdout) |
#endif |
_END_STD_C |
#endif /* _WCHAR_H_ */ |
/contrib/sdk/sources/libc/include/wctype.h |
---|
0,0 → 1,47 |
#ifndef _WCTYPE_H_ |
#define _WCTYPE_H_ |
#include <_ansi.h> |
#include <sys/_types.h> |
#define __need_wint_t |
#include <stddef.h> |
#ifndef WEOF |
# define WEOF ((wint_t)-1) |
#endif |
_BEGIN_STD_C |
#ifndef _WCTYPE_T |
#define _WCTYPE_T |
typedef int wctype_t; |
#endif |
#ifndef _WCTRANS_T |
#define _WCTRANS_T |
typedef int wctrans_t; |
#endif |
int _EXFUN(iswalpha, (wint_t)); |
int _EXFUN(iswalnum, (wint_t)); |
int _EXFUN(iswblank, (wint_t)); |
int _EXFUN(iswcntrl, (wint_t)); |
int _EXFUN(iswctype, (wint_t, wctype_t)); |
int _EXFUN(iswdigit, (wint_t)); |
int _EXFUN(iswgraph, (wint_t)); |
int _EXFUN(iswlower, (wint_t)); |
int _EXFUN(iswprint, (wint_t)); |
int _EXFUN(iswpunct, (wint_t)); |
int _EXFUN(iswspace, (wint_t)); |
int _EXFUN(iswupper, (wint_t)); |
int _EXFUN(iswxdigit, (wint_t)); |
wint_t _EXFUN(towctrans, (wint_t, wctrans_t)); |
wint_t _EXFUN(towupper, (wint_t)); |
wint_t _EXFUN(towlower, (wint_t)); |
wctrans_t _EXFUN(wctrans, (const char *)); |
wctype_t _EXFUN(wctype, (const char *)); |
_END_STD_C |
#endif /* _WCTYPE_H_ */ |
/contrib/sdk/sources/libc/include/wordexp.h |
---|
0,0 → 1,53 |
/* Copyright (C) 2002, 2010 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#ifndef _WORDEXP_H_ |
#define _WORDEXP_H_ |
#include <sys/types.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
struct _wordexp_t |
{ |
size_t we_wordc; /* Count of words matched by words. */ |
char **we_wordv; /* Pointer to list of expanded words. */ |
size_t we_offs; /* Slots to reserve at the beginning of we_wordv. */ |
}; |
typedef struct _wordexp_t wordexp_t; |
#define WRDE_DOOFFS 0x0001 /* Use we_offs. */ |
#define WRDE_APPEND 0x0002 /* Append to output from previous call. */ |
#define WRDE_NOCMD 0x0004 /* Don't perform command substitution. */ |
#define WRDE_REUSE 0x0008 /* pwordexp points to a wordexp_t struct returned from |
a previous successful call to wordexp. */ |
#define WRDE_SHOWERR 0x0010 /* Print error messages to stderr. */ |
#define WRDE_UNDEF 0x0020 /* Report attempt to expand undefined shell variable. */ |
enum { |
WRDE_SUCCESS, |
WRDE_NOSPACE, |
WRDE_BADCHAR, |
WRDE_BADVAL, |
WRDE_CMDSUB, |
WRDE_SYNTAX, |
WRDE_NOSYS |
}; |
/* Note: This implementation of wordexp requires a version of bash |
that supports the --wordexp and --protected arguments to be present |
on the system. It does not support the WRDE_UNDEF flag. */ |
int wordexp(const char *, wordexp_t *, int); |
void wordfree(wordexp_t *); |
#ifdef __cplusplus |
} |
#endif |
#endif /* _WORDEXP_H_ */ |
/contrib/sdk/sources/libc/pe/loader.c |
---|
0,0 → 1,768 |
#include <stdint.h> |
#include <stdio.h> |
#include <string.h> |
#include <alloca.h> |
#include <malloc.h> |
#include <setjmp.h> |
#include <envz.h> |
#include <kos32sys.h> |
#include "list.h" |
#include "pe.h" |
#define unlikely(x) __builtin_expect(!!(x), 0) |
//#define DBG(format,...) printf(format,##__VA_ARGS__) |
#define DBG(format,...) |
void init_loader(void *libc_image); |
void* create_image(void *raw); |
int link_image(void *img_base, PIMAGE_IMPORT_DESCRIPTOR imp); |
extern char* __appenv; |
extern int __appenv_size; |
typedef struct tag_module module_t; |
struct app_hdr |
{ |
char banner[8]; |
int version; |
int start; |
int iend; |
int memsize; |
int stacktop; |
char *cmdline; |
char *path; |
int reserved; |
void *__idata_start; |
void *__idata_end; |
void (*main)(int argc, char **argv, char **envp); |
}; |
struct tag_module |
{ |
struct list_head list; |
char *img_name; |
char *img_path; |
uint32_t refcount; |
void *start; |
uint32_t end; |
void *entry; |
PIMAGE_NT_HEADERS32 img_hdr; |
PIMAGE_SECTION_HEADER img_sec; |
PIMAGE_EXPORT_DIRECTORY img_exp; |
}; |
typedef struct |
{ |
struct list_head list; |
char *path; |
int path_len; |
}dll_path_t; |
module_t* load_library(const char *name); |
LIST_HEAD(path_list); |
static module_t libc_dll; |
static char libc_name[] = "libc.dll"; |
static char libc_path[] = "/KolibriOS/lib/libc.dll"; |
static inline int IsPowerOf2(uint32_t val) |
{ |
if(val == 0) |
return 0; |
return (val & (val - 1)) == 0; |
} |
int validate_pe(void *raw, size_t raw_size, int is_exec) |
{ |
PIMAGE_DOS_HEADER dos; |
PIMAGE_NT_HEADERS32 nt; |
dos = (PIMAGE_DOS_HEADER)raw; |
if( !raw || raw_size < sizeof(IMAGE_DOS_HEADER) ) |
return 0; |
if( dos->e_magic != IMAGE_DOS_SIGNATURE || dos->e_lfanew <= 0) |
return 0; |
nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew); |
if( (uint32_t)nt < (uint32_t)raw) |
return 0; |
if(nt->Signature != IMAGE_NT_SIGNATURE) |
return 0; |
if(nt->FileHeader.Machine != IMAGE_FILE_MACHINE_I386) |
return 0; |
if(is_exec && (nt->FileHeader.Characteristics & IMAGE_FILE_DLL)) |
return 0; |
if(nt->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC) |
return 0; |
if( is_exec && nt->OptionalHeader.ImageBase != 0) |
return 0; |
if(nt->OptionalHeader.SectionAlignment < 4096) |
{ |
if(nt->OptionalHeader.FileAlignment != nt->OptionalHeader.SectionAlignment) |
return 0; |
} |
else if(nt->OptionalHeader.SectionAlignment < nt->OptionalHeader.FileAlignment) |
return 0; |
if(!IsPowerOf2(nt->OptionalHeader.SectionAlignment) || |
!IsPowerOf2(nt->OptionalHeader.FileAlignment)) |
return 0; |
if(nt->FileHeader.NumberOfSections > 96) |
return 0; |
return 1; |
} |
void init_loader(void *libc_image) |
{ |
PIMAGE_DOS_HEADER dos; |
PIMAGE_NT_HEADERS32 nt; |
PIMAGE_EXPORT_DIRECTORY exp; |
struct app_hdr *header = NULL; |
dll_path_t *path; |
int len; |
char *p; |
#if 0 |
if(__appenv_size) |
{ |
char *env; |
env = envz_get(__appenv, __appenv_size, "PATH"); |
if( env ) |
{ |
while( *env ) |
{ |
p = env; |
while(*p) |
{ |
if( *p == 0x0D) |
break; |
else if( *p == 0x0A) |
break; |
else if( *p == ':') |
break; |
p++; |
}; |
len = p-env; |
if(len) |
{ |
char *p1; |
p1 = (char*)malloc(len+1); |
memcpy(p1, env, len); |
p1[len]=0; |
path = (dll_path_t*)malloc(sizeof(dll_path_t)); |
INIT_LIST_HEAD(&path->list); |
path->path = p1; |
path->path_len = len; |
DBG("add libraries path %s\n", path->path); |
list_add_tail(&path->list, &path_list); |
}; |
if(*p == ':') |
{ |
env = p+1; |
continue; |
} |
else break; |
}; |
}; |
}; |
#endif |
len = strrchr(header->path, '/') - header->path+1; |
p = (char*)malloc(len+1); |
memcpy(p, header->path, len); |
p[len]=0; |
path = (dll_path_t*)malloc(sizeof(dll_path_t)); |
INIT_LIST_HEAD(&path->list); |
path->path = p; |
path->path_len = len; |
DBG("add libraries path %s\n", path->path); |
list_add_tail(&path->list, &path_list); |
path = (dll_path_t*)malloc(sizeof(dll_path_t)); |
INIT_LIST_HEAD(&path->list); |
path->path = "/kolibrios/lib/"; |
path->path_len = 15; /* FIXME */ |
DBG("add libraries path %s\n", path->path); |
list_add_tail(&path->list, &path_list); |
INIT_LIST_HEAD(&libc_dll.list); |
libc_dll.img_name = libc_name; |
libc_dll.img_path = libc_path; |
libc_dll.refcount = 1; |
dos = (PIMAGE_DOS_HEADER)libc_image; |
nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew); |
exp = MakePtr(PIMAGE_EXPORT_DIRECTORY, libc_image, |
nt->OptionalHeader.DataDirectory[0].VirtualAddress); |
libc_dll.start = libc_image; |
libc_dll.end = MakePtr(uint32_t,libc_image, nt->OptionalHeader.SizeOfImage); |
libc_dll.img_hdr = nt; |
libc_dll.img_sec = MakePtr(PIMAGE_SECTION_HEADER,nt, sizeof(IMAGE_NT_HEADERS32)); |
libc_dll.img_exp = MakePtr(PIMAGE_EXPORT_DIRECTORY,libc_image, |
nt->OptionalHeader.DataDirectory[0].VirtualAddress); |
}; |
static inline void sec_copy(void *dst, void *src, size_t len) |
{ |
__asm__ __volatile__ ( |
"shrl $2, %%ecx \n\t" |
"rep movsl" |
: |
:"c"(len),"S"(src),"D"(dst) |
:"cc"); |
__asm__ __volatile__ ( |
"" |
:::"ecx","esi","edi"); |
}; |
void* create_image(void *raw) |
{ |
PIMAGE_DOS_HEADER dos; |
PIMAGE_NT_HEADERS32 nt; |
PIMAGE_SECTION_HEADER img_sec; |
void *img_base; |
uint32_t sec_align; |
int i; |
dos = (PIMAGE_DOS_HEADER)raw; |
nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew); |
img_base = user_alloc(nt->OptionalHeader.SizeOfImage); |
if(unlikely(img_base == NULL)) |
return 0; |
sec_copy(img_base, raw, nt->OptionalHeader.SizeOfHeaders); |
img_sec = MakePtr(PIMAGE_SECTION_HEADER, nt, sizeof(IMAGE_NT_HEADERS32)); |
sec_align = nt->OptionalHeader.SectionAlignment; |
for(i=0; i< nt->FileHeader.NumberOfSections; i++) |
{ |
void *src_ptr; |
void *dest_ptr; |
size_t sec_size; |
if ( img_sec->SizeOfRawData && img_sec->PointerToRawData ) |
{ |
src_ptr = MakePtr(void*, raw, img_sec->PointerToRawData); |
dest_ptr = MakePtr(void*, img_base, img_sec->VirtualAddress); |
sec_copy(dest_ptr, src_ptr, img_sec->SizeOfRawData); |
}; |
img_sec++; |
}; |
if(nt->OptionalHeader.DataDirectory[5].Size) |
{ |
PIMAGE_BASE_RELOCATION reloc; |
uint32_t delta = (uint32_t)img_base - nt->OptionalHeader.ImageBase; |
reloc = MakePtr(PIMAGE_BASE_RELOCATION, img_base, |
nt->OptionalHeader.DataDirectory[5].VirtualAddress); |
while ( reloc->SizeOfBlock != 0 ) |
{ |
uint32_t cnt; |
uint16_t *entry; |
uint16_t reltype; |
uint32_t offs; |
cnt = (reloc->SizeOfBlock - sizeof(*reloc))/sizeof(uint16_t); |
entry = MakePtr( uint16_t*, reloc, sizeof(*reloc) ); |
for ( i=0; i < cnt; i++ ) |
{ |
uint16_t *p16; |
uint32_t *p32; |
reltype = (*entry & 0xF000) >> 12; |
offs = (*entry & 0x0FFF) + reloc->VirtualAddress; |
switch(reltype) |
{ |
case 1: |
p16 = MakePtr(uint16_t*, img_base, offs); |
*p16+= (uint16_t)(delta>>16); |
break; |
case 2: |
p16 = MakePtr(uint16_t*, img_base, offs); |
*p16+= (uint16_t)delta; |
break; |
case 3: |
p32 = MakePtr(uint32_t*, img_base, offs); |
*p32+= delta; |
} |
entry++; |
} |
reloc = MakePtr(PIMAGE_BASE_RELOCATION, reloc,reloc->SizeOfBlock); |
} |
}; |
return img_base; |
}; |
//static jmp_buf loader_env; |
//static loader_recursion; |
int link_image(void *img_base, PIMAGE_IMPORT_DESCRIPTOR imp) |
{ |
static jmp_buf loader_env; |
static recursion = -1; |
int warn = 0; |
recursion++; |
if( !recursion ) |
{ |
if( unlikely(setjmp(loader_env) != 0)) |
{ |
recursion = -1; |
return 0; |
}; |
}; |
while ( imp->Name ) |
{ |
PIMAGE_DOS_HEADER expdos; |
PIMAGE_NT_HEADERS32 expnt; |
PIMAGE_EXPORT_DIRECTORY exp; |
PIMAGE_THUNK_DATA32 thunk; |
void **iat; |
char *libname; |
uint32_t *exp_functions; |
uint16_t *exp_ordinals; |
char **exp_names; |
const module_t *api; |
libname=MakePtr(char*,imp->Name, img_base); |
DBG("import from %s\n",libname); |
api = load_library(libname); |
if(unlikely(api == NULL)) |
{ |
printf("library %s not found\n", libname); |
longjmp(loader_env, 1); |
} |
iat = MakePtr(void**,imp->FirstThunk, img_base); |
if(imp->OriginalFirstThunk !=0 ) |
{ |
thunk = MakePtr(PIMAGE_THUNK_DATA32,imp->OriginalFirstThunk, img_base); |
} |
else |
{ |
thunk = MakePtr(PIMAGE_THUNK_DATA32,imp->FirstThunk, img_base); |
}; |
exp = api->img_exp; |
exp_functions = MakePtr(uint32_t*,exp->AddressOfFunctions,api->start); |
exp_ordinals = MakePtr(uint16_t*, exp->AddressOfNameOrdinals,api->start); |
exp_names = MakePtr(char**, exp->AddressOfNames,api->start); |
while ( thunk->u1.AddressOfData != 0 ) |
{ |
PIMAGE_IMPORT_BY_NAME imp_name; |
if (thunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) |
{ |
// ordinal = (*func_list) & 0x7fffffff; |
// *ImportAddressList = LdrGetExportByOrdinal(ImportedModule->DllBase, Ordinal); |
// if ((*ImportAddressList) == NULL) |
// { |
// DPRINT1("Failed to import #%ld from %wZ\n", Ordinal, &ImportedModule->FullDllName); |
// RtlpRaiseImportNotFound(NULL, Ordinal, &ImportedModule->FullDllName); |
// return STATUS_ENTRYPOINT_NOT_FOUND; |
// } |
} |
else |
{ |
char *export_name; |
uint16_t ordinal; |
void *function; |
uint32_t minn; |
uint32_t maxn; |
imp_name = MakePtr(PIMAGE_IMPORT_BY_NAME, |
thunk->u1.AddressOfData, img_base); |
*iat = NULL; |
DBG("import %s", imp_name->Name); |
if(imp_name->Hint < exp->NumberOfNames) |
{ |
export_name = MakePtr(char*,exp_names[imp_name->Hint], |
api->start); |
if(strcmp(imp_name->Name, export_name) == 0) |
{ |
ordinal = exp_ordinals[imp_name->Hint]; |
function = MakePtr(void*,exp_functions[ordinal], api->start); |
if((uint32_t)function >= (uint32_t)exp) |
{ |
printf("forward %s\n", function); |
warn=1; |
} |
else |
{ |
DBG(" \t\tat %x\n", function); |
*iat = function; |
}; |
thunk++; // Advance to next thunk |
iat++; |
continue; |
}; |
}; |
minn = 0; |
maxn = exp->NumberOfNames - 1; |
while (minn <= maxn) |
{ |
int mid; |
int res; |
mid = (minn + maxn) / 2; |
export_name = MakePtr(char*,exp_names[mid],api->start); |
res = strcmp(export_name, imp_name->Name); |
if (res == 0) |
{ |
ordinal = exp_ordinals[mid]; |
function = MakePtr(void*,exp_functions[ordinal], api->start); |
if((uint32_t)function >= (uint32_t)exp) |
{ |
printf("forward %s\n", function); |
warn=1; |
} |
else |
{ |
DBG(" \t\tat %x\n", function); |
*iat = function; |
}; |
break; |
} |
else if (minn == maxn) |
{ |
printf(" unresolved %s\n",imp_name->Name); |
warn=1; |
break; |
} |
else if (res > 0) |
{ |
maxn = mid - 1; |
} |
else |
{ |
minn = mid + 1; |
} |
}; |
}; |
thunk++; // Advance to next thunk |
iat++; |
} |
imp++; // advance to next IMAGE_IMPORT_DESCRIPTOR |
}; |
recursion--; |
if ( !warn ) |
return 1; |
else |
return 0; |
} |
int link_app() |
{ |
struct app_hdr *header = NULL; |
PIMAGE_IMPORT_DESCRIPTOR imp; |
imp = (PIMAGE_IMPORT_DESCRIPTOR)header->__idata_start; |
return link_image(NULL, imp); |
} |
void* get_entry_point(void *raw) |
{ |
PIMAGE_DOS_HEADER dos; |
PIMAGE_NT_HEADERS32 nt; |
dos = (PIMAGE_DOS_HEADER)raw; |
nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew); |
return MakePtr(void*, raw, nt->OptionalHeader.AddressOfEntryPoint); |
}; |
void *get_proc_address(module_t *module, char *proc_name) |
{ |
PIMAGE_DOS_HEADER expdos; |
PIMAGE_NT_HEADERS32 expnt; |
PIMAGE_EXPORT_DIRECTORY exp; |
uint32_t *exp_functions; |
uint16_t *exp_ordinals; |
char **exp_names; |
int minn, maxn; |
char *export_name; |
uint16_t ordinal; |
void *function=NULL; |
exp = module->img_exp; |
exp_functions = MakePtr(uint32_t*,exp->AddressOfFunctions,module->start); |
exp_ordinals = MakePtr(uint16_t*, exp->AddressOfNameOrdinals,module->start); |
exp_names = MakePtr(char**, exp->AddressOfNames,module->start); |
minn = 0; |
maxn = exp->NumberOfNames - 1; |
while (minn <= maxn) |
{ |
int mid; |
int res; |
mid = (minn + maxn) / 2; |
export_name = MakePtr(char*,exp_names[mid],module->start); |
res = strcmp(export_name, proc_name); |
if (res == 0) |
{ |
ordinal = exp_ordinals[mid]; |
function = MakePtr(void*,exp_functions[ordinal], module->start); |
if((uint32_t)function >= (uint32_t)exp) |
{ |
printf("forward %s\n", function); |
} |
else |
{ |
DBG(" \t\tat %x\n", function); |
}; |
break; |
} |
else if (minn == maxn) |
{ |
DBG(" unresolved %s\n",proc_name); |
break; |
} |
else if (res > 0) |
{ |
maxn = mid - 1; |
} |
else |
{ |
minn = mid + 1; |
} |
}; |
return function; |
}; |
static void *load_lib_internal(const char *path) |
{ |
PIMAGE_DOS_HEADER dos; |
PIMAGE_NT_HEADERS32 nt; |
PIMAGE_EXPORT_DIRECTORY exp; |
ufile_t uf; |
void *raw_img; |
size_t raw_size; |
void *img_base = NULL; |
uf = load_file(path); |
raw_img = uf.data; |
raw_size = uf.size; |
if(raw_img == NULL) |
return NULL; |
if( validate_pe(raw_img, raw_size, 0) == 0) |
{ |
printf("invalide module %s\n", path); |
user_free(raw_img); |
return NULL; |
}; |
img_base = create_image(raw_img); |
user_free(raw_img); |
if( unlikely(img_base == NULL) ) |
printf("cannot create image %s\n",path); |
return img_base; |
} |
module_t* load_library(const char *name) |
{ |
PIMAGE_DOS_HEADER dos; |
PIMAGE_NT_HEADERS32 nt; |
PIMAGE_EXPORT_DIRECTORY exp; |
module_t *module, *mod = &libc_dll; |
dll_path_t *dllpath; |
char *path; |
int len; |
char *libname, *tmp; |
void *img_base; |
/* check for already loaded libraries */ |
tmp = strrchr(name, '/'); |
libname = path = tmp != NULL ? tmp+1 : (char*)name; |
// printf("path %s\n", path); |
do |
{ |
if( !strncmp(path, mod->img_name, 16)) |
return mod; |
mod = (module_t*)mod->list.next; |
}while(mod != &libc_dll); |
if(name[0] == '/') |
{ |
path = (char*)name; |
img_base = load_lib_internal(path); |
} |
else |
{ |
len = strlen(libname); |
list_for_each_entry(dllpath, &path_list, list) |
{ |
path = alloca(len+dllpath->path_len+1); |
memcpy(path, dllpath->path, dllpath->path_len); |
memcpy(path+dllpath->path_len, libname, len); |
path[len+dllpath->path_len]=0; |
// printf("%s\n", path); |
img_base = load_lib_internal(path); |
if( unlikely(img_base == NULL) ) |
continue; |
}; |
} |
if( unlikely(img_base == NULL) ) |
{ |
printf("unable to load %s\n", name); |
return NULL; |
}; |
module = (module_t*)malloc(sizeof(module_t)); |
if(unlikely(module == NULL)) |
{ |
printf("%s epic fail: no enough memory\n",__FUNCTION__); |
goto err1; |
} |
INIT_LIST_HEAD(&module->list); |
module->img_name = strdup(libname); |
module->img_path = strdup(path); |
module->start = img_base; |
module->entry = get_entry_point(img_base); |
module->refcount = 1; |
dos = (PIMAGE_DOS_HEADER)img_base; |
nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew); |
exp = MakePtr(PIMAGE_EXPORT_DIRECTORY, img_base, |
nt->OptionalHeader.DataDirectory[0].VirtualAddress); |
module->end = MakePtr(uint32_t,img_base, nt->OptionalHeader.SizeOfImage); |
module->img_hdr = nt; |
module->img_sec = MakePtr(PIMAGE_SECTION_HEADER,nt, sizeof(IMAGE_NT_HEADERS32)); |
module->img_exp = MakePtr(PIMAGE_EXPORT_DIRECTORY, img_base, |
nt->OptionalHeader.DataDirectory[0].VirtualAddress); |
list_add_tail(&module->list, &libc_dll.list); |
if(nt->OptionalHeader.DataDirectory[1].Size) |
{ |
PIMAGE_IMPORT_DESCRIPTOR imp; |
int (*dll_startup)(module_t *mod, uint32_t reason); |
imp = MakePtr(PIMAGE_IMPORT_DESCRIPTOR, img_base, |
nt->OptionalHeader.DataDirectory[1].VirtualAddress); |
if(link_image(img_base, imp) == 0) |
goto err2; |
dll_startup = get_proc_address(module, "DllStartup"); |
if( dll_startup ) |
{ |
if( 0 == dll_startup(module, 1)) |
goto err2; |
} |
}; |
// printf("module %s %p - %p\n", name, module->start, module->end); |
return module; |
err2: |
list_del(&module->list); |
free(module->img_name); |
free(module->img_path); |
free(module); |
err1: |
user_free(img_base); |
return NULL; |
}; |
/contrib/sdk/sources/libc/pe/crtloader.c |
---|
0,0 → 1,223 |
#include <stdint.h> |
#include <stdio.h> |
#include <string.h> |
#include <alloca.h> |
#include <malloc.h> |
#include <setjmp.h> |
#include <envz.h> |
#include <kos32sys.h> |
#include "list.h" |
#include "pe.h" |
#define unlikely(x) __builtin_expect(!!(x), 0) |
//#define DBG(format,...) printf(format,##__VA_ARGS__) |
#define DBG(format,...) |
static inline void sec_copy(void *dst, void *src, size_t len) |
{ |
__asm__ __volatile__ ( |
"shrl $2, %%ecx \n\t" |
"rep movsl" |
: |
:"c"(len),"S"(src),"D"(dst) |
:"cc"); |
__asm__ __volatile__ ( |
"" |
:::"ecx","esi","edi"); |
}; |
void* load_libc(); |
static inline int IsPowerOf2(uint32_t val) |
{ |
if(val == 0) |
return 0; |
return (val & (val - 1)) == 0; |
} |
int validate_pe(void *raw, size_t raw_size) |
{ |
PIMAGE_DOS_HEADER dos; |
PIMAGE_NT_HEADERS32 nt; |
dos = (PIMAGE_DOS_HEADER)raw; |
if( !raw || raw_size < sizeof(IMAGE_DOS_HEADER) ) |
return 0; |
if( dos->e_magic != IMAGE_DOS_SIGNATURE || dos->e_lfanew <= 0) |
return 0; |
nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew); |
if( (uint32_t)nt < (uint32_t)raw) |
return 0; |
if(nt->Signature != IMAGE_NT_SIGNATURE) |
return 0; |
if(nt->FileHeader.Machine != IMAGE_FILE_MACHINE_I386) |
return 0; |
if(nt->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC) |
return 0; |
if(nt->OptionalHeader.SectionAlignment < 4096) |
{ |
if(nt->OptionalHeader.FileAlignment != nt->OptionalHeader.SectionAlignment) |
return 0; |
} |
else if(nt->OptionalHeader.SectionAlignment < nt->OptionalHeader.FileAlignment) |
return 0; |
if(!IsPowerOf2(nt->OptionalHeader.SectionAlignment) || |
!IsPowerOf2(nt->OptionalHeader.FileAlignment)) |
return 0; |
if(nt->FileHeader.NumberOfSections > 96) |
return 0; |
return 1; |
} |
void* create_image(void *raw) |
{ |
PIMAGE_DOS_HEADER dos; |
PIMAGE_NT_HEADERS32 nt; |
PIMAGE_SECTION_HEADER img_sec; |
void *img_base; |
uint32_t sec_align; |
int i; |
dos = (PIMAGE_DOS_HEADER)raw; |
nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew); |
img_base = user_alloc(nt->OptionalHeader.SizeOfImage); |
if(unlikely(img_base == NULL)) |
return 0; |
sec_copy(img_base, raw, nt->OptionalHeader.SizeOfHeaders); |
img_sec = MakePtr(PIMAGE_SECTION_HEADER, nt, sizeof(IMAGE_NT_HEADERS32)); |
sec_align = nt->OptionalHeader.SectionAlignment; |
for(i=0; i< nt->FileHeader.NumberOfSections; i++) |
{ |
void *src_ptr; |
void *dest_ptr; |
size_t sec_size; |
if ( img_sec->SizeOfRawData && img_sec->PointerToRawData ) |
{ |
src_ptr = MakePtr(void*, raw, img_sec->PointerToRawData); |
dest_ptr = MakePtr(void*, img_base, img_sec->VirtualAddress); |
sec_copy(dest_ptr, src_ptr, img_sec->SizeOfRawData); |
}; |
img_sec++; |
}; |
if(nt->OptionalHeader.DataDirectory[5].Size) |
{ |
PIMAGE_BASE_RELOCATION reloc; |
uint32_t delta = (uint32_t)img_base - nt->OptionalHeader.ImageBase; |
reloc = MakePtr(PIMAGE_BASE_RELOCATION, img_base, |
nt->OptionalHeader.DataDirectory[5].VirtualAddress); |
while ( reloc->SizeOfBlock != 0 ) |
{ |
uint32_t cnt; |
uint16_t *entry; |
uint16_t reltype; |
uint32_t offs; |
cnt = (reloc->SizeOfBlock - sizeof(*reloc))/sizeof(uint16_t); |
entry = MakePtr( uint16_t*, reloc, sizeof(*reloc) ); |
for ( i=0; i < cnt; i++ ) |
{ |
uint16_t *p16; |
uint32_t *p32; |
reltype = (*entry & 0xF000) >> 12; |
offs = (*entry & 0x0FFF) + reloc->VirtualAddress; |
switch(reltype) |
{ |
case 1: |
p16 = MakePtr(uint16_t*, img_base, offs); |
*p16+= (uint16_t)(delta>>16); |
break; |
case 2: |
p16 = MakePtr(uint16_t*, img_base, offs); |
*p16+= (uint16_t)delta; |
break; |
case 3: |
p32 = MakePtr(uint32_t*, img_base, offs); |
*p32+= delta; |
} |
entry++; |
} |
reloc = MakePtr(PIMAGE_BASE_RELOCATION, reloc,reloc->SizeOfBlock); |
}; |
// printf("unmap base %p offset %x %d page(s)\n", |
// img_base, |
// nt->OptionalHeader.DataDirectory[5].VirtualAddress, |
// (nt->OptionalHeader.DataDirectory[5].Size+4095)>>12); |
user_unmap(img_base,nt->OptionalHeader.DataDirectory[5].VirtualAddress, |
nt->OptionalHeader.DataDirectory[5].Size); |
}; |
return img_base; |
}; |
void* get_entry_point(void *raw) |
{ |
PIMAGE_DOS_HEADER dos; |
PIMAGE_NT_HEADERS32 nt; |
dos = (PIMAGE_DOS_HEADER)raw; |
nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew); |
return MakePtr(void*, raw, nt->OptionalHeader.AddressOfEntryPoint); |
}; |
void* load_libc() |
{ |
void *raw_img; |
size_t raw_size; |
void *img_base = NULL; |
ufile_t uf; |
uf = load_file("/kolibrios/lib/libc.dll"); |
raw_img = uf.data; |
raw_size = uf.size; |
if(raw_img == NULL) |
return NULL; |
// printf("libc.dll raw %p, size %d\n", raw_img, raw_size); |
if(validate_pe(raw_img, raw_size) != 0) |
{ |
// printf("invalide libc.dll\n"); |
img_base = create_image(raw_img); |
}; |
user_free(raw_img); |
return img_base; |
} |
/contrib/sdk/sources/libc/pe/libc.asm |
---|
0,0 → 1,284 |
struc APP_HEADER_02 |
{ .banner dq ? |
.version dd ? ;+8 |
.start dd ? ;+12 |
.i_end dd ? ;+16 |
.mem_size dd ? ;+20 |
.stack_top dd ? ;+24 |
.cmdline dd ? ;+28 |
.path dd ? ;+32 |
} |
virtual at 0 |
app_hdr APP_HEADER_02 |
end virtual |
format MS COFF |
public EXPORTS |
section '.flat' code readable align 16 |
EXPORTS: |
dd szStart, START |
dd szVersion, 0x00010001 |
dd szExec, exec |
dd 0 |
check dd 0 |
szStart db 'START',0 |
szVersion db 'version',0 |
szExec db 'exec',0 |
START: |
xor eax, eax |
cmp [app_hdr.path], 0 |
je .ret |
not eax |
.ret: |
mov [check], eax |
ret 4 |
align 4 |
exec: |
cmp [check], 0 |
lea ebp, [esp+4] |
je .fail |
mov eax, [ebp+8] |
test eax, eax |
jz .fail |
mov ecx, [ebp] |
mov edx, [ebp+4] |
call validate_pe |
test eax, eax |
jz .fail |
mov eax, 68 |
mov ebx, [ebp] |
mov ecx, [ebx+60] |
mov ecx, [ecx+96+ebx] ; app stack size |
add ecx, 4095 |
and ecx, -4096 |
mov ebx, 12 |
int 0x40 |
test eax, eax |
jz .fail |
add ecx, eax |
mov [fs:4], eax ;stack base |
mov [fs:8], ecx ;stack top |
mov esp, ecx |
sub esp, 1024 |
mov eax, 9 |
mov ebx, esp |
mov ecx, -1 |
int 0x40 |
mov eax, [ebx+30] |
mov [fs:0], eax ; save pid |
add esp, 1024 |
mov ecx, my_libc |
call create_image |
test eax, eax |
jz .fail |
mov ebx, [eax+60] |
mov ebx, [ebx+40+eax] |
add ebx, eax |
push ebp |
push EXPORTS |
push eax |
call ebx |
ret |
.fail: |
ret 4 |
align 4 |
validate_pe: |
test ecx, ecx |
je .L2 |
cmp edx, 63 |
jbe .L2 |
cmp [ecx], word 23117 |
je .L10 |
.L2: |
xor eax, eax |
ret |
align 4 |
.L10: |
mov eax, [ecx+60] |
test eax, eax |
je .L2 |
add ecx, eax |
jb .L2 |
cmp [ecx], dword 17744 |
jne .L2 |
cmp [ecx+4], word 332 |
jne .L2 |
test [ecx+23], byte 32 |
jne .L2 |
cmp [ecx+24], word 267 |
jne .L2 |
mov eax, [ecx+56] |
cmp eax, 4095 |
ja .L3 |
cmp eax, [ecx+60] |
jne .L2 |
test eax, eax |
je .L2 |
.L5: |
lea edx, [eax-1] |
test edx, eax |
jne .L2 |
mov eax, [ecx+60] |
test eax, eax |
je .L2 |
lea edx, [eax-1] |
test edx, eax |
jne .L2 |
xor eax, eax |
cmp [ecx+6], word 96 |
setbe al |
ret |
.L3: |
cmp eax, [ecx+60] |
jae .L5 |
jmp .L2 |
align 4 |
create_image: |
push ebp |
push edi |
push esi |
push ebx |
sub esp, 20 |
mov [esp+16], ecx |
mov eax, [ecx+60] |
add eax, ecx |
mov [esp], eax |
mov ecx, [eax+80] |
mov ebx, 12 |
mov eax, 68 |
int 0x40 |
test eax, eax |
je .L16 |
mov edx, [esp] |
mov ecx, [edx+84] |
mov esi, [esp+16] |
mov edi, eax |
shr ecx, 2 |
rep movsd |
mov cx, [edx+6] |
test cx, cx |
je .L17 |
add edx, 248 |
movzx ecx, cx |
lea ebp, [ecx-1] |
xor bl, bl |
jmp .L19 |
align 4 |
.L31: |
add edx, 40 |
inc ebx |
.L19: |
mov ecx, [edx+16] |
test ecx, ecx |
je .L18 |
mov esi, [edx+20] |
test esi, esi |
je .L18 |
add esi, [esp+16] |
mov edi, [edx+12] |
add edi, eax |
shr ecx, 2 |
rep movsd |
.L18: |
cmp ebx, ebp |
jne .L31 |
.L17: |
mov edx, [esp] |
mov ecx, [edx+164] |
test ecx, ecx |
je .L16 |
mov ebp, eax |
sub ebp, [edx+52] |
mov ebx, [edx+160] |
add ebx, eax |
mov esi, [ebx+4] |
test esi, esi |
je .L16 |
mov edi, ebp |
shr edi, 16 |
mov [esp], di |
align 4 |
.L26: |
lea edi, [esi-8] |
shr edi, 1 |
je .L20 |
xor ecx, ecx |
jmp .L25 |
align 4 |
.L32: |
cmp si, 3 |
je .L24 |
dec si |
jne .L21 |
mov esi, [esp] |
add [eax+edx], si |
.L21: |
inc ecx |
cmp ecx, edi |
je .L20 |
.L25: |
mov si, [ebx+8+ecx*2] |
mov edx, esi |
and edx, 4095 |
add edx, [ebx] |
shr si, 12 |
cmp si, 2 |
jne .L32 |
add [eax+edx], bp |
inc ecx |
cmp ecx, edi |
jne .L25 |
.L20: |
add ebx, [ebx+4] |
mov esi, [ebx+4] |
test esi, esi |
jne .L26 |
.L16: |
add esp, 20 |
pop ebx |
pop esi |
pop edi |
pop ebp |
ret |
align 4 |
.L24: |
add [eax+edx], ebp |
jmp .L21 |
align 16 |
my_libc: |
file '../libc.dll' |
/contrib/sdk/sources/libc/pe/list.h |
---|
0,0 → 1,707 |
#ifndef _LINUX_LIST_H |
#define _LINUX_LIST_H |
/* |
* Simple doubly linked list implementation. |
* |
* Some of the internal functions ("__xxx") are useful when |
* manipulating whole lists rather than single entries, as |
* sometimes we already know the next/prev entries and we can |
* generate better code by using them directly rather than |
* using the generic single-entry routines. |
*/ |
/** |
* container_of - cast a member of a structure out to the containing structure |
* @ptr: the pointer to the member. |
* @type: the type of the container struct this is embedded in. |
* @member: the name of the member within the struct. |
* |
*/ |
#define container_of(ptr, type, member) ({ \ |
const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
(type *)( (char *)__mptr - offsetof(type,member) );}) |
#define LIST_POISON1 ((struct list_head*)0xFFFF0100) |
#define LIST_POISON2 ((struct list_head*)0xFFFF0200) |
#define prefetch(x) __builtin_prefetch(x) |
struct list_head { |
struct list_head *next, *prev; |
}; |
#define LIST_HEAD_INIT(name) { &(name), &(name) } |
#define LIST_HEAD(name) \ |
struct list_head name = LIST_HEAD_INIT(name) |
static inline void INIT_LIST_HEAD(struct list_head *list) |
{ |
list->next = list; |
list->prev = list; |
} |
/* |
* Insert a new entry between two known consecutive entries. |
* |
* This is only for internal list manipulation where we know |
* the prev/next entries already! |
*/ |
#ifndef CONFIG_DEBUG_LIST |
static inline void __list_add(struct list_head *new, |
struct list_head *prev, |
struct list_head *next) |
{ |
next->prev = new; |
new->next = next; |
new->prev = prev; |
prev->next = new; |
} |
#else |
extern void __list_add(struct list_head *new, |
struct list_head *prev, |
struct list_head *next); |
#endif |
/** |
* list_add - add a new entry |
* @new: new entry to be added |
* @head: list head to add it after |
* |
* Insert a new entry after the specified head. |
* This is good for implementing stacks. |
*/ |
static inline void list_add(struct list_head *new, struct list_head *head) |
{ |
__list_add(new, head, head->next); |
} |
/** |
* list_add_tail - add a new entry |
* @new: new entry to be added |
* @head: list head to add it before |
* |
* Insert a new entry before the specified head. |
* This is useful for implementing queues. |
*/ |
static inline void list_add_tail(struct list_head *new, struct list_head *head) |
{ |
__list_add(new, head->prev, head); |
} |
/* |
* Delete a list entry by making the prev/next entries |
* point to each other. |
* |
* This is only for internal list manipulation where we know |
* the prev/next entries already! |
*/ |
static inline void __list_del(struct list_head * prev, struct list_head * next) |
{ |
next->prev = prev; |
prev->next = next; |
} |
/** |
* list_del - deletes entry from list. |
* @entry: the element to delete from the list. |
* Note: list_empty() on entry does not return true after this, the entry is |
* in an undefined state. |
*/ |
#ifndef CONFIG_DEBUG_LIST |
static inline void list_del(struct list_head *entry) |
{ |
__list_del(entry->prev, entry->next); |
entry->next = LIST_POISON1; |
entry->prev = LIST_POISON2; |
} |
#else |
extern void list_del(struct list_head *entry); |
#endif |
/** |
* list_replace - replace old entry by new one |
* @old : the element to be replaced |
* @new : the new element to insert |
* |
* If @old was empty, it will be overwritten. |
*/ |
static inline void list_replace(struct list_head *old, |
struct list_head *new) |
{ |
new->next = old->next; |
new->next->prev = new; |
new->prev = old->prev; |
new->prev->next = new; |
} |
static inline void list_replace_init(struct list_head *old, |
struct list_head *new) |
{ |
list_replace(old, new); |
INIT_LIST_HEAD(old); |
} |
/** |
* list_del_init - deletes entry from list and reinitialize it. |
* @entry: the element to delete from the list. |
*/ |
static inline void list_del_init(struct list_head *entry) |
{ |
__list_del(entry->prev, entry->next); |
INIT_LIST_HEAD(entry); |
} |
/** |
* list_move - delete from one list and add as another's head |
* @list: the entry to move |
* @head: the head that will precede our entry |
*/ |
static inline void list_move(struct list_head *list, struct list_head *head) |
{ |
__list_del(list->prev, list->next); |
list_add(list, head); |
} |
/** |
* list_move_tail - delete from one list and add as another's tail |
* @list: the entry to move |
* @head: the head that will follow our entry |
*/ |
static inline void list_move_tail(struct list_head *list, |
struct list_head *head) |
{ |
__list_del(list->prev, list->next); |
list_add_tail(list, head); |
} |
/** |
* list_is_last - tests whether @list is the last entry in list @head |
* @list: the entry to test |
* @head: the head of the list |
*/ |
static inline int list_is_last(const struct list_head *list, |
const struct list_head *head) |
{ |
return list->next == head; |
} |
/** |
* list_empty - tests whether a list is empty |
* @head: the list to test. |
*/ |
static inline int list_empty(const struct list_head *head) |
{ |
return head->next == head; |
} |
/** |
* list_empty_careful - tests whether a list is empty and not being modified |
* @head: the list to test |
* |
* Description: |
* tests whether a list is empty _and_ checks that no other CPU might be |
* in the process of modifying either member (next or prev) |
* |
* NOTE: using list_empty_careful() without synchronization |
* can only be safe if the only activity that can happen |
* to the list entry is list_del_init(). Eg. it cannot be used |
* if another CPU could re-list_add() it. |
*/ |
static inline int list_empty_careful(const struct list_head *head) |
{ |
struct list_head *next = head->next; |
return (next == head) && (next == head->prev); |
} |
/** |
* list_is_singular - tests whether a list has just one entry. |
* @head: the list to test. |
*/ |
static inline int list_is_singular(const struct list_head *head) |
{ |
return !list_empty(head) && (head->next == head->prev); |
} |
static inline void __list_cut_position(struct list_head *list, |
struct list_head *head, struct list_head *entry) |
{ |
struct list_head *new_first = entry->next; |
list->next = head->next; |
list->next->prev = list; |
list->prev = entry; |
entry->next = list; |
head->next = new_first; |
new_first->prev = head; |
} |
/** |
* list_cut_position - cut a list into two |
* @list: a new list to add all removed entries |
* @head: a list with entries |
* @entry: an entry within head, could be the head itself |
* and if so we won't cut the list |
* |
* This helper moves the initial part of @head, up to and |
* including @entry, from @head to @list. You should |
* pass on @entry an element you know is on @head. @list |
* should be an empty list or a list you do not care about |
* losing its data. |
* |
*/ |
static inline void list_cut_position(struct list_head *list, |
struct list_head *head, struct list_head *entry) |
{ |
if (list_empty(head)) |
return; |
if (list_is_singular(head) && |
(head->next != entry && head != entry)) |
return; |
if (entry == head) |
INIT_LIST_HEAD(list); |
else |
__list_cut_position(list, head, entry); |
} |
static inline void __list_splice(const struct list_head *list, |
struct list_head *prev, |
struct list_head *next) |
{ |
struct list_head *first = list->next; |
struct list_head *last = list->prev; |
first->prev = prev; |
prev->next = first; |
last->next = next; |
next->prev = last; |
} |
/** |
* list_splice - join two lists, this is designed for stacks |
* @list: the new list to add. |
* @head: the place to add it in the first list. |
*/ |
static inline void list_splice(const struct list_head *list, |
struct list_head *head) |
{ |
if (!list_empty(list)) |
__list_splice(list, head, head->next); |
} |
/** |
* list_splice_tail - join two lists, each list being a queue |
* @list: the new list to add. |
* @head: the place to add it in the first list. |
*/ |
static inline void list_splice_tail(struct list_head *list, |
struct list_head *head) |
{ |
if (!list_empty(list)) |
__list_splice(list, head->prev, head); |
} |
/** |
* list_splice_init - join two lists and reinitialise the emptied list. |
* @list: the new list to add. |
* @head: the place to add it in the first list. |
* |
* The list at @list is reinitialised |
*/ |
static inline void list_splice_init(struct list_head *list, |
struct list_head *head) |
{ |
if (!list_empty(list)) { |
__list_splice(list, head, head->next); |
INIT_LIST_HEAD(list); |
} |
} |
/** |
* list_splice_tail_init - join two lists and reinitialise the emptied list |
* @list: the new list to add. |
* @head: the place to add it in the first list. |
* |
* Each of the lists is a queue. |
* The list at @list is reinitialised |
*/ |
static inline void list_splice_tail_init(struct list_head *list, |
struct list_head *head) |
{ |
if (!list_empty(list)) { |
__list_splice(list, head->prev, head); |
INIT_LIST_HEAD(list); |
} |
} |
/** |
* list_entry - get the struct for this entry |
* @ptr: the &struct list_head pointer. |
* @type: the type of the struct this is embedded in. |
* @member: the name of the list_struct within the struct. |
*/ |
#define list_entry(ptr, type, member) \ |
container_of(ptr, type, member) |
/** |
* list_first_entry - get the first element from a list |
* @ptr: the list head to take the element from. |
* @type: the type of the struct this is embedded in. |
* @member: the name of the list_struct within the struct. |
* |
* Note, that list is expected to be not empty. |
*/ |
#define list_first_entry(ptr, type, member) \ |
list_entry((ptr)->next, type, member) |
/** |
* list_for_each - iterate over a list |
* @pos: the &struct list_head to use as a loop cursor. |
* @head: the head for your list. |
*/ |
#define list_for_each(pos, head) \ |
for (pos = (head)->next; prefetch(pos->next), pos != (head); \ |
pos = pos->next) |
/** |
* __list_for_each - iterate over a list |
* @pos: the &struct list_head to use as a loop cursor. |
* @head: the head for your list. |
* |
* This variant differs from list_for_each() in that it's the |
* simplest possible list iteration code, no prefetching is done. |
* Use this for code that knows the list to be very short (empty |
* or 1 entry) most of the time. |
*/ |
#define __list_for_each(pos, head) \ |
for (pos = (head)->next; pos != (head); pos = pos->next) |
/** |
* list_for_each_prev - iterate over a list backwards |
* @pos: the &struct list_head to use as a loop cursor. |
* @head: the head for your list. |
*/ |
#define list_for_each_prev(pos, head) \ |
for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \ |
pos = pos->prev) |
/** |
* list_for_each_safe - iterate over a list safe against removal of list entry |
* @pos: the &struct list_head to use as a loop cursor. |
* @n: another &struct list_head to use as temporary storage |
* @head: the head for your list. |
*/ |
#define list_for_each_safe(pos, n, head) \ |
for (pos = (head)->next, n = pos->next; pos != (head); \ |
pos = n, n = pos->next) |
/** |
* list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry |
* @pos: the &struct list_head to use as a loop cursor. |
* @n: another &struct list_head to use as temporary storage |
* @head: the head for your list. |
*/ |
#define list_for_each_prev_safe(pos, n, head) \ |
for (pos = (head)->prev, n = pos->prev; \ |
prefetch(pos->prev), pos != (head); \ |
pos = n, n = pos->prev) |
/** |
* list_for_each_entry - iterate over list of given type |
* @pos: the type * to use as a loop cursor. |
* @head: the head for your list. |
* @member: the name of the list_struct within the struct. |
*/ |
#define list_for_each_entry(pos, head, member) \ |
for (pos = list_entry((head)->next, typeof(*pos), member); \ |
prefetch(pos->member.next), &pos->member != (head); \ |
pos = list_entry(pos->member.next, typeof(*pos), member)) |
/** |
* list_for_each_entry_reverse - iterate backwards over list of given type. |
* @pos: the type * to use as a loop cursor. |
* @head: the head for your list. |
* @member: the name of the list_struct within the struct. |
*/ |
#define list_for_each_entry_reverse(pos, head, member) \ |
for (pos = list_entry((head)->prev, typeof(*pos), member); \ |
prefetch(pos->member.prev), &pos->member != (head); \ |
pos = list_entry(pos->member.prev, typeof(*pos), member)) |
/** |
* list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue() |
* @pos: the type * to use as a start point |
* @head: the head of the list |
* @member: the name of the list_struct within the struct. |
* |
* Prepares a pos entry for use as a start point in list_for_each_entry_continue(). |
*/ |
#define list_prepare_entry(pos, head, member) \ |
((pos) ? : list_entry(head, typeof(*pos), member)) |
/** |
* list_for_each_entry_continue - continue iteration over list of given type |
* @pos: the type * to use as a loop cursor. |
* @head: the head for your list. |
* @member: the name of the list_struct within the struct. |
* |
* Continue to iterate over list of given type, continuing after |
* the current position. |
*/ |
#define list_for_each_entry_continue(pos, head, member) \ |
for (pos = list_entry(pos->member.next, typeof(*pos), member); \ |
prefetch(pos->member.next), &pos->member != (head); \ |
pos = list_entry(pos->member.next, typeof(*pos), member)) |
/** |
* list_for_each_entry_continue_reverse - iterate backwards from the given point |
* @pos: the type * to use as a loop cursor. |
* @head: the head for your list. |
* @member: the name of the list_struct within the struct. |
* |
* Start to iterate over list of given type backwards, continuing after |
* the current position. |
*/ |
#define list_for_each_entry_continue_reverse(pos, head, member) \ |
for (pos = list_entry(pos->member.prev, typeof(*pos), member); \ |
prefetch(pos->member.prev), &pos->member != (head); \ |
pos = list_entry(pos->member.prev, typeof(*pos), member)) |
/** |
* list_for_each_entry_from - iterate over list of given type from the current point |
* @pos: the type * to use as a loop cursor. |
* @head: the head for your list. |
* @member: the name of the list_struct within the struct. |
* |
* Iterate over list of given type, continuing from current position. |
*/ |
#define list_for_each_entry_from(pos, head, member) \ |
for (; prefetch(pos->member.next), &pos->member != (head); \ |
pos = list_entry(pos->member.next, typeof(*pos), member)) |
/** |
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry |
* @pos: the type * to use as a loop cursor. |
* @n: another type * to use as temporary storage |
* @head: the head for your list. |
* @member: the name of the list_struct within the struct. |
*/ |
#define list_for_each_entry_safe(pos, n, head, member) \ |
for (pos = list_entry((head)->next, typeof(*pos), member), \ |
n = list_entry(pos->member.next, typeof(*pos), member); \ |
&pos->member != (head); \ |
pos = n, n = list_entry(n->member.next, typeof(*n), member)) |
/** |
* list_for_each_entry_safe_continue |
* @pos: the type * to use as a loop cursor. |
* @n: another type * to use as temporary storage |
* @head: the head for your list. |
* @member: the name of the list_struct within the struct. |
* |
* Iterate over list of given type, continuing after current point, |
* safe against removal of list entry. |
*/ |
#define list_for_each_entry_safe_continue(pos, n, head, member) \ |
for (pos = list_entry(pos->member.next, typeof(*pos), member), \ |
n = list_entry(pos->member.next, typeof(*pos), member); \ |
&pos->member != (head); \ |
pos = n, n = list_entry(n->member.next, typeof(*n), member)) |
/** |
* list_for_each_entry_safe_from |
* @pos: the type * to use as a loop cursor. |
* @n: another type * to use as temporary storage |
* @head: the head for your list. |
* @member: the name of the list_struct within the struct. |
* |
* Iterate over list of given type from current point, safe against |
* removal of list entry. |
*/ |
#define list_for_each_entry_safe_from(pos, n, head, member) \ |
for (n = list_entry(pos->member.next, typeof(*pos), member); \ |
&pos->member != (head); \ |
pos = n, n = list_entry(n->member.next, typeof(*n), member)) |
/** |
* list_for_each_entry_safe_reverse |
* @pos: the type * to use as a loop cursor. |
* @n: another type * to use as temporary storage |
* @head: the head for your list. |
* @member: the name of the list_struct within the struct. |
* |
* Iterate backwards over list of given type, safe against removal |
* of list entry. |
*/ |
#define list_for_each_entry_safe_reverse(pos, n, head, member) \ |
for (pos = list_entry((head)->prev, typeof(*pos), member), \ |
n = list_entry(pos->member.prev, typeof(*pos), member); \ |
&pos->member != (head); \ |
pos = n, n = list_entry(n->member.prev, typeof(*n), member)) |
/* |
* Double linked lists with a single pointer list head. |
* Mostly useful for hash tables where the two pointer list head is |
* too wasteful. |
* You lose the ability to access the tail in O(1). |
*/ |
struct hlist_head { |
struct hlist_node *first; |
}; |
struct hlist_node { |
struct hlist_node *next, **pprev; |
}; |
#define HLIST_HEAD_INIT { .first = NULL } |
#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } |
#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL) |
static inline void INIT_HLIST_NODE(struct hlist_node *h) |
{ |
h->next = NULL; |
h->pprev = NULL; |
} |
static inline int hlist_unhashed(const struct hlist_node *h) |
{ |
return !h->pprev; |
} |
static inline int hlist_empty(const struct hlist_head *h) |
{ |
return !h->first; |
} |
static inline void __hlist_del(struct hlist_node *n) |
{ |
struct hlist_node *next = n->next; |
struct hlist_node **pprev = n->pprev; |
*pprev = next; |
if (next) |
next->pprev = pprev; |
} |
static inline void hlist_del(struct hlist_node *n) |
{ |
__hlist_del(n); |
n->next = (struct hlist_node*)LIST_POISON1; |
n->pprev = (struct hlist_node**)LIST_POISON2; |
} |
static inline void hlist_del_init(struct hlist_node *n) |
{ |
if (!hlist_unhashed(n)) { |
__hlist_del(n); |
INIT_HLIST_NODE(n); |
} |
} |
static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) |
{ |
struct hlist_node *first = h->first; |
n->next = first; |
if (first) |
first->pprev = &n->next; |
h->first = n; |
n->pprev = &h->first; |
} |
/* next must be != NULL */ |
static inline void hlist_add_before(struct hlist_node *n, |
struct hlist_node *next) |
{ |
n->pprev = next->pprev; |
n->next = next; |
next->pprev = &n->next; |
*(n->pprev) = n; |
} |
static inline void hlist_add_after(struct hlist_node *n, |
struct hlist_node *next) |
{ |
next->next = n->next; |
n->next = next; |
next->pprev = &n->next; |
if(next->next) |
next->next->pprev = &next->next; |
} |
/* |
* Move a list from one list head to another. Fixup the pprev |
* reference of the first entry if it exists. |
*/ |
static inline void hlist_move_list(struct hlist_head *old, |
struct hlist_head *new) |
{ |
new->first = old->first; |
if (new->first) |
new->first->pprev = &new->first; |
old->first = NULL; |
} |
#define hlist_entry(ptr, type, member) container_of(ptr,type,member) |
#define hlist_for_each(pos, head) \ |
for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \ |
pos = pos->next) |
#define hlist_for_each_safe(pos, n, head) \ |
for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ |
pos = n) |
/** |
* hlist_for_each_entry - iterate over list of given type |
* @tpos: the type * to use as a loop cursor. |
* @pos: the &struct hlist_node to use as a loop cursor. |
* @head: the head for your list. |
* @member: the name of the hlist_node within the struct. |
*/ |
#define hlist_for_each_entry(tpos, pos, head, member) \ |
for (pos = (head)->first; \ |
pos && ({ prefetch(pos->next); 1;}) && \ |
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
pos = pos->next) |
/** |
* hlist_for_each_entry_continue - iterate over a hlist continuing after current point |
* @tpos: the type * to use as a loop cursor. |
* @pos: the &struct hlist_node to use as a loop cursor. |
* @member: the name of the hlist_node within the struct. |
*/ |
#define hlist_for_each_entry_continue(tpos, pos, member) \ |
for (pos = (pos)->next; \ |
pos && ({ prefetch(pos->next); 1;}) && \ |
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
pos = pos->next) |
/** |
* hlist_for_each_entry_from - iterate over a hlist continuing from current point |
* @tpos: the type * to use as a loop cursor. |
* @pos: the &struct hlist_node to use as a loop cursor. |
* @member: the name of the hlist_node within the struct. |
*/ |
#define hlist_for_each_entry_from(tpos, pos, member) \ |
for (; pos && ({ prefetch(pos->next); 1;}) && \ |
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
pos = pos->next) |
/** |
* hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry |
* @tpos: the type * to use as a loop cursor. |
* @pos: the &struct hlist_node to use as a loop cursor. |
* @n: another &struct hlist_node to use as temporary storage |
* @head: the head for your list. |
* @member: the name of the hlist_node within the struct. |
*/ |
#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \ |
for (pos = (head)->first; \ |
pos && ({ n = pos->next; 1; }) && \ |
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
pos = n) |
#endif |
/contrib/sdk/sources/libc/pe/pe.h |
---|
0,0 → 1,188 |
typedef unsigned short WORD; |
typedef unsigned int DWORD; |
typedef unsigned int LONG; |
typedef unsigned char BYTE; |
#define IMAGE_DOS_SIGNATURE 0x5A4D |
#define IMAGE_NT_SIGNATURE 0x00004550 |
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b |
#pragma pack(push,2) |
typedef struct _IMAGE_DOS_HEADER |
{ |
WORD e_magic; |
WORD e_cblp; |
WORD e_cp; |
WORD e_crlc; |
WORD e_cparhdr; |
WORD e_minalloc; |
WORD e_maxalloc; |
WORD e_ss; |
WORD e_sp; |
WORD e_csum; |
WORD e_ip; |
WORD e_cs; |
WORD e_lfarlc; |
WORD e_ovno; |
WORD e_res[4]; |
WORD e_oemid; |
WORD e_oeminfo; |
WORD e_res2[10]; |
LONG e_lfanew; |
} IMAGE_DOS_HEADER,*PIMAGE_DOS_HEADER; |
#pragma pack(pop) |
#pragma pack(push,4) |
typedef struct _IMAGE_FILE_HEADER |
{ |
WORD Machine; |
WORD NumberOfSections; |
DWORD TimeDateStamp; |
DWORD PointerToSymbolTable; |
DWORD NumberOfSymbols; |
WORD SizeOfOptionalHeader; |
WORD Characteristics; |
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; |
#define IMAGE_FILE_DLL 0x2000 |
#define IMAGE_FILE_MACHINE_I386 0x014c /* Intel 386 or later processors |
and compatible processors */ |
typedef struct _IMAGE_DATA_DIRECTORY { |
DWORD VirtualAddress; |
DWORD Size; |
} IMAGE_DATA_DIRECTORY,*PIMAGE_DATA_DIRECTORY; |
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 |
typedef struct _IMAGE_OPTIONAL_HEADER { |
WORD Magic; |
BYTE MajorLinkerVersion; |
BYTE MinorLinkerVersion; |
DWORD SizeOfCode; |
DWORD SizeOfInitializedData; |
DWORD SizeOfUninitializedData; |
DWORD AddressOfEntryPoint; |
DWORD BaseOfCode; |
DWORD BaseOfData; |
DWORD ImageBase; |
DWORD SectionAlignment; |
DWORD FileAlignment; |
WORD MajorOperatingSystemVersion; |
WORD MinorOperatingSystemVersion; |
WORD MajorImageVersion; |
WORD MinorImageVersion; |
WORD MajorSubsystemVersion; |
WORD MinorSubsystemVersion; |
DWORD Win32VersionValue; |
DWORD SizeOfImage; |
DWORD SizeOfHeaders; |
DWORD CheckSum; |
WORD Subsystem; |
WORD DllCharacteristics; |
DWORD SizeOfStackReserve; |
DWORD SizeOfStackCommit; |
DWORD SizeOfHeapReserve; |
DWORD SizeOfHeapCommit; |
DWORD LoaderFlags; |
DWORD NumberOfRvaAndSizes; |
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; |
} IMAGE_OPTIONAL_HEADER,*PIMAGE_OPTIONAL_HEADER; |
#pragma pack(pop) |
#pragma pack(push,4) |
typedef struct _IMAGE_NT_HEADERS |
{ |
DWORD Signature; |
IMAGE_FILE_HEADER FileHeader; |
IMAGE_OPTIONAL_HEADER OptionalHeader; |
} IMAGE_NT_HEADERS32,*PIMAGE_NT_HEADERS32; |
#define IMAGE_SIZEOF_SHORT_NAME 8 |
typedef struct _IMAGE_SECTION_HEADER |
{ |
BYTE Name[IMAGE_SIZEOF_SHORT_NAME]; |
union |
{ |
DWORD PhysicalAddress; |
DWORD VirtualSize; |
} Misc; |
DWORD VirtualAddress; |
DWORD SizeOfRawData; |
DWORD PointerToRawData; |
DWORD PointerToRelocations; |
DWORD PointerToLinenumbers; |
WORD NumberOfRelocations; |
WORD NumberOfLinenumbers; |
DWORD Characteristics; |
} IMAGE_SECTION_HEADER,*PIMAGE_SECTION_HEADER; |
#pragma pack(pop) |
#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 |
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 |
#define IMAGE_SCN_MEM_SHARED 0x10000000 |
#define IMAGE_SCN_MEM_EXECUTE 0x20000000 |
#define IMAGE_SCN_MEM_WRITE 0x80000000 |
#pragma pack(push,4) |
typedef struct _IMAGE_BASE_RELOCATION { |
DWORD VirtualAddress; |
DWORD SizeOfBlock; |
} IMAGE_BASE_RELOCATION,*PIMAGE_BASE_RELOCATION; |
#pragma pack(pop) |
typedef struct _IMAGE_IMPORT_DESCRIPTOR |
{ |
union |
{ |
DWORD Characteristics; |
DWORD OriginalFirstThunk; |
}; |
DWORD TimeDateStamp; |
DWORD ForwarderChain; |
DWORD Name; |
DWORD FirstThunk; |
} IMAGE_IMPORT_DESCRIPTOR,*PIMAGE_IMPORT_DESCRIPTOR; |
typedef struct _IMAGE_THUNK_DATA32 |
{ |
union |
{ |
DWORD ForwarderString; |
DWORD Function; |
DWORD Ordinal; |
DWORD AddressOfData; |
} u1; |
} IMAGE_THUNK_DATA32,*PIMAGE_THUNK_DATA32; |
typedef struct _IMAGE_IMPORT_BY_NAME |
{ |
WORD Hint; |
BYTE Name[1]; |
} IMAGE_IMPORT_BY_NAME,*PIMAGE_IMPORT_BY_NAME; |
#define IMAGE_ORDINAL_FLAG 0x80000000 |
typedef struct _IMAGE_EXPORT_DIRECTORY { |
DWORD Characteristics; |
DWORD TimeDateStamp; |
WORD MajorVersion; |
WORD MinorVersion; |
DWORD Name; |
DWORD Base; |
DWORD NumberOfFunctions; |
DWORD NumberOfNames; |
DWORD AddressOfFunctions; |
DWORD AddressOfNames; |
DWORD AddressOfNameOrdinals; |
} IMAGE_EXPORT_DIRECTORY,*PIMAGE_EXPORT_DIRECTORY; |
#define MakePtr( cast, ptr, addValue ) (cast)( (uint32_t)(ptr) + (uint32_t)(addValue) ) |
/contrib/sdk/sources/libc/app.lds |
---|
0,0 → 1,128 |
/*OUTPUT_FORMAT("binary")*/ |
ENTRY(__start) |
SECTIONS |
{ |
.text 0x000000: |
{ |
LONG(0x554e454D); |
LONG(0x32305445); |
LONG(1); |
LONG(__start); |
LONG(___iend); |
LONG(___memsize); |
LONG(___stacktop); |
LONG(___cmdline); |
LONG(___pgmname); /* full path */ |
LONG(0); /*FIXME tls data */ |
LONG(__idata_start) |
LONG(__idata_end) |
LONG(_main) |
*(.init) |
*(.text) |
*(SORT(.text$*)) |
*(.text.*) |
*(.glue_7t) |
*(.glue_7) |
___CTOR_LIST__ = .; __CTOR_LIST__ = . ; |
LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); |
___DTOR_LIST__ = .; __DTOR_LIST__ = . ; |
LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); |
*(.fini) |
/* ??? Why is .gcc_exc here? */ |
*(.gcc_exc) |
PROVIDE (etext = .); |
*(.gcc_except_table) |
} |
.rdata ALIGN(16) : |
{ |
*(.rdata) |
*(SORT(.rdata$*)) |
___RUNTIME_PSEUDO_RELOC_LIST__ = .; |
__RUNTIME_PSEUDO_RELOC_LIST__ = .; |
*(.rdata_runtime_pseudo_reloc) |
___RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
__RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
} |
.CRT ALIGN(16) : |
{ |
___crt_xc_start__ = . ; |
*(SORT(.CRT$XC*)) /* C initialization */ |
___crt_xc_end__ = . ; |
___crt_xi_start__ = . ; |
*(SORT(.CRT$XI*)) /* C++ initialization */ |
___crt_xi_end__ = . ; |
___crt_xl_start__ = . ; |
*(SORT(.CRT$XL*)) /* TLS callbacks */ |
/* ___crt_xl_end__ is defined in the TLS Directory support code */ |
___crt_xp_start__ = . ; |
*(SORT(.CRT$XP*)) /* Pre-termination */ |
___crt_xp_end__ = . ; |
___crt_xt_start__ = . ; |
*(SORT(.CRT$XT*)) /* Termination */ |
___crt_xt_end__ = . ; |
} |
.data ALIGN(64) : |
{ |
PROVIDE ( __data_start__ = .) ; |
*(.data) |
*(.data2) |
*(SORT(.data$*)) |
*(.jcr) |
__CRT_MT = .; |
LONG(0); |
PROVIDE ( __data_end__ = .) ; |
*(.data_cygwin_nocopy) |
___iend = . ; |
} |
.idata ALIGN(16): |
{ |
__idata_start = .; |
SORT(*)(.idata$2) |
SORT(*)(.idata$3) |
/* These zeroes mark the end of the import list. */ |
LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); |
SORT(*)(.idata$4) |
SORT(*)(.idata$5) |
SORT(*)(.idata$6) |
SORT(*)(.idata$7) |
__idata_end = . ; |
} |
bss ALIGN(16): |
{ |
*(.bss) |
*(COMMON) |
. = ALIGN(16); |
___cmdline = .; |
. = . + 256; |
___pgmname = .; |
. = . + 1024 + 16; |
___stacktop = .; |
___memsize = . ; |
} |
/DISCARD/ : |
{ |
*(.debug$S) |
*(.debug$T) |
*(.debug$F) |
*(.drectve) |
*(.note.GNU-stack) |
*(.eh_frame) |
*(.comment) |
*(.debug_abbrev) |
*(.debug_info) |
*(.debug_line) |
*(.debug_frame) |
*(.debug_loc) |
*(.debug_pubnames) |
*(.debug_aranges) |
*(.debug_ranges) |
} |
} |
/contrib/sdk/sources/libc/argz/buf_findstr.c |
---|
0,0 → 1,44 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include <errno.h> |
#include <sys/types.h> |
#include <string.h> |
#include <stdlib.h> |
#include "buf_findstr.h" |
/* Find string str in buffer buf of length buf_len. Point buf to character after string, |
or set it to NULL if end of buffer is reached. Return 1 if found, 0 if not. */ |
int |
_buf_findstr(const char *str, char **buf, size_t *buf_len) |
{ |
int i = 0; |
int j = 0; |
for (i = 0; i < *buf_len; i++) |
{ |
if (str[0] == (*buf)[i]) |
{ |
j = i; |
while (str[j - i] && (str[j - i] == (*buf)[j])) j++; |
if(str[j - i] == '\0') |
{ |
*buf += j; |
*buf_len -= j; |
return 1; |
} |
} |
} |
if (i == *buf_len) |
{ |
*buf += *buf_len; |
*buf_len = 0; |
} |
return 0; |
} |
/contrib/sdk/sources/libc/argz/buf_findstr.h |
---|
0,0 → 1,12 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include <sys/types.h> |
/* Find string str in buffer buf of length buf_len. Point buf to |
character after string, or set it to NULL if end of buffer is |
reached. Return 1 if found, 0 if not. */ |
int _buf_findstr(const char *str, char **buf, size_t *buf_len); |
/contrib/sdk/sources/libc/argz/envz_get.c |
---|
0,0 → 1,43 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include <errno.h> |
#include <sys/types.h> |
#include <string.h> |
#include <stdlib.h> |
#include <envz.h> |
#include "buf_findstr.h" |
char * |
_DEFUN (envz_get, (envz, envz_len, name), |
const char *envz _AND |
size_t envz_len _AND |
const char *name) |
{ |
char *buf_ptr = (char *)envz; |
size_t buf_len = envz_len; |
while(buf_len) |
{ |
if (_buf_findstr(name, &buf_ptr, &buf_len)) |
{ |
if (*buf_ptr == '=') |
{ |
buf_ptr++; |
return (char *)buf_ptr; |
} |
else |
{ |
if (*buf_ptr == '\0') |
/* NULL entry. */ |
return NULL; |
} |
} |
} |
/* No matching entries found. */ |
return NULL; |
} |
/contrib/sdk/sources/libc/cmd1.sed |
---|
0,0 → 1,0 |
s|[^ ][A-Za-z0-9_]*|&,'&',\\| |
/contrib/sdk/sources/libc/cmd2.sed |
---|
0,0 → 1,0 |
s|\<DATA\>|| |
/contrib/sdk/sources/libc/ctype/ctype_.c |
---|
0,0 → 1,223 |
/* |
* Copyright (c) 1989 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "@(#)ctype_.c 5.6 (Berkeley) 6/1/90"; |
#endif /* LIBC_SCCS and not lint */ |
#include <ctype.h> |
#define _CTYPE_DATA_0_127 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_N, _N, _N, _N, _N, _N, _N, _N, \ |
_N, _N, _P, _P, _P, _P, _P, _P, \ |
_P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _P, _P, _P, _P, _P, \ |
_P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _P, _P, _P, _P, _C |
#define _CTYPE_DATA_128_255 \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0 |
#if (defined(__GNUC__) && !defined(__CHAR_UNSIGNED__) && !defined(COMPACT_CTYPE)) || defined (__CYGWIN__) |
#define ALLOW_NEGATIVE_CTYPE_INDEX |
#endif |
#if defined(_MB_CAPABLE) |
#if defined(_MB_EXTENDED_CHARSETS_ISO) |
#include "ctype_iso.h" |
#endif |
#if defined(_MB_EXTENDED_CHARSETS_WINDOWS) |
#include "ctype_cp.h" |
#endif |
#endif |
#if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
/* No static const on Cygwin since it's referenced and potentially overwritten |
for compatibility with older applications. */ |
#ifndef __CYGWIN__ |
static _CONST |
#endif |
char _ctype_b[128 + 256] = { |
_CTYPE_DATA_128_255, |
_CTYPE_DATA_0_127, |
_CTYPE_DATA_128_255 |
}; |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
#ifndef _MB_CAPABLE |
_CONST |
#endif |
char __EXPORT *__ctype_ptr = (char *) _ctype_b + 128; |
#endif |
#ifndef _MB_CAPABLE |
_CONST |
#endif |
char __EXPORT *__ctype_ptr__ = (char *) _ctype_b + 127; |
# ifdef __CYGWIN__ |
__asm__ (" \n\ |
.data \n\ |
.globl __ctype_ \n\ |
.set __ctype_,__ctype_b+127 \n\ |
.text \n\ |
"); |
# else /* !__CYGWIN__ */ |
_CONST char _ctype_[1 + 256] = { |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_DATA_128_255 |
}; |
# endif /* !__CYGWIN__ */ |
#else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */ |
_CONST char _ctype_[1 + 256] = { |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_DATA_128_255 |
}; |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
#ifndef _MB_CAPABLE |
_CONST |
#endif |
char *__ctype_ptr = (char *) _ctype_ + 1; |
#endif |
#ifndef _MB_CAPABLE |
_CONST |
#endif |
char *__ctype_ptr__ = (char *) _ctype_; |
#endif |
#if defined(_MB_CAPABLE) |
/* Cygwin has its own implementation which additionally maintains backward |
compatibility with applications built under older Cygwin releases. */ |
#ifndef __CYGWIN__ |
void |
__set_ctype (const char *charset) |
{ |
#if defined(_MB_EXTENDED_CHARSETS_ISO) || defined(_MB_EXTENDED_CHARSETS_WINDOWS) |
int idx; |
#endif |
switch (*charset) |
{ |
#if defined(_MB_EXTENDED_CHARSETS_ISO) |
case 'I': |
idx = __iso_8859_index (charset + 9); |
/* The ctype table has a leading ISO-8859-1 element so we have to add |
1 to the index returned by __iso_8859_index. If __iso_8859_index |
returns < 0, it's ISO-8859-1. */ |
if (idx < 0) |
idx = 0; |
else |
++idx; |
# if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) (__ctype_iso[idx] + 128); |
#endif |
__ctype_ptr__ = (char *) (__ctype_iso[idx] + 127); |
# else |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) __ctype_iso[idx] + 1; |
#endif |
__ctype_ptr__ = (char *) __ctype_iso[idx]; |
# endif |
return; |
#endif |
#if defined(_MB_EXTENDED_CHARSETS_WINDOWS) |
case 'C': |
idx = __cp_index (charset + 2); |
if (idx < 0) |
break; |
# if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) (__ctype_cp[idx] + 128); |
#endif |
__ctype_ptr__ = (char *) (__ctype_cp[idx] + 127); |
# else |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) __ctype_cp[idx] + 1; |
#endif |
__ctype_ptr__ = (char *) __ctype_cp[idx]; |
# endif |
return; |
#endif |
default: |
break; |
} |
# if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) _ctype_b + 128; |
#endif |
__ctype_ptr__ = (char *) _ctype_b + 127; |
# else |
#ifdef _NEED_OLD_CTYPE_PTR_DEFINITION |
__ctype_ptr = (char *) _ctype_ + 1; |
#endif |
__ctype_ptr__ = (char *) _ctype_; |
# endif |
} |
#endif /* !__CYGWIN__ */ |
#endif /* _MB_CAPABLE */ |
/contrib/sdk/sources/libc/ctype/ctype_cp.h |
---|
0,0 → 1,775 |
/* ctype table definitions for Windows codepage charsets. |
Included by ctype_.c. */ |
#define _CTYPE_CP437_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _U, _U, \ |
_U, _L, _U, _L, _L, _L, _L, _L, \ |
_L, _U, _U, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _U, _L, _U, _L, _P, _L, \ |
_U, _U, _U, _L, _P, _L, _L, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP437_255 _S|_B |
#define _CTYPE_CP720_128_254 \ |
0, 0, _L, _L, 0, _L, 0, _L, \ |
_L, _L, _L, _L, _L, 0, 0, 0, \ |
0, _P, _P, _L, _P, _P, _L, _L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _P, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _P, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP720_255 _S|_B |
#define _CTYPE_CP737_128_254 \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _U, _U, _U, _U, _U, _U, \ |
_U, _P, _P, _P, _U, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP737_255 _S|_B |
#define _CTYPE_CP775_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _U, _L, _L, _U, _U, _U, \ |
_U, _L, _U, _L, _L, _U, _P, _U, \ |
_L, _U, _U, _L, _P, _U, _P, _P, \ |
_U, _U, _L, _U, _L, _L, _P, _P, \ |
_P, _P, _P, _P, _P, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _U, _U, _U, \ |
_U, _P, _P, _P, _P, _U, _U, _P, \ |
_P, _P, _P, _P, _P, _P, _U, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _L, _U, _U, _L, _U, _P, _L, \ |
_U, _L, _U, _L, _L, _U, _U, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP775_255 _S|_B |
#define _CTYPE_CP850_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _U, _U, \ |
_U, _L, _U, _L, _L, _L, _L, _L, \ |
_L, _U, _U, _L, _P, _U, _P, _L, \ |
_L, _L, _L, _L, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _U, _U, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _L, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _U, _U, _U, _U, _L, _U, _U, \ |
_U, _P, _P, _P, _P, _P, _U, _P, \ |
_U, _L, _U, _U, _L, _U, _P, _L, \ |
_U, _U, _U, _U, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP850_255 _S|_B |
#define _CTYPE_CP852_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _U, _L, _L, _U, _U, _U, \ |
_U, _U, _L, _L, _L, _U, _L, _U, \ |
_L, _U, _U, _U, _L, _U, _P, _L, \ |
_L, _L, _L, _L, _U, _L, _U, _L, \ |
_U, _L, _P, _L, _U, _L, _P, _P, \ |
_P, _P, _P, _P, _P, _U, _U, _U, \ |
_U, _P, _P, _P, _P, _U, _L, _P, \ |
_P, _P, _P, _P, _P, _P, _U, _L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _U, _U, _U, _L, _U, _U, _U, \ |
_L, _P, _P, _P, _P, _U, _U, _P, \ |
_U, _L, _U, _U, _L, _L, _U, _L, \ |
_U, _U, _L, _U, _L, _U, _L, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _L, _U, _L, _P |
#define _CTYPE_CP852_255 _S|_B |
#define _CTYPE_CP855_128_254 \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _U, _L, _U, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _L, _U, _L, \ |
_U, _P, _P, _P, _P, _L, _U, _P, \ |
_P, _P, _P, _P, _P, _P, _L, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _U, _L, _U, _L, _U, _L, _U, \ |
_L, _P, _P, _P, _P, _U, _L, _P, \ |
_U, _L, _U, _L, _U, _L, _U, _L, \ |
_U, _L, _U, _L, _U, _L, _U, _P, \ |
_P, _L, _U, _L, _U, _L, _U, _L, \ |
_U, _L, _U, _L, _U, _P, _P |
#define _CTYPE_CP855_255 _S|_B |
#define _CTYPE_CP857_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _U, _U, \ |
_U, _L, _U, _L, _L, _L, _L, _L, \ |
_U, _U, _U, _L, _P, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _U, _U, _L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _U, _U, _U, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _L, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _U, _U, _U, 0, _U, _U, \ |
_U, _P, _P, _P, _P, _P, _U, _P, \ |
_U, _L, _U, _U, _L, _U, _P, 0, \ |
_P, _U, _U, _U, _L, _L, _P, _P, \ |
_P, _P, 0, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP857_255 _S|_B |
#define _CTYPE_CP858_128_254 \ |
_U, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _U, _U, \ |
_U, _L, _U, _L, _L, _L, _L, _L, \ |
_L, _U, _U, _L, _P, _U, _P, _L, \ |
_L, _L, _L, _L, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _U, _U, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _L, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _U, _U, _U, _U, _P, _U, _U, \ |
_U, _P, _P, _P, _P, _P, _U, _P, \ |
_U, _L, _U, _U, _L, _U, _P, _L, \ |
_U, _U, _U, _U, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP858_255 _S|_B |
#define _CTYPE_CP862_128_254 \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _P, _P, _P, _P, _L, \ |
_L, _L, _L, _L, _L, _U, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _U, _L, _U, _L, _P, _L, \ |
_U, _U, _U, _L, _P, _L, _L, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP862_255 _S|_B |
#define _CTYPE_CP866_128_254 \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_U, _L, _U, _L, _U, _L, _U, _L, \ |
_P, _P, _P, _P, _P, _P, _P |
#define _CTYPE_CP866_255 _S|_B |
#define _CTYPE_CP874_128_254 \ |
_P, 0, 0, 0, 0, _P, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
_S|_B, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, 0, 0, 0, 0, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _U|_L, _U|_L, 0, 0, 0 |
#define _CTYPE_CP874_255 0 |
#define _CTYPE_CP1125_128_254 \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_U, _L, _U, _L, _U, _L, _U, _L, \ |
_U, _L, _P, _P, _P, _P, _P |
#define _CTYPE_CP1125_255 _S|_B |
#define _CTYPE_CP1250_128_254 \ |
_P, 0, _P, 0, _P, _P, _P, _P, \ |
0, _P, _U, _P, _U, _U, _U, _U, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
0, _P, _L, _P, _L, _L, _L, _L, \ |
_S|_B, _P, _P, _U, _P, _U, _P, _P, \ |
_P, _P, _U, _P, _P, _P, _P, _U, \ |
_P, _P, _P, _L, _P, _P, _P, _P, \ |
_P, _L, _L, _P, _U, _P, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1250_255 _P |
#define _CTYPE_CP1251_128_254 \ |
_U, _U, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _U, _P, _U, _U, _U, _U, \ |
_L, _P, _P, _P, _P, _P, _P, _P, \ |
0, _P, _L, _P, _L, _L, _L, _L, \ |
_S|_B, _U, _L, _U, _P, _U, _P, _P, \ |
_U, _P, _U, _P, _P, _P, _P, _U, \ |
_P, _P, _U, _L, _L, _P, _P, _P, \ |
_L, _P, _L, _P, _L, _U, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1251_255 _L |
#define _CTYPE_CP1252_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _U, _P, _U, _U, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _L, _P, _L, 0, _L, _U, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1252_255 _L |
#define _CTYPE_CP1253_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
0, _P, 0, _P, 0, 0, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
0, _P, 0, _P, 0, 0, 0, 0, \ |
_S|_B, _P, _U, _P, _P, _P, _P, _P, \ |
_P, _P, 0, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _P, _U, _P, _U, _U, \ |
_L, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1253_255 _L |
#define _CTYPE_CP1254_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _U, _P, _U, 0, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _L, _P, _L, 0, 0, _U, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1254_255 _L |
#define _CTYPE_CP1255_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
_P, _P, 0, _P, 0, 0, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, 0, _P, 0, 0, 0, 0, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _U|_L, _U|_L, _U|_L, _P, \ |
_P, 0, 0, 0, 0, 0, 0, 0, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, 0, 0, _P, _P |
#define _CTYPE_CP1255_255 0 |
#define _CTYPE_CP1256_128_254 \ |
_P, _U|_L, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _U|_L, _P, _U, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _P, _P, _P, _P, _P, _P, _P, \ |
_U|_L, _P, _U|_L, _P, _L, _P, _P, _U|_L, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _U|_L, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _P, _U|_L, _U|_L, _U|_L, \ |
_L, _U|_L, _L, _U|_L, _U|_L, _U|_L, _U|_L, _L, \ |
_L, _L, _L, _L, _U|_L, _U|_L, _L, _L, \ |
_P, _P, _P, _P, _L, _P, _P, _P, \ |
_P, _L, _P, _L, _L, _P, _P |
#define _CTYPE_CP1256_255 _U|_L |
#define _CTYPE_CP1257_128_254 \ |
_P, 0, _P, 0, _P, _P, _P, _P, \ |
0, _P, 0, _P, 0, _P, _P, _P, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
0, _P, 0, _P, 0, _P, _P, 0, \ |
_S|_B, 0, _P, _P, _P, 0, _P, _P, \ |
_U, _P, _U, _P, _P, _P, _P, _U, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _P, _L, _P, _P, _P, _P, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_CP1257_255 _P |
#define _CTYPE_CP1258_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
_P, _P, 0, _P, _U, 0, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, 0, _P, _L, 0, 0, _U, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _P, _U, _U, _U, \ |
_U, _U, _P, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _P, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _P, _L, _L, _L, \ |
_L, _L, _P, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _P |
#define _CTYPE_CP1258_255 _L |
#define _CTYPE_CP20866_128_254 \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _S|_B, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _U, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U |
#define _CTYPE_CP20866_255 _U |
#define _CTYPE_CP21866_128_254 \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _S|_B, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _L, _L, _P, _L, _L, \ |
_P, _P, _P, _P, _P, _L, _P, _P, \ |
_P, _P, _P, _U, _U, _P, _U, _U, \ |
_P, _P, _P, _P, _P, _U, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U |
#define _CTYPE_CP21866_255 _U |
#define _CTYPE_GEORGIAN_PS_128_254 \ |
_P, 0, _P, _L, _P, _P, _P, _P, \ |
_P, _P, _U, _P, _U, _U, 0, 0, \ |
0, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _L, _P, _L, 0, _L, _U, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_GEORGIAN_PS_255 _L |
#define _CTYPE_PT154_128_254 \ |
_U, _U, _U, _L, _P, _P, _U, _U, \ |
_U, _L, _U, _U, _U, _U, _U, _U, \ |
_L, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_S|_B, _U, _L, _U, _U, _U, _U, _P, \ |
_U, _P, _U, _P, _P, _L, _P, _U, \ |
_P, _L, _U, _L, _L, _L, _P, _P, \ |
_L, _P, _L, _P, _L, _U, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_PT154_255 _L |
extern int __cp_index (const char *charset_ext); |
#if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
#ifndef __CYGWIN__ |
static _CONST |
#endif |
char __ctype_cp[26][128 + 256] = { |
{ _CTYPE_CP437_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP437_128_254, |
_CTYPE_CP437_255 |
}, |
{ _CTYPE_CP720_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP720_128_254, |
_CTYPE_CP720_255 |
}, |
{ _CTYPE_CP737_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP737_128_254, |
_CTYPE_CP737_255 |
}, |
{ _CTYPE_CP775_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP775_128_254, |
_CTYPE_CP775_255 |
}, |
{ _CTYPE_CP850_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP850_128_254, |
_CTYPE_CP850_255 |
}, |
{ _CTYPE_CP852_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP852_128_254, |
_CTYPE_CP852_255 |
}, |
{ _CTYPE_CP855_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP855_128_254, |
_CTYPE_CP855_255 |
}, |
{ _CTYPE_CP857_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP857_128_254, |
_CTYPE_CP857_255 |
}, |
{ _CTYPE_CP858_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP858_128_254, |
_CTYPE_CP858_255 |
}, |
{ _CTYPE_CP862_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP862_128_254, |
_CTYPE_CP862_255 |
}, |
{ _CTYPE_CP866_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP866_128_254, |
_CTYPE_CP866_255 |
}, |
{ _CTYPE_CP874_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP874_128_254, |
_CTYPE_CP874_255 |
}, |
{ _CTYPE_CP1125_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1125_128_254, |
_CTYPE_CP1125_255 |
}, |
{ _CTYPE_CP1250_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1250_128_254, |
_CTYPE_CP1250_255 |
}, |
{ _CTYPE_CP1251_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1251_128_254, |
_CTYPE_CP1251_255 |
}, |
{ _CTYPE_CP1252_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1252_128_254, |
_CTYPE_CP1252_255 |
}, |
{ _CTYPE_CP1253_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1253_128_254, |
_CTYPE_CP1253_255 |
}, |
{ _CTYPE_CP1254_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1254_128_254, |
_CTYPE_CP1254_255 |
}, |
{ _CTYPE_CP1255_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1255_128_254, |
_CTYPE_CP1255_255 |
}, |
{ _CTYPE_CP1256_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1256_128_254, |
_CTYPE_CP1256_255 |
}, |
{ _CTYPE_CP1257_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1257_128_254, |
_CTYPE_CP1257_255 |
}, |
{ _CTYPE_CP1258_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1258_128_254, |
_CTYPE_CP1258_255 |
}, |
{ _CTYPE_CP20866_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP20866_128_254, |
_CTYPE_CP20866_255 |
}, |
{ _CTYPE_CP21866_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP21866_128_254, |
_CTYPE_CP21866_255 |
}, |
{ _CTYPE_GEORGIAN_PS_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_GEORGIAN_PS_128_254, |
_CTYPE_GEORGIAN_PS_255 |
}, |
{ _CTYPE_PT154_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_PT154_128_254, |
_CTYPE_PT154_255 |
}, |
}; |
#else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */ |
static _CONST char __ctype_cp[26][1 + 256] = { |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP437_128_254, |
_CTYPE_CP437_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP720_128_254, |
_CTYPE_CP720_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP737_128_254, |
_CTYPE_CP737_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP775_128_254, |
_CTYPE_CP775_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP850_128_254, |
_CTYPE_CP850_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP852_128_254, |
_CTYPE_CP852_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP855_128_254, |
_CTYPE_CP855_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP857_128_254, |
_CTYPE_CP857_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP858_128_254, |
_CTYPE_CP858_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP862_128_254, |
_CTYPE_CP862_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP866_128_254, |
_CTYPE_CP866_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP874_128_254, |
_CTYPE_CP874_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1125_128_254, |
_CTYPE_CP1125_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1250_128_254, |
_CTYPE_CP1250_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1251_128_254, |
_CTYPE_CP1251_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1252_128_254, |
_CTYPE_CP1252_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1253_128_254, |
_CTYPE_CP1253_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1254_128_254, |
_CTYPE_CP1254_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1255_128_254, |
_CTYPE_CP1255_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1256_128_254, |
_CTYPE_CP1256_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1257_128_254, |
_CTYPE_CP1257_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP1258_128_254, |
_CTYPE_CP1258_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP20866_128_254, |
_CTYPE_CP20866_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_CP21866_128_254, |
_CTYPE_CP21866_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_GEORGIAN_PS_128_254, |
_CTYPE_GEORGIAN_PS_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_PT154_128_254, |
_CTYPE_PT154_255 |
}, |
}; |
#endif /* ALLOW_NEGATIVE_CTYPE_INDEX */ |
/contrib/sdk/sources/libc/ctype/ctype_iso.h |
---|
0,0 → 1,455 |
/* ctype table definitions for ISO-8859-x charsets. |
Included by ctype_.c. */ |
#define _CTYPE_ISO_8859_1_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_1_255 _L |
#define _CTYPE_ISO_8859_2_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _P, _U, _P, _U, _U, _P, \ |
_P, _U, _U, _U, _U, _P, _U, _U, \ |
_P, _L, _P, _L, _P, _L, _L, _P, \ |
_P, _L, _L, _L, _L, _P, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_2_255 _P |
#define _CTYPE_ISO_8859_3_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _P, _P, _P, 0, _U, _P, \ |
_P, _U, _U, _U, _U, _P, 0, _U, \ |
_P, _L, _P, _P, _P, _P, _L, _P, \ |
_P, _L, _L, _L, _L, _P, 0, _L, \ |
_U, _U, _U, 0, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
0, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, 0, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
0, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_3_255 _P |
#define _CTYPE_ISO_8859_4_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _L, _U, _P, _U, _U, _P, \ |
_P, _U, _U, _U, _U, _P, _U, _P, \ |
_P, _L, _P, _L, _P, _L, _L, _P, \ |
_P, _L, _L, _L, _L, _P, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_4_255 _L |
#define _CTYPE_ISO_8859_5_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _P, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_P, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _P, _L |
#define _CTYPE_ISO_8859_5_255 _L |
#define _CTYPE_ISO_8859_6_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, 0, 0, 0, _P, 0, 0, 0, \ |
0, 0, 0, 0, _P, _P, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, _P, 0, 0, 0, _P, \ |
0, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, 0, 0, 0, 0, 0, \ |
_P, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _P, _P, _P, _P, _P, \ |
_P, _P, _P, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0 |
#define _CTYPE_ISO_8859_6_255 0 |
#define _CTYPE_ISO_8859_7_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, 0, _P, \ |
_P, _P, _P, _P, _P, _P, _U, _P, \ |
_U, _U, _U, _P, _U, _P, _U, _U, \ |
_L, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_7_255 0 |
#define _CTYPE_ISO_8859_8_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, 0, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, 0, \ |
0, 0, 0, 0, 0, 0, 0, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, 0, 0, _P, _P |
#define _CTYPE_ISO_8859_8_255 0 |
#define _CTYPE_ISO_8859_9_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_9_255 _L |
#define _CTYPE_ISO_8859_10_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _P, _U, _U, \ |
_P, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _P, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_10_255 _L |
#define _CTYPE_ISO_8859_11_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _P, _U|_L, _U|_L, _P, _P, _P, _P, \ |
_P, _P, _P, 0, 0, 0, 0, _P, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, _U|_L, \ |
_U|_L, _U|_L, _U|_L, _U|_L, 0, 0, 0 |
#define _CTYPE_ISO_8859_11_255 0 |
#define _CTYPE_ISO_8859_13_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _P, _P, \ |
_U, _P, _U, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _P, _P, _P, _P, \ |
_L, _P, _L, _P, _P, _P, _P, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_13_255 _P |
#define _CTYPE_ISO_8859_14_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _L, _P, _U, _L, _U, _P, \ |
_U, _P, _U, _L, _U, _P, _P, _U, \ |
_U, _L, _U, _L, _U, _L, _P, _U, \ |
_L, _L, _L, _U, _L, _U, _L, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_14_255 _L |
#define _CTYPE_ISO_8859_15_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _P, _P, _P, _P, _P, _U, _P, \ |
_L, _P, _P, _P, _P, _P, _P, _P, \ |
_P, _P, _P, _P, _U, _P, _P, _P, \ |
_L, _P, _P, _P, _U, _L, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _P, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _P, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_15_255 _L |
#define _CTYPE_ISO_8859_16_128_254 \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_C, _C, _C, _C, _C, _C, _C, _C, \ |
_S|_B, _U, _L, _U, _P, _P, _U, _P, \ |
_L, _P, _U, _P, _U, _P, _L, _U, \ |
_P, _P, _U, _U, _U, _P, _P, _P, \ |
_L, _L, _L, _P, _U, _L, _U, _L, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _U, \ |
_U, _U, _U, _U, _U, _U, _U, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L, _L, \ |
_L, _L, _L, _L, _L, _L, _L |
#define _CTYPE_ISO_8859_16_255 _L |
extern int __iso_8859_index (const char *charset_ext); |
#if defined(ALLOW_NEGATIVE_CTYPE_INDEX) |
#ifndef __CYGWIN__ |
static _CONST |
#endif |
char __ctype_iso[15][128 + 256] = { |
{ _CTYPE_ISO_8859_1_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_1_128_254, |
_CTYPE_ISO_8859_1_255 |
}, |
{ _CTYPE_ISO_8859_2_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_2_128_254, |
_CTYPE_ISO_8859_2_255 |
}, |
{ _CTYPE_ISO_8859_3_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_3_128_254, |
_CTYPE_ISO_8859_3_255 |
}, |
{ _CTYPE_ISO_8859_4_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_4_128_254, |
_CTYPE_ISO_8859_4_255 |
}, |
{ _CTYPE_ISO_8859_5_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_5_128_254, |
_CTYPE_ISO_8859_5_255 |
}, |
{ _CTYPE_ISO_8859_6_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_6_128_254, |
_CTYPE_ISO_8859_6_255 |
}, |
{ _CTYPE_ISO_8859_7_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_7_128_254, |
_CTYPE_ISO_8859_7_255 |
}, |
{ _CTYPE_ISO_8859_8_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_8_128_254, |
_CTYPE_ISO_8859_8_255 |
}, |
{ _CTYPE_ISO_8859_9_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_9_128_254, |
_CTYPE_ISO_8859_9_255 |
}, |
{ _CTYPE_ISO_8859_10_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_10_128_254, |
_CTYPE_ISO_8859_10_255 |
}, |
{ _CTYPE_ISO_8859_11_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_11_128_254, |
_CTYPE_ISO_8859_11_255 |
}, |
{ _CTYPE_ISO_8859_13_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_13_128_254, |
_CTYPE_ISO_8859_13_255 |
}, |
{ _CTYPE_ISO_8859_14_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_14_128_254, |
_CTYPE_ISO_8859_14_255 |
}, |
{ _CTYPE_ISO_8859_15_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_15_128_254, |
_CTYPE_ISO_8859_15_255 |
}, |
{ _CTYPE_ISO_8859_16_128_254, |
0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_16_128_254, |
_CTYPE_ISO_8859_16_255 |
}, |
}; |
#else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */ |
static _CONST char __ctype_iso[15][1 + 256] = { |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_1_128_254, |
_CTYPE_ISO_8859_1_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_2_128_254, |
_CTYPE_ISO_8859_2_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_3_128_254, |
_CTYPE_ISO_8859_3_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_4_128_254, |
_CTYPE_ISO_8859_4_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_5_128_254, |
_CTYPE_ISO_8859_5_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_6_128_254, |
_CTYPE_ISO_8859_6_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_7_128_254, |
_CTYPE_ISO_8859_7_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_8_128_254, |
_CTYPE_ISO_8859_8_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_9_128_254, |
_CTYPE_ISO_8859_9_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_10_128_254, |
_CTYPE_ISO_8859_10_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_11_128_254, |
_CTYPE_ISO_8859_11_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_13_128_254, |
_CTYPE_ISO_8859_13_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_14_128_254, |
_CTYPE_ISO_8859_14_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_15_128_254, |
_CTYPE_ISO_8859_15_255 |
}, |
{ 0, |
_CTYPE_DATA_0_127, |
_CTYPE_ISO_8859_16_128_254, |
_CTYPE_ISO_8859_16_255 |
}, |
}; |
#endif /* ALLOW_NEGATIVE_CTYPE_INDEX */ |
/contrib/sdk/sources/libc/ctype/isalnum.c |
---|
0,0 → 1,46 |
/* |
FUNCTION |
<<isalnum>>---alphanumeric character predicate |
INDEX |
isalnum |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isalnum(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isalnum(<[c]>); |
DESCRIPTION |
<<isalnum>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for alphabetic or |
numeric ASCII characters, and <<0>> for other arguments. It is defined |
for all integer values. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isalnum>>'. |
RETURNS |
<<isalnum>> returns non-zero if <[c]> is a letter (<<a>>--<<z>> or |
<<A>>--<<Z>>) or a digit (<<0>>--<<9>>). |
PORTABILITY |
<<isalnum>> is ANSI C. |
No OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isalnum |
int |
_DEFUN(isalnum,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & (_U|_L|_N)); |
} |
/contrib/sdk/sources/libc/ctype/isalpha.c |
---|
0,0 → 1,44 |
/* |
FUNCTION |
<<isalpha>>---alphabetic character predicate |
INDEX |
isalpha |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isalpha(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isalpha(<[c]>); |
DESCRIPTION |
<<isalpha>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero when <[c]> represents an |
alphabetic ASCII character, and 0 otherwise. It is defined only when |
<<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isalpha>>'. |
RETURNS |
<<isalpha>> returns non-zero if <[c]> is a letter (<<A>>--<<Z>> or |
<<a>>--<<z>>). |
PORTABILITY |
<<isalpha>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isalpha |
int |
_DEFUN(isalpha,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & (_U|_L)); |
} |
/contrib/sdk/sources/libc/ctype/isascii.c |
---|
0,0 → 1,43 |
/* |
FUNCTION |
<<isascii>>---ASCII character predicate |
INDEX |
isascii |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isascii(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isascii(<[c]>); |
DESCRIPTION |
<<isascii>> is a macro which returns non-zero when <[c]> is an ASCII |
character, and 0 otherwise. It is defined for all integer values. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isascii>>'. |
RETURNS |
<<isascii>> returns non-zero if the low order byte of <[c]> is in the range |
0 to 127 (<<0x00>>--<<0x7F>>). |
PORTABILITY |
<<isascii>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isascii |
int |
_DEFUN(isascii,(c),int c) |
{ |
return c >= 0 && c< 128; |
} |
/contrib/sdk/sources/libc/ctype/isblank.c |
---|
0,0 → 1,41 |
/* |
FUNCTION |
<<isblank>>---blank character predicate |
INDEX |
isblank |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isblank(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isblank(<[c]>); |
DESCRIPTION |
<<isblank>> is a function which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for blank characters, and 0 |
for other characters. |
RETURNS |
<<isblank>> returns non-zero if <[c]> is a blank character. |
PORTABILITY |
<<isblank>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isblank |
int |
_DEFUN(isblank,(c),int c) |
{ |
return ((__ctype_ptr__[c+1] & _B) || (c == '\t')); |
} |
/contrib/sdk/sources/libc/ctype/iscntrl.c |
---|
0,0 → 1,48 |
/* |
FUNCTION |
<<iscntrl>>---control character predicate |
INDEX |
iscntrl |
ANSI_SYNOPSIS |
#include <ctype.h> |
int iscntrl(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int iscntrl(<[c]>); |
DESCRIPTION |
<<iscntrl>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for control characters, and 0 |
for other characters. It is defined only when <<isascii>>(<[c]>) is |
true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef iscntrl>>'. |
RETURNS |
<<iscntrl>> returns non-zero if <[c]> is a delete character or ordinary |
control character (<<0x7F>> or <<0x00>>--<<0x1F>>). |
PORTABILITY |
<<iscntrl>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef iscntrl |
int |
_DEFUN(iscntrl,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & _C); |
} |
/contrib/sdk/sources/libc/ctype/isdigit.c |
---|
0,0 → 1,43 |
/* |
FUNCTION |
<<isdigit>>---decimal digit predicate |
INDEX |
isdigit |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isdigit(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isdigit(<[c]>); |
DESCRIPTION |
<<isdigit>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for decimal digits, and 0 for |
other characters. It is defined only when <<isascii>>(<[c]>) is true |
or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isdigit>>'. |
RETURNS |
<<isdigit>> returns non-zero if <[c]> is a decimal digit (<<0>>--<<9>>). |
PORTABILITY |
<<isdigit>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isdigit |
int |
_DEFUN(isdigit,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & _N); |
} |
/contrib/sdk/sources/libc/ctype/islower.c |
---|
0,0 → 1,43 |
/* |
FUNCTION |
<<islower>>---lowercase character predicate |
INDEX |
islower |
ANSI_SYNOPSIS |
#include <ctype.h> |
int islower(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int islower(<[c]>); |
DESCRIPTION |
<<islower>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for minuscules |
(lowercase alphabetic characters), and 0 for other characters. |
It is defined only when <<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef islower>>'. |
RETURNS |
<<islower>> returns non-zero if <[c]> is a lowercase letter (<<a>>--<<z>>). |
PORTABILITY |
<<islower>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef islower |
int |
_DEFUN(islower,(c),int c) |
{ |
return ((__ctype_ptr__[c+1] & (_U|_L)) == _L); |
} |
/contrib/sdk/sources/libc/ctype/isprint.c |
---|
0,0 → 1,60 |
/* |
FUNCTION |
<<isprint>>, <<isgraph>>---printable character predicates |
INDEX |
isprint |
INDEX |
isgraph |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isprint(int <[c]>); |
int isgraph(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isprint(<[c]>); |
int isgraph(<[c]>); |
DESCRIPTION |
<<isprint>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for printable |
characters, and 0 for other character arguments. |
It is defined only when <<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining either macro using `<<#undef isprint>>' or `<<#undef isgraph>>'. |
RETURNS |
<<isprint>> returns non-zero if <[c]> is a printing character, |
(<<0x20>>--<<0x7E>>). |
<<isgraph>> behaves identically to <<isprint>>, except that the space |
character (<<0x20>>) is excluded. |
PORTABILITY |
<<isprint>> and <<isgraph>> are ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isgraph |
int |
_DEFUN(isgraph,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & (_P|_U|_L|_N)); |
} |
#undef isprint |
int |
_DEFUN(isprint,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & (_P|_U|_L|_N|_B)); |
} |
/contrib/sdk/sources/libc/ctype/ispunct.c |
---|
0,0 → 1,46 |
/* |
FUNCTION |
<<ispunct>>---punctuation character predicate |
INDEX |
ispunct |
ANSI_SYNOPSIS |
#include <ctype.h> |
int ispunct(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int ispunct(<[c]>); |
DESCRIPTION |
<<ispunct>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for printable |
punctuation characters, and 0 for other characters. It is defined |
only when <<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef ispunct>>'. |
RETURNS |
<<ispunct>> returns non-zero if <[c]> is a printable punctuation character |
(<<isgraph(<[c]>) && !isalnum(<[c]>)>>). |
PORTABILITY |
<<ispunct>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef ispunct |
int |
_DEFUN(ispunct,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & _P); |
} |
/contrib/sdk/sources/libc/ctype/isspace.c |
---|
0,0 → 1,44 |
/* |
FUNCTION |
<<isspace>>---whitespace character predicate |
INDEX |
isspace |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isspace(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isspace(<[c]>); |
DESCRIPTION |
<<isspace>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for whitespace |
characters, and 0 for other characters. It is defined only when <<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isspace>>'. |
RETURNS |
<<isspace>> returns non-zero if <[c]> is a space, tab, carriage return, new |
line, vertical tab, or formfeed (<<0x09>>--<<0x0D>>, <<0x20>>). |
PORTABILITY |
<<isspace>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isspace |
int |
_DEFUN(isspace,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & _S); |
} |
/contrib/sdk/sources/libc/ctype/isupper.c |
---|
0,0 → 1,43 |
/* |
FUNCTION |
<<isupper>>---uppercase character predicate |
INDEX |
isupper |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isupper(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isupper(<[c]>); |
DESCRIPTION |
<<isupper>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for uppercase letters |
(<<A>>--<<Z>>), and 0 for other characters. It is defined only when |
<<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isupper>>'. |
RETURNS |
<<isupper>> returns non-zero if <[c]> is a uppercase letter (A-Z). |
PORTABILITY |
<<isupper>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isupper |
int |
_DEFUN(isupper,(c),int c) |
{ |
return ((__ctype_ptr__[c+1] & (_U|_L)) == _U); |
} |
/contrib/sdk/sources/libc/ctype/iswalnum.c |
---|
0,0 → 1,37 |
/* |
FUNCTION |
<<iswalnum>>---alphanumeric wide character test |
INDEX |
iswalnum |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswalnum(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswalnum(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswalnum>> is a function which classifies wide-character values that |
are alphanumeric. |
RETURNS |
<<iswalnum>> returns non-zero if <[c]> is a alphanumeric wide character. |
PORTABILITY |
<<iswalnum>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswalnum,(c),wint_t c) |
{ |
return (iswalpha (c) || iswdigit (c)); |
} |
/contrib/sdk/sources/libc/ctype/iswalpha.c |
---|
0,0 → 1,433 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswalpha>>---alphabetic wide character test |
INDEX |
iswalpha |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswalpha(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswalpha(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswalpha>> is a function which classifies wide-character values that |
are alphabetic. |
RETURNS |
<<iswalpha>> returns non-zero if <[c]> is an alphabetic wide character. |
PORTABILITY |
<<iswalpha>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <string.h> |
#include <ctype.h> |
#include "local.h" |
#ifdef _MB_CAPABLE |
#include "utf8alpha.h" |
#endif /* _MB_CAPABLE */ |
int |
_DEFUN(iswalpha,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
unsigned const char *table; |
unsigned char *ptr; |
unsigned char ctmp; |
int size; |
wint_t x; |
c = _jp2uc (c); |
/* Based on and tested against Unicode 5.2 |
See utf8alpha.h for a description how to fetch the data. */ |
x = (c >> 8); |
/* for some large sections, all characters are alphabetic so handle them here */ |
if ((x >= 0x34 && x <= 0x4c) || |
(x >= 0x4e && x <= 0x9e) || |
(x >= 0xac && x <= 0xd6) || |
(x >= 0x120 && x <= 0x122) || |
(x >= 0x130 && x <= 0x133) || |
(x >= 0x200 && x <= 0x2a5) || |
(x >= 0x2a7 && x <= 0x2b6)) |
return 1; |
switch (x) |
{ |
case 0x00: |
table = u0; |
size = sizeof(u0); |
break; |
case 0x01: |
case 0x11: |
case 0x15: |
case 0x1e: |
case 0xa0: |
case 0xa1: |
case 0xa2: |
case 0xa3: |
case 0xa5: |
case 0xf9: |
case 0xfc: |
case 0x2f8: |
case 0x2f9: |
return 1; |
case 0x02: |
table = u2; |
size = sizeof(u2); |
break; |
case 0x03: |
table = u3; |
size = sizeof(u3); |
break; |
case 0x04: |
table = u4; |
size = sizeof(u4); |
break; |
case 0x05: |
table = u5; |
size = sizeof(u5); |
break; |
case 0x06: |
table = u6; |
size = sizeof(u6); |
break; |
case 0x07: |
table = u7; |
size = sizeof(u7); |
break; |
case 0x08: |
table = u8; |
size = sizeof(u8); |
break; |
case 0x09: |
table = u9; |
size = sizeof(u9); |
break; |
case 0x0a: |
table = ua; |
size = sizeof(ua); |
break; |
case 0x0b: |
table = ub; |
size = sizeof(ub); |
break; |
case 0x0c: |
table = uc; |
size = sizeof(uc); |
break; |
case 0x0d: |
table = ud; |
size = sizeof(ud); |
break; |
case 0x0e: |
table = ue; |
size = sizeof(ue); |
break; |
case 0x0f: |
table = uf; |
size = sizeof(uf); |
break; |
case 0x10: |
table = u10; |
size = sizeof(u10); |
break; |
case 0x12: |
table = u12; |
size = sizeof(u12); |
break; |
case 0x13: |
table = u13; |
size = sizeof(u13); |
break; |
case 0x14: |
table = u14; |
size = sizeof(u14); |
break; |
case 0x16: |
table = u16; |
size = sizeof(u16); |
break; |
case 0x17: |
table = u17; |
size = sizeof(u17); |
break; |
case 0x18: |
table = u18; |
size = sizeof(u18); |
break; |
case 0x19: |
table = u19; |
size = sizeof(u19); |
break; |
case 0x1a: |
table = u1a; |
size = sizeof(u1a); |
break; |
case 0x1b: |
table = u1b; |
size = sizeof(u1b); |
break; |
case 0x1c: |
table = u1c; |
size = sizeof(u1c); |
break; |
case 0x1d: |
table = u1d; |
size = sizeof(u1d); |
break; |
case 0x1f: |
table = u1f; |
size = sizeof(u1f); |
break; |
case 0x20: |
table = u20; |
size = sizeof(u20); |
break; |
case 0x21: |
table = u21; |
size = sizeof(u21); |
break; |
case 0x24: |
table = u24; |
size = sizeof(u24); |
break; |
case 0x2c: |
table = u2c; |
size = sizeof(u2c); |
break; |
case 0x2d: |
table = u2d; |
size = sizeof(u2d); |
break; |
case 0x2e: |
table = u2e; |
size = sizeof(u2e); |
break; |
case 0x30: |
table = u30; |
size = sizeof(u30); |
break; |
case 0x31: |
table = u31; |
size = sizeof(u31); |
break; |
case 0x4d: |
table = u4d; |
size = sizeof(u4d); |
break; |
case 0x9f: |
table = u9f; |
size = sizeof(u9f); |
break; |
case 0xa4: |
table = ua4; |
size = sizeof(ua4); |
break; |
case 0xa6: |
table = ua6; |
size = sizeof(ua6); |
break; |
case 0xa7: |
table = ua7; |
size = sizeof(ua7); |
break; |
case 0xa8: |
table = ua8; |
size = sizeof(ua8); |
break; |
case 0xa9: |
table = ua9; |
size = sizeof(ua9); |
break; |
case 0xaa: |
table = uaa; |
size = sizeof(uaa); |
break; |
case 0xab: |
table = uab; |
size = sizeof(uab); |
break; |
case 0xd7: |
table = ud7; |
size = sizeof(ud7); |
break; |
case 0xfa: |
table = ufa; |
size = sizeof(ufa); |
break; |
case 0xfb: |
table = ufb; |
size = sizeof(ufb); |
break; |
case 0xfd: |
table = ufd; |
size = sizeof(ufd); |
break; |
case 0xfe: |
table = ufe; |
size = sizeof(ufe); |
break; |
case 0xff: |
table = uff; |
size = sizeof(uff); |
break; |
case 0x100: |
table = u100; |
size = sizeof(u100); |
break; |
case 0x101: |
table = u101; |
size = sizeof(u101); |
break; |
case 0x102: |
table = u102; |
size = sizeof(u102); |
break; |
case 0x103: |
table = u103; |
size = sizeof(u103); |
break; |
case 0x104: |
table = u104; |
size = sizeof(u104); |
break; |
case 0x108: |
table = u108; |
size = sizeof(u108); |
break; |
case 0x109: |
table = u109; |
size = sizeof(u109); |
break; |
case 0x10a: |
table = u10a; |
size = sizeof(u10a); |
break; |
case 0x10b: |
table = u10b; |
size = sizeof(u10b); |
break; |
case 0x10c: |
table = u10c; |
size = sizeof(u10c); |
break; |
case 0x110: |
table = u110; |
size = sizeof(u110); |
break; |
case 0x123: |
table = u123; |
size = sizeof(u123); |
break; |
case 0x124: |
table = u124; |
size = sizeof(u124); |
break; |
case 0x134: |
table = u134; |
size = sizeof(u134); |
break; |
case 0x1d4: |
table = u1d4; |
size = sizeof(u1d4); |
break; |
case 0x1d5: |
table = u1d5; |
size = sizeof(u1d5); |
break; |
case 0x1d6: |
table = u1d6; |
size = sizeof(u1d6); |
break; |
case 0x1d7: |
table = u1d7; |
size = sizeof(u1d7); |
break; |
case 0x1f1: |
table = u1f1; |
size = sizeof(u1f1); |
break; |
case 0x2a6: |
table = u2a6; |
size = sizeof(u2a6); |
break; |
case 0x2b7: |
table = u2b7; |
size = sizeof(u2b7); |
break; |
case 0x2fa: |
table = u2fa; |
size = sizeof(u2fa); |
break; |
default: |
return 0; |
} |
/* we have narrowed down to a section of 256 characters to check */ |
/* now check if c matches the alphabetic wide-chars within that section */ |
ptr = (unsigned char *)table; |
ctmp = (unsigned char)c; |
while (ptr < table + size) |
{ |
if (ctmp == *ptr) |
return 1; |
if (ctmp < *ptr) |
return 0; |
/* otherwise c > *ptr */ |
/* look for 0x0 as next element which indicates a range */ |
++ptr; |
if (*ptr == 0x0) |
{ |
/* we have a range..see if c falls within range */ |
++ptr; |
if (ctmp <= *ptr) |
return 1; |
++ptr; |
} |
} |
/* not in table */ |
return 0; |
#else |
return (c < (wint_t)0x100 ? isalpha (c) : 0); |
#endif /* _MB_CAPABLE */ |
} |
/contrib/sdk/sources/libc/ctype/iswblank.c |
---|
0,0 → 1,82 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswblank>>---blank wide character test |
INDEX |
iswblank |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswblank(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswblank(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswblank>> is a function which classifies wide-character values that |
are categorized as blank. |
RETURNS |
<<iswblank>> returns non-zero if <[c]> is a blank wide character. |
PORTABILITY |
<<iswblank>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <ctype.h> |
#include <string.h> |
#include "local.h" |
int |
_DEFUN(iswblank,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
c = _jp2uc (c); |
/* Based on Unicode 5.2. Control char 09, plus all characters |
from general category "Zs", which are not marked as decomposition |
type "noBreak". */ |
return (c == 0x0009 || c == 0x0020 || |
c == 0x1680 || c == 0x180e || |
(c >= 0x2000 && c <= 0x2006) || |
(c >= 0x2008 && c <= 0x200a) || |
c == 0x205f || c == 0x3000); |
#else |
return (c < 0x100 ? isblank (c) : 0); |
#endif /* _MB_CAPABLE */ |
} |
/contrib/sdk/sources/libc/ctype/iswcntrl.c |
---|
0,0 → 1,80 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswcntrl>>---control wide character test |
INDEX |
iswcntrl |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswcntrl(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswcntrl(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswcntrl>> is a function which classifies wide-character values that |
are categorized as control characters. |
RETURNS |
<<iswcntrl>> returns non-zero if <[c]> is a control wide character. |
PORTABILITY |
<<iswcntrl>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <ctype.h> |
#include <string.h> |
#include "local.h" |
int |
_DEFUN(iswcntrl,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
c = _jp2uc (c); |
/* Based on Unicode 5.2. All characters from general category "Cc", "Zl", |
and "Zp". */ |
return ((c >= 0x0000 && c <= 0x001f) || |
(c >= 0x007f && c <= 0x009f) || |
c == 0x2028 || c == 0x2029); |
#else |
return (c < 0x100 ? iscntrl (c) : 0); |
#endif /* _MB_CAPABLE */ |
} |
/contrib/sdk/sources/libc/ctype/iswctype.c |
---|
0,0 → 1,71 |
/* |
FUNCTION |
<<iswctype>>---extensible wide-character test |
INDEX |
iswctype |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswctype(wint_t <[c]>, wctype_t <[desc]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswctype(<[c]>, <[desc]>) |
wint_t <[c]>; |
wctype_t <[desc]>; |
DESCRIPTION |
<<iswctype>> is a function which classifies wide-character values using the |
wide-character test specified by <[desc]>. |
RETURNS |
<<iswctype>> returns non-zero if and only if <[c]> matches the test specified by <[desc]>. |
If <[desc]> is unknown, zero is returned. |
PORTABILITY |
<<iswctype>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
#include "local.h" |
int |
_DEFUN(iswctype,(c, desc), wint_t c _AND wctype_t desc) |
{ |
switch (desc) |
{ |
case WC_ALNUM: |
return iswalnum (c); |
case WC_ALPHA: |
return iswalpha (c); |
case WC_BLANK: |
return iswblank (c); |
case WC_CNTRL: |
return iswcntrl (c); |
case WC_DIGIT: |
return iswdigit (c); |
case WC_GRAPH: |
return iswgraph (c); |
case WC_LOWER: |
return iswlower (c); |
case WC_PRINT: |
return iswprint (c); |
case WC_PUNCT: |
return iswpunct (c); |
case WC_SPACE: |
return iswspace (c); |
case WC_UPPER: |
return iswupper (c); |
case WC_XDIGIT: |
return iswxdigit (c); |
default: |
return 0; /* eliminate warning */ |
} |
/* otherwise unknown */ |
return 0; |
} |
/contrib/sdk/sources/libc/ctype/iswdigit.c |
---|
0,0 → 1,37 |
/* |
FUNCTION |
<<iswdigit>>---decimal digit wide character test |
INDEX |
iswdigit |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswdigit(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswdigit(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswdigit>> is a function which classifies wide-character values that |
are decimal digits. |
RETURNS |
<<iswdigit>> returns non-zero if <[c]> is a decimal digit wide character. |
PORTABILITY |
<<iswdigit>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswdigit,(c), wint_t c) |
{ |
return (c >= (wint_t)'0' && c <= (wint_t)'9'); |
} |
/contrib/sdk/sources/libc/ctype/iswgraph.c |
---|
0,0 → 1,66 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswgraph>>---graphic wide character test |
INDEX |
iswgraph |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswgraph(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswgraph(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswgraph>> is a function which classifies wide-character values that |
are graphic. |
RETURNS |
<<iswgraph>> returns non-zero if <[c]> is a graphic wide character. |
PORTABILITY |
<<iswgraph>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswgraph,(c),wint_t c) |
{ |
return (iswprint (c) && !iswspace (c)); |
} |
/contrib/sdk/sources/libc/ctype/iswlower.c |
---|
0,0 → 1,38 |
/* |
FUNCTION |
<<iswlower>>---lowercase wide character test |
INDEX |
iswlower |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswlower(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswlower(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswlower>> is a function which classifies wide-character values that |
have uppercase translations. |
RETURNS |
<<iswlower>> returns non-zero if <[c]> is a lowercase wide character. |
PORTABILITY |
<<iswlower>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswlower,(c),wint_t c) |
{ |
return (towupper (c) != c); |
} |
/contrib/sdk/sources/libc/ctype/iswprint.c |
---|
0,0 → 1,496 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswprint>>---printable wide character test |
INDEX |
iswprint |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswprint(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswprint(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswprint>> is a function which classifies wide-character values that |
are printable. |
RETURNS |
<<iswprint>> returns non-zero if <[c]> is a printable wide character. |
PORTABILITY |
<<iswprint>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <string.h> |
#include <ctype.h> |
#include "local.h" |
#ifdef _MB_CAPABLE |
#include "utf8print.h" |
#endif /* _MB_CAPABLE */ |
int |
_DEFUN(iswprint,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
unsigned const char *table; |
unsigned char *ptr; |
unsigned char ctmp; |
int size; |
wint_t x; |
c = _jp2uc (c); |
/* Based on and tested against Unicode 5.2 |
See utf8print.h for a description how to fetch the data. */ |
x = (c >> 8); |
/* for some large sections, all characters are printuation so handle them here */ |
if ((x >= 0x33 && x <= 0x4c) || |
(x >= 0x4e && x <= 0x9e) || |
(x >= 0xa0 && x <= 0xa3) || |
(x >= 0xac && x <= 0xd6) || |
(x >= 0xe0 && x <= 0xf9) || |
(x >= 0x120 && x <= 0x122) || |
(x >= 0x130 && x <= 0x133) || |
(x >= 0x200 && x <= 0x2a5) || |
(x >= 0x2a7 && x <= 0x2b6) || |
(x >= 0xf00 && x <= 0xffe) || |
(x >= 0x1000 && x <= 0x10fe)) |
return 1; |
switch (x) |
{ |
case 0x01: |
case 0x02: |
case 0x04: |
case 0x11: |
case 0x14: |
case 0x15: |
case 0x1e: |
case 0x22: |
case 0x25: |
case 0x28: |
case 0x29: |
case 0x2a: |
case 0xa5: |
case 0xfc: |
case 0x2f8: |
case 0x2f9: |
return 1; |
case 0x00: |
table = u0; |
size = sizeof(u0); |
break; |
case 0x03: |
table = u3; |
size = sizeof(u3); |
break; |
case 0x05: |
table = u5; |
size = sizeof(u5); |
break; |
case 0x06: |
table = u6; |
size = sizeof(u6); |
break; |
case 0x07: |
table = u7; |
size = sizeof(u7); |
break; |
case 0x08: |
table = u8; |
size = sizeof(u8); |
break; |
case 0x09: |
table = u9; |
size = sizeof(u9); |
break; |
case 0x0a: |
table = ua; |
size = sizeof(ua); |
break; |
case 0x0b: |
table = ub; |
size = sizeof(ub); |
break; |
case 0x0c: |
table = uc; |
size = sizeof(uc); |
break; |
case 0x0d: |
table = ud; |
size = sizeof(ud); |
break; |
case 0x0e: |
table = ue; |
size = sizeof(ue); |
break; |
case 0x0f: |
table = uf; |
size = sizeof(uf); |
break; |
case 0x10: |
table = u10; |
size = sizeof(u10); |
break; |
case 0x12: |
table = u12; |
size = sizeof(u12); |
break; |
case 0x13: |
table = u13; |
size = sizeof(u13); |
break; |
case 0x16: |
table = u16; |
size = sizeof(u16); |
break; |
case 0x17: |
table = u17; |
size = sizeof(u17); |
break; |
case 0x18: |
table = u18; |
size = sizeof(u18); |
break; |
case 0x19: |
table = u19; |
size = sizeof(u19); |
break; |
case 0x1a: |
table = u1a; |
size = sizeof(u1a); |
break; |
case 0x1b: |
table = u1b; |
size = sizeof(u1b); |
break; |
case 0x1c: |
table = u1c; |
size = sizeof(u1c); |
break; |
case 0x1d: |
table = u1d; |
size = sizeof(u1d); |
break; |
case 0x1f: |
table = u1f; |
size = sizeof(u1f); |
break; |
case 0x20: |
table = u20; |
size = sizeof(u20); |
break; |
case 0x21: |
table = u21; |
size = sizeof(u21); |
break; |
case 0x23: |
table = u23; |
size = sizeof(u23); |
break; |
case 0x24: |
table = u24; |
size = sizeof(u24); |
break; |
case 0x26: |
table = u26; |
size = sizeof(u26); |
break; |
case 0x27: |
table = u27; |
size = sizeof(u27); |
break; |
case 0x2b: |
table = u2b; |
size = sizeof(u2b); |
break; |
case 0x2c: |
table = u2c; |
size = sizeof(u2c); |
break; |
case 0x2d: |
table = u2d; |
size = sizeof(u2d); |
break; |
case 0x2e: |
table = u2e; |
size = sizeof(u2e); |
break; |
case 0x2f: |
table = u2f; |
size = sizeof(u2f); |
break; |
case 0x30: |
table = u30; |
size = sizeof(u30); |
break; |
case 0x31: |
table = u31; |
size = sizeof(u31); |
break; |
case 0x32: |
table = u32; |
size = sizeof(u32); |
break; |
case 0x4d: |
table = u4d; |
size = sizeof(u4d); |
break; |
case 0x9f: |
table = u9f; |
size = sizeof(u9f); |
break; |
case 0xa4: |
table = ua4; |
size = sizeof(ua4); |
break; |
case 0xa6: |
table = ua6; |
size = sizeof(ua6); |
break; |
case 0xa7: |
table = ua7; |
size = sizeof(ua7); |
break; |
case 0xa8: |
table = ua8; |
size = sizeof(ua8); |
break; |
case 0xa9: |
table = ua9; |
size = sizeof(ua9); |
break; |
case 0xaa: |
table = uaa; |
size = sizeof(uaa); |
break; |
case 0xab: |
table = uab; |
size = sizeof(uab); |
break; |
case 0xd7: |
table = ud7; |
size = sizeof(ud7); |
break; |
case 0xfa: |
table = ufa; |
size = sizeof(ufa); |
break; |
case 0xfb: |
table = ufb; |
size = sizeof(ufb); |
break; |
case 0xfd: |
table = ufd; |
size = sizeof(ufd); |
break; |
case 0xfe: |
table = ufe; |
size = sizeof(ufe); |
break; |
case 0xff: |
table = uff; |
size = sizeof(uff); |
break; |
case 0x100: |
table = u100; |
size = sizeof(u100); |
break; |
case 0x101: |
table = u101; |
size = sizeof(u101); |
break; |
case 0x102: |
table = u102; |
size = sizeof(u102); |
break; |
case 0x103: |
table = u103; |
size = sizeof(u103); |
break; |
case 0x104: |
table = u104; |
size = sizeof(u104); |
break; |
case 0x108: |
table = u108; |
size = sizeof(u108); |
break; |
case 0x109: |
table = u109; |
size = sizeof(u109); |
break; |
case 0x10a: |
table = u10a; |
size = sizeof(u10a); |
break; |
case 0x10b: |
table = u10b; |
size = sizeof(u10b); |
break; |
case 0x10c: |
table = u10c; |
size = sizeof(u10c); |
break; |
case 0x10e: |
table = u10e; |
size = sizeof(u10e); |
break; |
case 0x110: |
table = u110; |
size = sizeof(u110); |
break; |
case 0x123: |
table = u123; |
size = sizeof(u123); |
break; |
case 0x124: |
table = u124; |
size = sizeof(u124); |
break; |
case 0x134: |
table = u134; |
size = sizeof(u134); |
break; |
case 0x1d0: |
table = u1d0; |
size = sizeof(u1d0); |
break; |
case 0x1d1: |
table = u1d1; |
size = sizeof(u1d1); |
break; |
case 0x1d2: |
table = u1d2; |
size = sizeof(u1d2); |
break; |
case 0x1d3: |
table = u1d3; |
size = sizeof(u1d3); |
break; |
case 0x1d4: |
table = u1d4; |
size = sizeof(u1d4); |
break; |
case 0x1d5: |
table = u1d5; |
size = sizeof(u1d5); |
break; |
case 0x1d6: |
table = u1d6; |
size = sizeof(u1d6); |
break; |
case 0x1d7: |
table = u1d7; |
size = sizeof(u1d7); |
break; |
case 0x1f0: |
table = u1f0; |
size = sizeof(u1f0); |
break; |
case 0x1f1: |
table = u1f1; |
size = sizeof(u1f1); |
break; |
case 0x1f2: |
table = u1f2; |
size = sizeof(u1f2); |
break; |
case 0x2a6: |
table = u2a6; |
size = sizeof(u2a6); |
break; |
case 0x2b7: |
table = u2b7; |
size = sizeof(u2b7); |
break; |
case 0x2fa: |
table = u2fa; |
size = sizeof(u2fa); |
break; |
case 0xe00: |
table = ue00; |
size = sizeof(ue00); |
break; |
case 0xe01: |
table = ue01; |
size = sizeof(ue01); |
break; |
case 0xfff: |
table = ufff; |
size = sizeof(ufff); |
break; |
case 0x10ff: |
table = u10ff; |
size = sizeof(u10ff); |
break; |
default: |
return 0; |
} |
/* we have narrowed down to a section of 256 characters to check */ |
/* now check if c matches the printuation wide-chars within that section */ |
ptr = (unsigned char *)table; |
ctmp = (unsigned char)c; |
while (ptr < table + size) |
{ |
if (ctmp == *ptr) |
return 1; |
if (ctmp < *ptr) |
return 0; |
/* otherwise c > *ptr */ |
/* look for 0x0 as next element which indicates a range */ |
++ptr; |
if (*ptr == 0x0) |
{ |
/* we have a range..see if c falls within range */ |
++ptr; |
if (ctmp <= *ptr) |
return 1; |
++ptr; |
} |
} |
/* not in table */ |
return 0; |
#else |
return (c < (wint_t)0x100 ? isprint (c) : 0); |
#endif /* _MB_CAPABLE */ |
} |
/contrib/sdk/sources/libc/ctype/iswpunct.c |
---|
0,0 → 1,70 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswpunct>>---punctuation wide character test |
INDEX |
iswpunct |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswpunct(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswpunct(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswpunct>> is a function which classifies wide-character values that |
are punctuation. |
RETURNS |
<<iswpunct>> returns non-zero if <[c]> is a punctuation wide character. |
PORTABILITY |
<<iswpunct>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <string.h> |
#include <ctype.h> |
#include "local.h" |
int |
_DEFUN(iswpunct,(c), wint_t c) |
{ |
return (!iswalnum (c) && iswgraph (c)); |
} |
/contrib/sdk/sources/libc/ctype/iswspace.c |
---|
0,0 → 1,83 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<iswspace>>---whitespace wide character test |
INDEX |
iswspace |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswspace(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswspace(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswspace>> is a function which classifies wide-character values that |
are categorized as whitespace. |
RETURNS |
<<iswspace>> returns non-zero if <[c]> is a whitespace wide character. |
PORTABILITY |
<<iswspace>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <wctype.h> |
#include <ctype.h> |
#include <string.h> |
#include "local.h" |
int |
_DEFUN(iswspace,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
c = _jp2uc (c); |
/* Based on Unicode 5.2. Control chars 09-0D, plus all characters |
from general category "Zs", which are not marked as decomposition |
type "noBreak". */ |
return ((c >= 0x0009 && c <= 0x000d) || c == 0x0020 || |
c == 0x1680 || c == 0x180e || |
(c >= 0x2000 && c <= 0x2006) || |
(c >= 0x2008 && c <= 0x200a) || |
c == 0x2028 || c == 0x2029 || |
c == 0x205f || c == 0x3000); |
#else |
return (c < 0x100 ? isspace (c) : 0); |
#endif /* _MB_CAPABLE */ |
} |
/contrib/sdk/sources/libc/ctype/iswupper.c |
---|
0,0 → 1,38 |
/* |
FUNCTION |
<<iswupper>>---uppercase wide character test |
INDEX |
iswupper |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswupper(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswupper(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswupper>> is a function which classifies wide-character values that |
have uppercase translations. |
RETURNS |
<<iswupper>> returns non-zero if <[c]> is a uppercase wide character. |
PORTABILITY |
<<iswupper>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswupper,(c),wint_t c) |
{ |
return (towlower (c) != c); |
} |
/contrib/sdk/sources/libc/ctype/iswxdigit.c |
---|
0,0 → 1,39 |
/* |
FUNCTION |
<<iswxdigit>>---hexadecimal digit wide character test |
INDEX |
iswxdigit |
ANSI_SYNOPSIS |
#include <wctype.h> |
int iswxdigit(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
int iswxdigit(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<iswxdigit>> is a function which classifies wide character values that |
are hexadecimal digits. |
RETURNS |
<<iswxdigit>> returns non-zero if <[c]> is a hexadecimal digit wide character. |
PORTABILITY |
<<iswxdigit>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <wctype.h> |
int |
_DEFUN(iswxdigit,(c), wint_t c) |
{ |
return ((c >= (wint_t)'0' && c <= (wint_t)'9') || |
(c >= (wint_t)'a' && c <= (wint_t)'f') || |
(c >= (wint_t)'A' && c <= (wint_t)'F')); |
} |
/contrib/sdk/sources/libc/ctype/isxdigit.c |
---|
0,0 → 1,45 |
/* |
FUNCTION |
<<isxdigit>>---hexadecimal digit predicate |
INDEX |
isxdigit |
ANSI_SYNOPSIS |
#include <ctype.h> |
int isxdigit(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int isxdigit(int <[c]>); |
DESCRIPTION |
<<isxdigit>> is a macro which classifies ASCII integer values by table |
lookup. It is a predicate returning non-zero for hexadecimal digits, |
and <<0>> for other characters. It is defined only when |
<<isascii>>(<[c]>) is true or <[c]> is EOF. |
You can use a compiled subroutine instead of the macro definition by |
undefining the macro using `<<#undef isxdigit>>'. |
RETURNS |
<<isxdigit>> returns non-zero if <[c]> is a hexadecimal digit |
(<<0>>--<<9>>, <<a>>--<<f>>, or <<A>>--<<F>>). |
PORTABILITY |
<<isxdigit>> is ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef isxdigit |
int |
_DEFUN(isxdigit,(c),int c) |
{ |
return(__ctype_ptr__[c+1] & ((_X)|(_N))); |
} |
/contrib/sdk/sources/libc/ctype/jp2uc.h |
---|
0,0 → 1,6849 |
/* based on eucjp-208A.txt */ |
/* a1 is contiguous from a1a1 to a1fe */ |
static unsigned short a1[] = { |
0x3000, |
0x3001, |
0x3002, |
0xFF0C, |
0xFF0E, |
0x30FB, |
0xFF1A, |
0xFF1B, |
0xFF1F, |
0xFF01, |
0x309B, |
0x309C, |
0x00B4, |
0xFF40, |
0x00A8, |
0xFF3E, |
0x203E, |
0xFF3F, |
0x30FD, |
0x30FE, |
0x309D, |
0x309E, |
0x3003, |
0x4EDD, |
0x3005, |
0x3006, |
0x3007, |
0x30FC, |
0x2014, |
0x2010, |
0xFF0F, |
0xFF3C, |
0x301C, |
0x2016, |
0xFF5C, |
0x2026, |
0x2025, |
0x2018, |
0x2019, |
0x201C, |
0x201D, |
0xFF08, |
0xFF09, |
0x3014, |
0x3015, |
0xFF3B, |
0xFF3D, |
0xFF5B, |
0xFF5D, |
0x3008, |
0x3009, |
0x300A, |
0x300B, |
0x300C, |
0x300D, |
0x300E, |
0x300F, |
0x3010, |
0x3011, |
0xFF0B, |
0x2212, |
0x00B1, |
0x00D7, |
0x00F7, |
0xFF1D, |
0x2260, |
0xFF1C, |
0xFF1E, |
0x2266, |
0x2267, |
0x221E, |
0x2234, |
0x2642, |
0x2640, |
0x00B0, |
0x2032, |
0x2033, |
0x2103, |
0x00A5, |
0xFF04, |
0x00A2, |
0x00A3, |
0xFF05, |
0xFF03, |
0xFF06, |
0xFF0A, |
0xFF20, |
0x00A7, |
0x2606, |
0x2605, |
0x25CB, |
0x25CF, |
0x25CE, |
0x25C7 |
}; |
/* a2 has a number of holes between a2a1 and a2fe which we fill with 0x0000 */ |
static unsigned short a2[] = { |
0x25C6, |
0x25A1, |
0x25A0, |
0x25B3, |
0x25B2, |
0x25BD, |
0x25BC, |
0x203B, |
0x3012, |
0x2192, |
0x2190, |
0x2191, |
0x2193, |
0x3013, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x2208, |
0x220B, |
0x2286, |
0x2287, |
0x2282, |
0x2283, |
0x222A, |
0x2229, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x2227, |
0x2228, |
0x00AC, |
0x21D2, |
0x21D4, |
0x2200, |
0x2203, |
0x2229, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x2220, |
0x22A5, |
0x2312, |
0x2202, |
0x2207, |
0x2261, |
0x2252, |
0x226A, |
0x226B, |
0x221A, |
0x223D, |
0x221D, |
0x2235, |
0x222B, |
0x222C, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x212B, |
0x2030, |
0x266F, |
0x266D, |
0x266A, |
0x2020, |
0x2021, |
0x00B6, |
0x222C, |
0x0000, |
0x0000, |
0x0000, |
0x25EF |
}; |
/* a3a1 to a3fe is mostly contiguous. Conversion output values are |
of the form 0xFFxx where xx is (yy - 0xA0) where the input is 0xA3yy */ |
static unsigned char a3[] = { |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
0, |
0, |
0, |
0, |
0, |
0, |
0, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1, |
1 |
}; |
/* a4 is contiguous from a4a1 to a4f3 */ |
/* transform = 0x30xx where xx = last byte - 0x60 */ |
/* a5 is contiguous from a5a1 to a5f6 */ |
/* transform = 0x30xx where xx = last byte */ |
/* a6 is mostly contiguous from a6a1 to a6d8 */ |
static unsigned short a6[] = { |
0x0391, |
0x0392, |
0x0393, |
0x0394, |
0x0395, |
0x0396, |
0x0397, |
0x0398, |
0x0399, |
0x039A, |
0x039B, |
0x039C, |
0x039D, |
0x039E, |
0x039F, |
0x03A0, |
0x03A1, |
0x03A3, |
0x03A4, |
0x03A5, |
0x03A6, |
0x03A7, |
0x03A8, |
0x03A9, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x03B1, |
0x03B2, |
0x03B3, |
0x03B4, |
0x03B5, |
0x03B6, |
0x03B7, |
0x03B8, |
0x03B9, |
0x03BA, |
0x03BB, |
0x03BC, |
0x03BD, |
0x03BE, |
0x03BF, |
0x03C0, |
0x03C1, |
0x03C3, |
0x03C4, |
0x03C5, |
0x03C6, |
0x03C7, |
0x03C8, |
0x03C9 |
}; |
/* a7 is mostly contiguous from a7a1 to a7f1 */ |
static unsigned short a7[] = { |
0x0410, |
0x0411, |
0x0412, |
0x0413, |
0x0414, |
0x0415, |
0x0401, |
0x0416, |
0x0417, |
0x0418, |
0x0419, |
0x041A, |
0x041B, |
0x041C, |
0x041D, |
0x041E, |
0x041F, |
0x0420, |
0x0421, |
0x0422, |
0x0423, |
0x0424, |
0x0425, |
0x0426, |
0x0427, |
0x0428, |
0x0429, |
0x042A, |
0x042B, |
0x042C, |
0x042D, |
0x042E, |
0x042F, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0000, |
0x0430, |
0x0431, |
0x0432, |
0x0433, |
0x0434, |
0x0435, |
0x0451, |
0x0436, |
0x0437, |
0x0438, |
0x0439, |
0x043A, |
0x043B, |
0x043C, |
0x043D, |
0x043E, |
0x043F, |
0x0440, |
0x0441, |
0x0442, |
0x0443, |
0x0444, |
0x0445, |
0x0446, |
0x0447, |
0x0448, |
0x0449, |
0x044A, |
0x044B, |
0x044C, |
0x044D, |
0x044E, |
0x044F |
}; |
/* a8 is contiguous from a8a1 to a8c0 */ |
static unsigned short a8[] = { |
0x2500, |
0x2502, |
0x250C, |
0x2510, |
0x2518, |
0x2514, |
0x251C, |
0x252C, |
0x2524, |
0x2534, |
0x253C, |
0x2501, |
0x2503, |
0x250F, |
0x2513, |
0x251B, |
0x2517, |
0x2523, |
0x2533, |
0x252B, |
0x253B, |
0x254B, |
0x2520, |
0x252F, |
0x2528, |
0x2537, |
0x253F, |
0x251D, |
0x2530, |
0x2525, |
0x2538, |
0x2542 |
}; |
/* no conversion a9 to af */ |
/* b0a1 to cfd3 is contiguous except for illegal sequences with 0xfe */ |
static unsigned short b02cf[] = { |
0x4E9C, |
0x5516, |
0x5A03, |
0x963F, |
0x54C0, |
0x611B, |
0x6328, |
0x59F6, |
0x9022, |
0x8475, |
0x831C, |
0x7A50, |
0x60AA, |
0x63E1, |
0x6E25, |
0x65ED, |
0x8466, |
0x82A6, |
0x9BF5, |
0x6893, |
0x5727, |
0x65A1, |
0x6271, |
0x5B9B, |
0x59D0, |
0x867B, |
0x98F4, |
0x7D62, |
0x7DBE, |
0x9B8E, |
0x6216, |
0x7C9F, |
0x88B7, |
0x5B89, |
0x5EB5, |
0x6309, |
0x6697, |
0x6848, |
0x95C7, |
0x978D, |
0x674F, |
0x4EE5, |
0x4F0A, |
0x4F4D, |
0x4F9D, |
0x5049, |
0x56F2, |
0x5937, |
0x59D4, |
0x5A01, |
0x5C09, |
0x60DF, |
0x610F, |
0x6170, |
0x6613, |
0x6905, |
0x70BA, |
0x754F, |
0x7570, |
0x79FB, |
0x7DAD, |
0x7DEF, |
0x80C3, |
0x840E, |
0x8863, |
0x8B02, |
0x9055, |
0x907A, |
0x533B, |
0x4E95, |
0x4EA5, |
0x57DF, |
0x80B2, |
0x90C1, |
0x78EF, |
0x4E00, |
0x58F1, |
0x6EA2, |
0x9038, |
0x7A32, |
0x8328, |
0x828B, |
0x9C2F, |
0x5141, |
0x5370, |
0x54BD, |
0x54E1, |
0x56E0, |
0x59FB, |
0x5F15, |
0x98F2, |
0x6DEB, |
0x80E4, |
0x852D, |
0x9662, |
0x9670, |
0x96A0, |
0x97FB, |
0x540B, |
0x53F3, |
0x5B87, |
0x70CF, |
0x7FBD, |
0x8FC2, |
0x96E8, |
0x536F, |
0x9D5C, |
0x7ABA, |
0x4E11, |
0x7893, |
0x81FC, |
0x6E26, |
0x5618, |
0x5504, |
0x6B1D, |
0x851A, |
0x9C3B, |
0x59E5, |
0x53A9, |
0x6D66, |
0x74DC, |
0x958F, |
0x5642, |
0x4E91, |
0x904B, |
0x96F2, |
0x834F, |
0x990C, |
0x53E1, |
0x55B6, |
0x5B30, |
0x5F71, |
0x6620, |
0x66F3, |
0x6804, |
0x6C38, |
0x6CF3, |
0x6D29, |
0x745B, |
0x76C8, |
0x7A4E, |
0x9834, |
0x82F1, |
0x885B, |
0x8A60, |
0x92ED, |
0x6DB2, |
0x75AB, |
0x76CA, |
0x99C5, |
0x60A6, |
0x8B01, |
0x8D8A, |
0x95B2, |
0x698E, |
0x53AD, |
0x5186, |
0x5712, |
0x5830, |
0x5944, |
0x5BB4, |
0x5EF6, |
0x6028, |
0x63A9, |
0x63F4, |
0x6CBF, |
0x6F14, |
0x708E, |
0x7114, |
0x7159, |
0x71D5, |
0x733F, |
0x7E01, |
0x8276, |
0x82D1, |
0x8597, |
0x9060, |
0x925B, |
0x9D1B, |
0x5869, |
0x65BC, |
0x6C5A, |
0x7525, |
0x51F9, |
0x592E, |
0x5965, |
0x5F80, |
0x5FDC, |
0x62BC, |
0x65FA, |
0x6A2A, |
0x6B27, |
0x6BB4, |
0x738B, |
0x7FC1, |
0x8956, |
0x9D2C, |
0x9D0E, |
0x9EC4, |
0x5CA1, |
0x6C96, |
0x837B, |
0x5104, |
0x5C4B, |
0x61B6, |
0x81C6, |
0x6876, |
0x7261, |
0x4E59, |
0x4FFA, |
0x5378, |
0x6069, |
0x6E29, |
0x7A4F, |
0x97F3, |
0x4E0B, |
0x5316, |
0x4EEE, |
0x4F55, |
0x4F3D, |
0x4FA1, |
0x4F73, |
0x52A0, |
0x53EF, |
0x5609, |
0x590F, |
0x5AC1, |
0x5BB6, |
0x5BE1, |
0x79D1, |
0x6687, |
0x679C, |
0x67B6, |
0x6B4C, |
0x6CB3, |
0x706B, |
0x73C2, |
0x798D, |
0x79BE, |
0x7A3C, |
0x7B87, |
0x82B1, |
0x82DB, |
0x8304, |
0x8377, |
0x83EF, |
0x83D3, |
0x8766, |
0x8AB2, |
0x5629, |
0x8CA8, |
0x8FE6, |
0x904E, |
0x971E, |
0x868A, |
0x4FC4, |
0x5CE8, |
0x6211, |
0x7259, |
0x753B, |
0x81E5, |
0x82BD, |
0x86FE, |
0x8CC0, |
0x96C5, |
0x9913, |
0x99D5, |
0x4ECB, |
0x4F1A, |
0x89E3, |
0x56DE, |
0x584A, |
0x58CA, |
0x5EFB, |
0x5FEB, |
0x602A, |
0x6094, |
0x6062, |
0x61D0, |
0x6212, |
0x62D0, |
0x6539, |
0x9B41, |
0x6666, |
0x68B0, |
0x6D77, |
0x7070, |
0x754C, |
0x7686, |
0x7D75, |
0x82A5, |
0x87F9, |
0x958B, |
0x968E, |
0x8C9D, |
0x51F1, |
0x52BE, |
0x5916, |
0x54B3, |
0x5BB3, |
0x5D16, |
0x6168, |
0x6982, |
0x6DAF, |
0x788D, |
0x84CB, |
0x8857, |
0x8A72, |
0x93A7, |
0x9AB8, |
0x6D6C, |
0x99A8, |
0x86D9, |
0x57A3, |
0x67FF, |
0x86CE, |
0x920E, |
0x5283, |
0x5687, |
0x5404, |
0x5ED3, |
0x62E1, |
0x64B9, |
0x683C, |
0x6838, |
0x6BBB, |
0x7372, |
0x78BA, |
0x7A6B, |
0x899A, |
0x89D2, |
0x8D6B, |
0x8F03, |
0x90ED, |
0x95A3, |
0x9694, |
0x9769, |
0x5B66, |
0x5CB3, |
0x697D, |
0x984D, |
0x984E, |
0x639B, |
0x7B20, |
0x6A2B, |
0x6A7F, |
0x68B6, |
0x9C0D, |
0x6F5F, |
0x5272, |
0x559D, |
0x6070, |
0x62EC, |
0x6D3B, |
0x6E07, |
0x6ED1, |
0x845B, |
0x8910, |
0x8F44, |
0x4E14, |
0x9C39, |
0x53F6, |
0x691B, |
0x6A3A, |
0x9784, |
0x682A, |
0x515C, |
0x7AC3, |
0x84B2, |
0x91DC, |
0x938C, |
0x565B, |
0x9D28, |
0x6822, |
0x8305, |
0x8431, |
0x7CA5, |
0x5208, |
0x82C5, |
0x74E6, |
0x4E7E, |
0x4F83, |
0x51A0, |
0x5BD2, |
0x520A, |
0x52D8, |
0x52E7, |
0x5DFB, |
0x559A, |
0x582A, |
0x59E6, |
0x5B8C, |
0x5B98, |
0x5BDB, |
0x5E72, |
0x5E79, |
0x60A3, |
0x611F, |
0x6163, |
0x61BE, |
0x63DB, |
0x6562, |
0x67D1, |
0x6853, |
0x68FA, |
0x6B3E, |
0x6B53, |
0x6C57, |
0x6F22, |
0x6F97, |
0x6F45, |
0x74B0, |
0x7518, |
0x76E3, |
0x770B, |
0x7AFF, |
0x7BA1, |
0x7C21, |
0x7DE9, |
0x7F36, |
0x7FF0, |
0x809D, |
0x8266, |
0x839E, |
0x89B3, |
0x8ACC, |
0x8CAB, |
0x9084, |
0x9451, |
0x9593, |
0x9591, |
0x95A2, |
0x9665, |
0x97D3, |
0x9928, |
0x8218, |
0x4E38, |
0x542B, |
0x5CB8, |
0x5DCC, |
0x73A9, |
0x764C, |
0x773C, |
0x5CA9, |
0x7FEB, |
0x8D0B, |
0x96C1, |
0x9811, |
0x9854, |
0x9858, |
0x4F01, |
0x4F0E, |
0x5371, |
0x559C, |
0x5668, |
0x57FA, |
0x5947, |
0x5B09, |
0x5BC4, |
0x5C90, |
0x5E0C, |
0x5E7E, |
0x5FCC, |
0x63EE, |
0x673A, |
0x65D7, |
0x65E2, |
0x671F, |
0x68CB, |
0x68C4, |
0x6A5F, |
0x5E30, |
0x6BC5, |
0x6C17, |
0x6C7D, |
0x757F, |
0x7948, |
0x5B63, |
0x7A00, |
0x7D00, |
0x5FBD, |
0x898F, |
0x8A18, |
0x8CB4, |
0x8D77, |
0x8ECC, |
0x8F1D, |
0x98E2, |
0x9A0E, |
0x9B3C, |
0x4E80, |
0x507D, |
0x5100, |
0x5993, |
0x5B9C, |
0x622F, |
0x6280, |
0x64EC, |
0x6B3A, |
0x72A0, |
0x7591, |
0x7947, |
0x7FA9, |
0x87FB, |
0x8ABC, |
0x8B70, |
0x63AC, |
0x83CA, |
0x97A0, |
0x5409, |
0x5403, |
0x55AB, |
0x6854, |
0x6A58, |
0x8A70, |
0x7827, |
0x6775, |
0x9ECD, |
0x5374, |
0x5BA2, |
0x811A, |
0x8650, |
0x9006, |
0x4E18, |
0x4E45, |
0x4EC7, |
0x4F11, |
0x53CA, |
0x5438, |
0x5BAE, |
0x5F13, |
0x6025, |
0x6551, |
0x673D, |
0x6C42, |
0x6C72, |
0x6CE3, |
0x7078, |
0x7403, |
0x7A76, |
0x7AAE, |
0x7B08, |
0x7D1A, |
0x7CFE, |
0x7D66, |
0x65E7, |
0x725B, |
0x53BB, |
0x5C45, |
0x5DE8, |
0x62D2, |
0x62E0, |
0x6319, |
0x6E20, |
0x865A, |
0x8A31, |
0x8DDD, |
0x92F8, |
0x6F01, |
0x79A6, |
0x9B5A, |
0x4EA8, |
0x4EAB, |
0x4EAC, |
0x4F9B, |
0x4FA0, |
0x50D1, |
0x5147, |
0x7AF6, |
0x5171, |
0x51F6, |
0x5354, |
0x5321, |
0x537F, |
0x53EB, |
0x55AC, |
0x5883, |
0x5CE1, |
0x5F37, |
0x5F4A, |
0x602F, |
0x6050, |
0x606D, |
0x631F, |
0x6559, |
0x6A4B, |
0x6CC1, |
0x72C2, |
0x72ED, |
0x77EF, |
0x80F8, |
0x8105, |
0x8208, |
0x854E, |
0x90F7, |
0x93E1, |
0x97FF, |
0x9957, |
0x9A5A, |
0x4EF0, |
0x51DD, |
0x5C2D, |
0x6681, |
0x696D, |
0x5C40, |
0x66F2, |
0x6975, |
0x7389, |
0x6850, |
0x7C81, |
0x50C5, |
0x52E4, |
0x5747, |
0x5DFE, |
0x9326, |
0x65A4, |
0x6B23, |
0x6B3D, |
0x7434, |
0x7981, |
0x79BD, |
0x7B4B, |
0x7DCA, |
0x82B9, |
0x83CC, |
0x887F, |
0x895F, |
0x8B39, |
0x8FD1, |
0x91D1, |
0x541F, |
0x9280, |
0x4E5D, |
0x5036, |
0x53E5, |
0x533A, |
0x72D7, |
0x7396, |
0x77E9, |
0x82E6, |
0x8EAF, |
0x99C6, |
0x99C8, |
0x99D2, |
0x5177, |
0x611A, |
0x865E, |
0x55B0, |
0x7A7A, |
0x5076, |
0x5BD3, |
0x9047, |
0x9685, |
0x4E32, |
0x6ADB, |
0x91E7, |
0x5C51, |
0x5C48, |
0x6398, |
0x7A9F, |
0x6C93, |
0x9774, |
0x8F61, |
0x7AAA, |
0x718A, |
0x9688, |
0x7C82, |
0x6817, |
0x7E70, |
0x6851, |
0x936C, |
0x52F2, |
0x541B, |
0x85AB, |
0x8A13, |
0x7FA4, |
0x8ECD, |
0x90E1, |
0x5366, |
0x8888, |
0x7941, |
0x4FC2, |
0x50BE, |
0x5211, |
0x5144, |
0x5553, |
0x572D, |
0x73EA, |
0x578B, |
0x5951, |
0x5F62, |
0x5F84, |
0x6075, |
0x6176, |
0x6167, |
0x61A9, |
0x63B2, |
0x643A, |
0x656C, |
0x666F, |
0x6842, |
0x6E13, |
0x7566, |
0x7A3D, |
0x7CFB, |
0x7D4C, |
0x7D99, |
0x7E4B, |
0x7F6B, |
0x830E, |
0x834A, |
0x86CD, |
0x8A08, |
0x8A63, |
0x8B66, |
0x8EFD, |
0x981A, |
0x9D8F, |
0x82B8, |
0x8FCE, |
0x9BE8, |
0x5287, |
0x621F, |
0x6483, |
0x6FC0, |
0x9699, |
0x6841, |
0x5091, |
0x6B20, |
0x6C7A, |
0x6F54, |
0x7A74, |
0x7D50, |
0x8840, |
0x8A23, |
0x6708, |
0x4EF6, |
0x5039, |
0x5026, |
0x5065, |
0x517C, |
0x5238, |
0x5263, |
0x55A7, |
0x570F, |
0x5805, |
0x5ACC, |
0x5EFA, |
0x61B2, |
0x61F8, |
0x62F3, |
0x6372, |
0x691C, |
0x6A29, |
0x727D, |
0x72AC, |
0x732E, |
0x7814, |
0x786F, |
0x7D79, |
0x770C, |
0x80A9, |
0x898B, |
0x8B19, |
0x8CE2, |
0x8ED2, |
0x9063, |
0x9375, |
0x967A, |
0x9855, |
0x9A13, |
0x9E78, |
0x5143, |
0x539F, |
0x53B3, |
0x5E7B, |
0x5F26, |
0x6E1B, |
0x6E90, |
0x7384, |
0x73FE, |
0x7D43, |
0x8237, |
0x8A00, |
0x8AFA, |
0x9650, |
0x4E4E, |
0x500B, |
0x53E4, |
0x547C, |
0x56FA, |
0x59D1, |
0x5B64, |
0x5DF1, |
0x5EAB, |
0x5F27, |
0x6238, |
0x6545, |
0x67AF, |
0x6E56, |
0x72D0, |
0x7CCA, |
0x88B4, |
0x80A1, |
0x80E1, |
0x83F0, |
0x864E, |
0x8A87, |
0x8DE8, |
0x9237, |
0x96C7, |
0x9867, |
0x9F13, |
0x4E94, |
0x4E92, |
0x4F0D, |
0x5348, |
0x5449, |
0x543E, |
0x5A2F, |
0x5F8C, |
0x5FA1, |
0x609F, |
0x68A7, |
0x6A8E, |
0x745A, |
0x7881, |
0x8A9E, |
0x8AA4, |
0x8B77, |
0x9190, |
0x4E5E, |
0x9BC9, |
0x4EA4, |
0x4F7C, |
0x4FAF, |
0x5019, |
0x5016, |
0x5149, |
0x516C, |
0x529F, |
0x52B9, |
0x52FE, |
0x539A, |
0x53E3, |
0x5411, |
0x540E, |
0x5589, |
0x5751, |
0x57A2, |
0x597D, |
0x5B54, |
0x5B5D, |
0x5B8F, |
0x5DE5, |
0x5DE7, |
0x5DF7, |
0x5E78, |
0x5E83, |
0x5E9A, |
0x5EB7, |
0x5F18, |
0x6052, |
0x614C, |
0x6297, |
0x62D8, |
0x63A7, |
0x653B, |
0x6602, |
0x6643, |
0x66F4, |
0x676D, |
0x6821, |
0x6897, |
0x69CB, |
0x6C5F, |
0x6D2A, |
0x6D69, |
0x6E2F, |
0x6E9D, |
0x7532, |
0x7687, |
0x786C, |
0x7A3F, |
0x7CE0, |
0x7D05, |
0x7D18, |
0x7D5E, |
0x7DB1, |
0x8015, |
0x8003, |
0x80AF, |
0x80B1, |
0x8154, |
0x818F, |
0x822A, |
0x8352, |
0x884C, |
0x8861, |
0x8B1B, |
0x8CA2, |
0x8CFC, |
0x90CA, |
0x9175, |
0x9271, |
0x783F, |
0x92FC, |
0x95A4, |
0x964D, |
0x9805, |
0x9999, |
0x9AD8, |
0x9D3B, |
0x525B, |
0x52AB, |
0x53F7, |
0x5408, |
0x58D5, |
0x62F7, |
0x6FE0, |
0x8C6A, |
0x8F5F, |
0x9EB9, |
0x514B, |
0x523B, |
0x544A, |
0x56FD, |
0x7A40, |
0x9177, |
0x9D60, |
0x9ED2, |
0x7344, |
0x6F09, |
0x8170, |
0x7511, |
0x5FFD, |
0x60DA, |
0x9AA8, |
0x72DB, |
0x8FBC, |
0x6B64, |
0x9803, |
0x4ECA, |
0x56F0, |
0x5764, |
0x58BE, |
0x5A5A, |
0x6068, |
0x61C7, |
0x660F, |
0x6606, |
0x6839, |
0x68B1, |
0x6DF7, |
0x75D5, |
0x7D3A, |
0x826E, |
0x9B42, |
0x4E9B, |
0x4F50, |
0x53C9, |
0x5506, |
0x5D6F, |
0x5DE6, |
0x5DEE, |
0x67FB, |
0x6C99, |
0x7473, |
0x7802, |
0x8A50, |
0x9396, |
0x88DF, |
0x5750, |
0x5EA7, |
0x632B, |
0x50B5, |
0x50AC, |
0x518D, |
0x6700, |
0x54C9, |
0x585E, |
0x59BB, |
0x5BB0, |
0x5F69, |
0x624D, |
0x63A1, |
0x683D, |
0x6B73, |
0x6E08, |
0x707D, |
0x91C7, |
0x7280, |
0x7815, |
0x7826, |
0x796D, |
0x658E, |
0x7D30, |
0x83DC, |
0x88C1, |
0x8F09, |
0x969B, |
0x5264, |
0x5728, |
0x6750, |
0x7F6A, |
0x8CA1, |
0x51B4, |
0x5742, |
0x962A, |
0x583A, |
0x698A, |
0x80B4, |
0x54B2, |
0x5D0E, |
0x57FC, |
0x7895, |
0x9DFA, |
0x4F5C, |
0x524A, |
0x548B, |
0x643E, |
0x6628, |
0x6714, |
0x67F5, |
0x7A84, |
0x7B56, |
0x7D22, |
0x932F, |
0x685C, |
0x9BAD, |
0x7B39, |
0x5319, |
0x518A, |
0x5237, |
0x5BDF, |
0x62F6, |
0x64AE, |
0x64E6, |
0x672D, |
0x6BBA, |
0x85A9, |
0x96D1, |
0x7690, |
0x9BD6, |
0x634C, |
0x9306, |
0x9BAB, |
0x76BF, |
0x6652, |
0x4E09, |
0x5098, |
0x53C2, |
0x5C71, |
0x60E8, |
0x6492, |
0x6563, |
0x685F, |
0x71E6, |
0x73CA, |
0x7523, |
0x7B97, |
0x7E82, |
0x8695, |
0x8B83, |
0x8CDB, |
0x9178, |
0x9910, |
0x65AC, |
0x66AB, |
0x6B8B, |
0x4ED5, |
0x4ED4, |
0x4F3A, |
0x4F7F, |
0x523A, |
0x53F8, |
0x53F2, |
0x55E3, |
0x56DB, |
0x58EB, |
0x59CB, |
0x59C9, |
0x59FF, |
0x5B50, |
0x5C4D, |
0x5E02, |
0x5E2B, |
0x5FD7, |
0x601D, |
0x6307, |
0x652F, |
0x5B5C, |
0x65AF, |
0x65BD, |
0x65E8, |
0x679D, |
0x6B62, |
0x6B7B, |
0x6C0F, |
0x7345, |
0x7949, |
0x79C1, |
0x7CF8, |
0x7D19, |
0x7D2B, |
0x80A2, |
0x8102, |
0x81F3, |
0x8996, |
0x8A5E, |
0x8A69, |
0x8A66, |
0x8A8C, |
0x8AEE, |
0x8CC7, |
0x8CDC, |
0x96CC, |
0x98FC, |
0x6B6F, |
0x4E8B, |
0x4F3C, |
0x4F8D, |
0x5150, |
0x5B57, |
0x5BFA, |
0x6148, |
0x6301, |
0x6642, |
0x6B21, |
0x6ECB, |
0x6CBB, |
0x723E, |
0x74BD, |
0x75D4, |
0x78C1, |
0x793A, |
0x800C, |
0x8033, |
0x81EA, |
0x8494, |
0x8F9E, |
0x6C50, |
0x9E7F, |
0x5F0F, |
0x8B58, |
0x9D2B, |
0x7AFA, |
0x8EF8, |
0x5B8D, |
0x96EB, |
0x4E03, |
0x53F1, |
0x57F7, |
0x5931, |
0x5AC9, |
0x5BA4, |
0x6089, |
0x6E7F, |
0x6F06, |
0x75BE, |
0x8CEA, |
0x5B9F, |
0x8500, |
0x7BE0, |
0x5072, |
0x67F4, |
0x829D, |
0x5C61, |
0x854A, |
0x7E1E, |
0x820E, |
0x5199, |
0x5C04, |
0x6368, |
0x8D66, |
0x659C, |
0x716E, |
0x793E, |
0x7D17, |
0x8005, |
0x8B1D, |
0x8ECA, |
0x906E, |
0x86C7, |
0x90AA, |
0x501F, |
0x52FA, |
0x5C3A, |
0x6753, |
0x707C, |
0x7235, |
0x914C, |
0x91C8, |
0x932B, |
0x82E5, |
0x5BC2, |
0x5F31, |
0x60F9, |
0x4E3B, |
0x53D6, |
0x5B88, |
0x624B, |
0x6731, |
0x6B8A, |
0x72E9, |
0x73E0, |
0x7A2E, |
0x816B, |
0x8DA3, |
0x9152, |
0x9996, |
0x5112, |
0x53D7, |
0x546A, |
0x5BFF, |
0x6388, |
0x6A39, |
0x7DAC, |
0x9700, |
0x56DA, |
0x53CE, |
0x5468, |
0x5B97, |
0x5C31, |
0x5DDE, |
0x4FEE, |
0x6101, |
0x62FE, |
0x6D32, |
0x79C0, |
0x79CB, |
0x7D42, |
0x7E4D, |
0x7FD2, |
0x81ED, |
0x821F, |
0x8490, |
0x8846, |
0x8972, |
0x8B90, |
0x8E74, |
0x8F2F, |
0x9031, |
0x914B, |
0x916C, |
0x96C6, |
0x919C, |
0x4EC0, |
0x4F4F, |
0x5145, |
0x5341, |
0x5F93, |
0x620E, |
0x67D4, |
0x6C41, |
0x6E0B, |
0x7363, |
0x7E26, |
0x91CD, |
0x9283, |
0x53D4, |
0x5919, |
0x5BBF, |
0x6DD1, |
0x795D, |
0x7E2E, |
0x7C9B, |
0x587E, |
0x719F, |
0x51FA, |
0x8853, |
0x8FF0, |
0x4FCA, |
0x5CFB, |
0x6625, |
0x77AC, |
0x7AE3, |
0x821C, |
0x99FF, |
0x51C6, |
0x5FAA, |
0x65EC, |
0x696F, |
0x6B89, |
0x6DF3, |
0x6E96, |
0x6F64, |
0x76FE, |
0x7D14, |
0x5DE1, |
0x9075, |
0x9187, |
0x9806, |
0x51E6, |
0x521D, |
0x6240, |
0x6691, |
0x66D9, |
0x6E1A, |
0x5EB6, |
0x7DD2, |
0x7F72, |
0x66F8, |
0x85AF, |
0x85F7, |
0x8AF8, |
0x52A9, |
0x53D9, |
0x5973, |
0x5E8F, |
0x5F90, |
0x6055, |
0x92E4, |
0x9664, |
0x50B7, |
0x511F, |
0x52DD, |
0x5320, |
0x5347, |
0x53EC, |
0x54E8, |
0x5546, |
0x5531, |
0x5617, |
0x5968, |
0x59BE, |
0x5A3C, |
0x5BB5, |
0x5C06, |
0x5C0F, |
0x5C11, |
0x5C1A, |
0x5E84, |
0x5E8A, |
0x5EE0, |
0x5F70, |
0x627F, |
0x6284, |
0x62DB, |
0x638C, |
0x6377, |
0x6607, |
0x660C, |
0x662D, |
0x6676, |
0x677E, |
0x68A2, |
0x6A1F, |
0x6A35, |
0x6CBC, |
0x6D88, |
0x6E09, |
0x6E58, |
0x713C, |
0x7126, |
0x7167, |
0x75C7, |
0x7701, |
0x785D, |
0x7901, |
0x7965, |
0x79F0, |
0x7AE0, |
0x7B11, |
0x7CA7, |
0x7D39, |
0x8096, |
0x83D6, |
0x848B, |
0x8549, |
0x885D, |
0x88F3, |
0x8A1F, |
0x8A3C, |
0x8A54, |
0x8A73, |
0x8C61, |
0x8CDE, |
0x91A4, |
0x9266, |
0x937E, |
0x9418, |
0x969C, |
0x9798, |
0x4E0A, |
0x4E08, |
0x4E1E, |
0x4E57, |
0x5197, |
0x5270, |
0x57CE, |
0x5834, |
0x58CC, |
0x5B22, |
0x5E38, |
0x60C5, |
0x64FE, |
0x6761, |
0x6756, |
0x6D44, |
0x72B6, |
0x7573, |
0x7A63, |
0x84B8, |
0x8B72, |
0x91B8, |
0x9320, |
0x5631, |
0x57F4, |
0x98FE, |
0x62ED, |
0x690D, |
0x6B96, |
0x71ED, |
0x7E54, |
0x8077, |
0x8272, |
0x89E6, |
0x98DF, |
0x8755, |
0x8FB1, |
0x5C3B, |
0x4F38, |
0x4FE1, |
0x4FB5, |
0x5507, |
0x5A20, |
0x5BDD, |
0x5BE9, |
0x5FC3, |
0x614E, |
0x632F, |
0x65B0, |
0x664B, |
0x68EE, |
0x699B, |
0x6D78, |
0x6DF1, |
0x7533, |
0x75B9, |
0x771F, |
0x795E, |
0x79E6, |
0x7D33, |
0x81E3, |
0x82AF, |
0x85AA, |
0x89AA, |
0x8A3A, |
0x8EAB, |
0x8F9B, |
0x9032, |
0x91DD, |
0x9707, |
0x4EBA, |
0x4EC1, |
0x5203, |
0x5875, |
0x58EC, |
0x5C0B, |
0x751A, |
0x5C3D, |
0x814E, |
0x8A0A, |
0x8FC5, |
0x9663, |
0x976D, |
0x7B25, |
0x8ACF, |
0x9808, |
0x9162, |
0x56F3, |
0x53A8, |
0x9017, |
0x5439, |
0x5782, |
0x5E25, |
0x63A8, |
0x6C34, |
0x708A, |
0x7761, |
0x7C8B, |
0x7FE0, |
0x8870, |
0x9042, |
0x9154, |
0x9310, |
0x9318, |
0x968F, |
0x745E, |
0x9AC4, |
0x5D07, |
0x5D69, |
0x6570, |
0x67A2, |
0x8DA8, |
0x96DB, |
0x636E, |
0x6749, |
0x6919, |
0x83C5, |
0x9817, |
0x96C0, |
0x88FE, |
0x6F84, |
0x647A, |
0x5BF8, |
0x4E16, |
0x702C, |
0x755D, |
0x662F, |
0x51C4, |
0x5236, |
0x52E2, |
0x59D3, |
0x5F81, |
0x6027, |
0x6210, |
0x653F, |
0x6574, |
0x661F, |
0x6674, |
0x68F2, |
0x6816, |
0x6B63, |
0x6E05, |
0x7272, |
0x751F, |
0x76DB, |
0x7CBE, |
0x8056, |
0x58F0, |
0x88FD, |
0x897F, |
0x8AA0, |
0x8A93, |
0x8ACB, |
0x901D, |
0x9192, |
0x9752, |
0x9759, |
0x6589, |
0x7A0E, |
0x8106, |
0x96BB, |
0x5E2D, |
0x60DC, |
0x621A, |
0x65A5, |
0x6614, |
0x6790, |
0x77F3, |
0x7A4D, |
0x7C4D, |
0x7E3E, |
0x810A, |
0x8CAC, |
0x8D64, |
0x8DE1, |
0x8E5F, |
0x78A9, |
0x5207, |
0x62D9, |
0x63A5, |
0x6442, |
0x6298, |
0x8A2D, |
0x7A83, |
0x7BC0, |
0x8AAC, |
0x96EA, |
0x7D76, |
0x820C, |
0x8749, |
0x4ED9, |
0x5148, |
0x5343, |
0x5360, |
0x5BA3, |
0x5C02, |
0x5C16, |
0x5DDD, |
0x6226, |
0x6247, |
0x64B0, |
0x6813, |
0x6834, |
0x6CC9, |
0x6D45, |
0x6D17, |
0x67D3, |
0x6F5C, |
0x714E, |
0x717D, |
0x65CB, |
0x7A7F, |
0x7BAD, |
0x7DDA, |
0x7E4A, |
0x7FA8, |
0x817A, |
0x821B, |
0x8239, |
0x85A6, |
0x8A6E, |
0x8CCE, |
0x8DF5, |
0x9078, |
0x9077, |
0x92AD, |
0x9291, |
0x9583, |
0x9BAE, |
0x524D, |
0x5584, |
0x6F38, |
0x7136, |
0x5168, |
0x7985, |
0x7E55, |
0x81B3, |
0x7CCE, |
0x564C, |
0x5851, |
0x5CA8, |
0x63AA, |
0x66FE, |
0x66FD, |
0x695A, |
0x72D9, |
0x758F, |
0x758E, |
0x790E, |
0x7956, |
0x79DF, |
0x7C97, |
0x7D20, |
0x7D44, |
0x8607, |
0x8A34, |
0x963B, |
0x9061, |
0x9F20, |
0x50E7, |
0x5275, |
0x53CC, |
0x53E2, |
0x5009, |
0x55AA, |
0x58EE, |
0x594F, |
0x723D, |
0x5B8B, |
0x5C64, |
0x531D, |
0x60E3, |
0x60F3, |
0x635C, |
0x6383, |
0x633F, |
0x63BB, |
0x64CD, |
0x65E9, |
0x66F9, |
0x5DE3, |
0x69CD, |
0x69FD, |
0x6F15, |
0x71E5, |
0x4E89, |
0x75E9, |
0x76F8, |
0x7A93, |
0x7CDF, |
0x7DCF, |
0x7D9C, |
0x8061, |
0x8349, |
0x8358, |
0x846C, |
0x84BC, |
0x85FB, |
0x88C5, |
0x8D70, |
0x9001, |
0x906D, |
0x9397, |
0x971C, |
0x9A12, |
0x50CF, |
0x5897, |
0x618E, |
0x81D3, |
0x8535, |
0x8D08, |
0x9020, |
0x4FC3, |
0x5074, |
0x5247, |
0x5373, |
0x606F, |
0x6349, |
0x675F, |
0x6E2C, |
0x8DB3, |
0x901F, |
0x4FD7, |
0x5C5E, |
0x8CCA, |
0x65CF, |
0x7D9A, |
0x5352, |
0x8896, |
0x5176, |
0x63C3, |
0x5B58, |
0x5B6B, |
0x5C0A, |
0x640D, |
0x6751, |
0x905C, |
0x4ED6, |
0x591A, |
0x592A, |
0x6C70, |
0x8A51, |
0x553E, |
0x5815, |
0x59A5, |
0x60F0, |
0x6253, |
0x67C1, |
0x8235, |
0x6955, |
0x9640, |
0x99C4, |
0x9A28, |
0x4F53, |
0x5806, |
0x5BFE, |
0x8010, |
0x5CB1, |
0x5E2F, |
0x5F85, |
0x6020, |
0x614B, |
0x6234, |
0x66FF, |
0x6CF0, |
0x6EDE, |
0x80CE, |
0x817F, |
0x82D4, |
0x888B, |
0x8CB8, |
0x9000, |
0x902E, |
0x968A, |
0x9EDB, |
0x9BDB, |
0x4EE3, |
0x53F0, |
0x5927, |
0x7B2C, |
0x918D, |
0x984C, |
0x9DF9, |
0x6EDD, |
0x7027, |
0x5353, |
0x5544, |
0x5B85, |
0x6258, |
0x629E, |
0x62D3, |
0x6CA2, |
0x6FEF, |
0x7422, |
0x8A17, |
0x9438, |
0x6FC1, |
0x8AFE, |
0x8338, |
0x51E7, |
0x86F8, |
0x53EA, |
0x53E9, |
0x4F46, |
0x9054, |
0x8FB0, |
0x596A, |
0x8131, |
0x5DFD, |
0x7AEA, |
0x8FBF, |
0x68DA, |
0x8C37, |
0x72F8, |
0x9C48, |
0x6A3D, |
0x8AB0, |
0x4E39, |
0x5358, |
0x5606, |
0x5766, |
0x62C5, |
0x63A2, |
0x65E6, |
0x6B4E, |
0x6DE1, |
0x6E5B, |
0x70AD, |
0x77ED, |
0x7AEF, |
0x7BAA, |
0x7DBB, |
0x803D, |
0x80C6, |
0x86CB, |
0x8A95, |
0x935B, |
0x56E3, |
0x58C7, |
0x5F3E, |
0x65AD, |
0x6696, |
0x6A80, |
0x6BB5, |
0x7537, |
0x8AC7, |
0x5024, |
0x77E5, |
0x5730, |
0x5F1B, |
0x6065, |
0x667A, |
0x6C60, |
0x75F4, |
0x7A1A, |
0x7F6E, |
0x81F4, |
0x8718, |
0x9045, |
0x99B3, |
0x7BC9, |
0x755C, |
0x7AF9, |
0x7B51, |
0x84C4, |
0x9010, |
0x79E9, |
0x7A92, |
0x8336, |
0x5AE1, |
0x7740, |
0x4E2D, |
0x4EF2, |
0x5B99, |
0x5FE0, |
0x62BD, |
0x663C, |
0x67F1, |
0x6CE8, |
0x866B, |
0x8877, |
0x8A3B, |
0x914E, |
0x92F3, |
0x99D0, |
0x6A17, |
0x7026, |
0x732A, |
0x82E7, |
0x8457, |
0x8CAF, |
0x4E01, |
0x5146, |
0x51CB, |
0x558B, |
0x5BF5, |
0x5E16, |
0x5E33, |
0x5E81, |
0x5F14, |
0x5F35, |
0x5F6B, |
0x5FB4, |
0x61F2, |
0x6311, |
0x66A2, |
0x671D, |
0x6F6E, |
0x7252, |
0x753A, |
0x773A, |
0x8074, |
0x8139, |
0x8178, |
0x8776, |
0x8ABF, |
0x8ADC, |
0x8D85, |
0x8DF3, |
0x929A, |
0x9577, |
0x9802, |
0x9CE5, |
0x52C5, |
0x6357, |
0x76F4, |
0x6715, |
0x6C88, |
0x73CD, |
0x8CC3, |
0x93AE, |
0x9673, |
0x6D25, |
0x589C, |
0x690E, |
0x69CC, |
0x8FFD, |
0x939A, |
0x75DB, |
0x901A, |
0x585A, |
0x6802, |
0x63B4, |
0x69FB, |
0x4F43, |
0x6F2C, |
0x67D8, |
0x8FBB, |
0x8526, |
0x7DB4, |
0x9354, |
0x693F, |
0x6F70, |
0x576A, |
0x58F7, |
0x5B2C, |
0x7D2C, |
0x722A, |
0x540A, |
0x91E3, |
0x9DB4, |
0x4EAD, |
0x4F4E, |
0x505C, |
0x5075, |
0x5243, |
0x8C9E, |
0x5448, |
0x5824, |
0x5B9A, |
0x5E1D, |
0x5E95, |
0x5EAD, |
0x5EF7, |
0x5F1F, |
0x608C, |
0x62B5, |
0x633A, |
0x63D0, |
0x68AF, |
0x6C40, |
0x7887, |
0x798E, |
0x7A0B, |
0x7DE0, |
0x8247, |
0x8A02, |
0x8AE6, |
0x8E44, |
0x9013, |
0x90B8, |
0x912D, |
0x91D8, |
0x9F0E, |
0x6CE5, |
0x6458, |
0x64E2, |
0x6575, |
0x6EF4, |
0x7684, |
0x7B1B, |
0x9069, |
0x93D1, |
0x6EBA, |
0x54F2, |
0x5FB9, |
0x64A4, |
0x8F4D, |
0x8FED, |
0x9244, |
0x5178, |
0x586B, |
0x5929, |
0x5C55, |
0x5E97, |
0x6DFB, |
0x7E8F, |
0x751C, |
0x8CBC, |
0x8EE2, |
0x985B, |
0x70B9, |
0x4F1D, |
0x6BBF, |
0x6FB1, |
0x7530, |
0x96FB, |
0x514E, |
0x5410, |
0x5835, |
0x5857, |
0x59AC, |
0x5C60, |
0x5F92, |
0x6597, |
0x675C, |
0x6E21, |
0x767B, |
0x83DF, |
0x8CED, |
0x9014, |
0x90FD, |
0x934D, |
0x7825, |
0x783A, |
0x52AA, |
0x5EA6, |
0x571F, |
0x5974, |
0x6012, |
0x5012, |
0x515A, |
0x51AC, |
0x51CD, |
0x5200, |
0x5510, |
0x5854, |
0x5858, |
0x5957, |
0x5B95, |
0x5CF6, |
0x5D8B, |
0x60BC, |
0x6295, |
0x642D, |
0x6771, |
0x6843, |
0x68BC, |
0x68DF, |
0x76D7, |
0x6DD8, |
0x6E6F, |
0x6D9B, |
0x706F, |
0x71C8, |
0x5F53, |
0x75D8, |
0x7977, |
0x7B49, |
0x7B54, |
0x7B52, |
0x7CD6, |
0x7D71, |
0x5230, |
0x8463, |
0x8569, |
0x85E4, |
0x8A0E, |
0x8B04, |
0x8C46, |
0x8E0F, |
0x9003, |
0x900F, |
0x9419, |
0x9676, |
0x982D, |
0x9A30, |
0x95D8, |
0x50CD, |
0x52D5, |
0x540C, |
0x5802, |
0x5C0E, |
0x61A7, |
0x649E, |
0x6D1E, |
0x77B3, |
0x7AE5, |
0x80F4, |
0x8404, |
0x9053, |
0x9285, |
0x5CE0, |
0x9D07, |
0x533F, |
0x5F97, |
0x5FB3, |
0x6D9C, |
0x7279, |
0x7763, |
0x79BF, |
0x7BE4, |
0x6BD2, |
0x72EC, |
0x8AAD, |
0x6803, |
0x6A61, |
0x51F8, |
0x7A81, |
0x6934, |
0x5C4A, |
0x9CF6, |
0x82EB, |
0x5BC5, |
0x9149, |
0x701E, |
0x5678, |
0x5C6F, |
0x60C7, |
0x6566, |
0x6C8C, |
0x8C5A, |
0x9041, |
0x9813, |
0x5451, |
0x66C7, |
0x920D, |
0x5948, |
0x90A3, |
0x5185, |
0x4E4D, |
0x51EA, |
0x8599, |
0x8B0E, |
0x7058, |
0x637A, |
0x934B, |
0x6962, |
0x99B4, |
0x7E04, |
0x7577, |
0x5357, |
0x6960, |
0x8EDF, |
0x96E3, |
0x6C5D, |
0x4E8C, |
0x5C3C, |
0x5F10, |
0x8FE9, |
0x5302, |
0x8CD1, |
0x8089, |
0x8679, |
0x5EFF, |
0x65E5, |
0x4E73, |
0x5165, |
0x5982, |
0x5C3F, |
0x97EE, |
0x4EFB, |
0x598A, |
0x5FCD, |
0x8A8D, |
0x6FE1, |
0x79B0, |
0x7962, |
0x5BE7, |
0x8471, |
0x732B, |
0x71B1, |
0x5E74, |
0x5FF5, |
0x637B, |
0x649A, |
0x71C3, |
0x7C98, |
0x4E43, |
0x5EFC, |
0x4E4B, |
0x57DC, |
0x56A2, |
0x60A9, |
0x6FC3, |
0x7D0D, |
0x80FD, |
0x8133, |
0x81BF, |
0x8FB2, |
0x8997, |
0x86A4, |
0x5DF4, |
0x628A, |
0x64AD, |
0x8987, |
0x6777, |
0x6CE2, |
0x6D3E, |
0x7436, |
0x7834, |
0x5A46, |
0x7F75, |
0x82AD, |
0x99AC, |
0x4FF3, |
0x5EC3, |
0x62DD, |
0x6392, |
0x6557, |
0x676F, |
0x76C3, |
0x724C, |
0x80CC, |
0x80BA, |
0x8F29, |
0x914D, |
0x500D, |
0x57F9, |
0x5A92, |
0x6885, |
0x6973, |
0x7164, |
0x72FD, |
0x8CB7, |
0x58F2, |
0x8CE0, |
0x966A, |
0x9019, |
0x877F, |
0x79E4, |
0x77E7, |
0x8429, |
0x4F2F, |
0x5265, |
0x535A, |
0x62CD, |
0x67CF, |
0x6CCA, |
0x767D, |
0x7B94, |
0x7C95, |
0x8236, |
0x8584, |
0x8FEB, |
0x66DD, |
0x6F20, |
0x7206, |
0x7E1B, |
0x83AB, |
0x99C1, |
0x9EA6, |
0x51FD, |
0x7BB1, |
0x7872, |
0x7BB8, |
0x8087, |
0x7B48, |
0x6AE8, |
0x5E61, |
0x808C, |
0x7551, |
0x7560, |
0x516B, |
0x9262, |
0x6E8C, |
0x767A, |
0x9197, |
0x9AEA, |
0x4F10, |
0x7F70, |
0x629C, |
0x7B4F, |
0x95A5, |
0x9CE9, |
0x567A, |
0x5859, |
0x86E4, |
0x96BC, |
0x4F34, |
0x5224, |
0x534A, |
0x53CD, |
0x53DB, |
0x5E06, |
0x642C, |
0x6591, |
0x677F, |
0x6C3E, |
0x6C4E, |
0x7248, |
0x72AF, |
0x73ED, |
0x7554, |
0x7E41, |
0x822C, |
0x85E9, |
0x8CA9, |
0x7BC4, |
0x91C6, |
0x7169, |
0x9812, |
0x98EF, |
0x633D, |
0x6669, |
0x756A, |
0x76E4, |
0x78D0, |
0x8543, |
0x86EE, |
0x532A, |
0x5351, |
0x5426, |
0x5983, |
0x5E87, |
0x5F7C, |
0x60B2, |
0x6249, |
0x6279, |
0x62AB, |
0x6590, |
0x6BD4, |
0x6CCC, |
0x75B2, |
0x76AE, |
0x7891, |
0x79D8, |
0x7DCB, |
0x7F77, |
0x80A5, |
0x88AB, |
0x8AB9, |
0x8CBB, |
0x907F, |
0x975E, |
0x98DB, |
0x6A0B, |
0x7C38, |
0x5099, |
0x5C3E, |
0x5FAE, |
0x6787, |
0x6BD8, |
0x7435, |
0x7709, |
0x7F8E, |
0x9F3B, |
0x67CA, |
0x7A17, |
0x5339, |
0x758B, |
0x9AED, |
0x5F66, |
0x819D, |
0x83F1, |
0x8098, |
0x5F3C, |
0x5FC5, |
0x7562, |
0x7B46, |
0x903C, |
0x6867, |
0x59EB, |
0x5A9B, |
0x7D10, |
0x767E, |
0x8B2C, |
0x4FF5, |
0x5F6A, |
0x6A19, |
0x6C37, |
0x6F02, |
0x74E2, |
0x7968, |
0x8868, |
0x8A55, |
0x8C79, |
0x5EDF, |
0x63CF, |
0x75C5, |
0x79D2, |
0x82D7, |
0x9328, |
0x92F2, |
0x849C, |
0x86ED, |
0x9C2D, |
0x54C1, |
0x5F6C, |
0x658C, |
0x6D5C, |
0x7015, |
0x8CA7, |
0x8CD3, |
0x983B, |
0x654F, |
0x74F6, |
0x4E0D, |
0x4ED8, |
0x57E0, |
0x592B, |
0x5A66, |
0x5BCC, |
0x51A8, |
0x5E03, |
0x5E9C, |
0x6016, |
0x6276, |
0x6577, |
0x65A7, |
0x666E, |
0x6D6E, |
0x7236, |
0x7B26, |
0x8150, |
0x819A, |
0x8299, |
0x8B5C, |
0x8CA0, |
0x8CE6, |
0x8D74, |
0x961C, |
0x9644, |
0x4FAE, |
0x64AB, |
0x6B66, |
0x821E, |
0x8461, |
0x856A, |
0x90E8, |
0x5C01, |
0x6953, |
0x98A8, |
0x847A, |
0x8557, |
0x4F0F, |
0x526F, |
0x5FA9, |
0x5E45, |
0x670D, |
0x798F, |
0x8179, |
0x8907, |
0x8986, |
0x6DF5, |
0x5F17, |
0x6255, |
0x6CB8, |
0x4ECF, |
0x7269, |
0x9B92, |
0x5206, |
0x543B, |
0x5674, |
0x58B3, |
0x61A4, |
0x626E, |
0x711A, |
0x596E, |
0x7C89, |
0x7CDE, |
0x7D1B, |
0x96F0, |
0x6587, |
0x805E, |
0x4E19, |
0x4F75, |
0x5175, |
0x5840, |
0x5E63, |
0x5E73, |
0x5F0A, |
0x67C4, |
0x4E26, |
0x853D, |
0x9589, |
0x965B, |
0x7C73, |
0x9801, |
0x50FB, |
0x58C1, |
0x7656, |
0x78A7, |
0x5225, |
0x77A5, |
0x8511, |
0x7B86, |
0x504F, |
0x5909, |
0x7247, |
0x7BC7, |
0x7DE8, |
0x8FBA, |
0x8FD4, |
0x904D, |
0x4FBF, |
0x52C9, |
0x5A29, |
0x5F01, |
0x97AD, |
0x4FDD, |
0x8217, |
0x92EA, |
0x5703, |
0x6355, |
0x6B69, |
0x752B, |
0x88DC, |
0x8F14, |
0x7A42, |
0x52DF, |
0x5893, |
0x6155, |
0x620A, |
0x66AE, |
0x6BCD, |
0x7C3F, |
0x83E9, |
0x5023, |
0x4FF8, |
0x5305, |
0x5446, |
0x5831, |
0x5949, |
0x5B9D, |
0x5CF0, |
0x5CEF, |
0x5D29, |
0x5E96, |
0x62B1, |
0x6367, |
0x653E, |
0x65B9, |
0x670B, |
0x6CD5, |
0x6CE1, |
0x70F9, |
0x7832, |
0x7E2B, |
0x80DE, |
0x82B3, |
0x840C, |
0x84EC, |
0x8702, |
0x8912, |
0x8A2A, |
0x8C4A, |
0x90A6, |
0x92D2, |
0x98FD, |
0x9CF3, |
0x9D6C, |
0x4E4F, |
0x4EA1, |
0x508D, |
0x5256, |
0x574A, |
0x59A8, |
0x5E3D, |
0x5FD8, |
0x5FD9, |
0x623F, |
0x66B4, |
0x671B, |
0x67D0, |
0x68D2, |
0x5192, |
0x7D21, |
0x80AA, |
0x81A8, |
0x8B00, |
0x8C8C, |
0x8CBF, |
0x927E, |
0x9632, |
0x5420, |
0x982C, |
0x5317, |
0x50D5, |
0x535C, |
0x58A8, |
0x64B2, |
0x6734, |
0x7267, |
0x7766, |
0x7A46, |
0x91E6, |
0x52C3, |
0x6CA1, |
0x6B86, |
0x5800, |
0x5E4C, |
0x5954, |
0x672C, |
0x7FFB, |
0x51E1, |
0x76C6, |
0x6469, |
0x78E8, |
0x9B54, |
0x9EBB, |
0x57CB, |
0x59B9, |
0x6627, |
0x679A, |
0x6BCE, |
0x54E9, |
0x69D9, |
0x5E55, |
0x819C, |
0x6795, |
0x9BAA, |
0x67FE, |
0x9C52, |
0x685D, |
0x4EA6, |
0x4FE3, |
0x53C8, |
0x62B9, |
0x672B, |
0x6CAB, |
0x8FC4, |
0x4FAD, |
0x7E6D, |
0x9EBF, |
0x4E07, |
0x6162, |
0x6E80, |
0x6F2B, |
0x8513, |
0x5473, |
0x672A, |
0x9B45, |
0x5DF3, |
0x7B95, |
0x5CAC, |
0x5BC6, |
0x871C, |
0x6E4A, |
0x84D1, |
0x7A14, |
0x8108, |
0x5999, |
0x7C8D, |
0x6C11, |
0x7720, |
0x52D9, |
0x5922, |
0x7121, |
0x725F, |
0x77DB, |
0x9727, |
0x9D61, |
0x690B, |
0x5A7F, |
0x5A18, |
0x51A5, |
0x540D, |
0x547D, |
0x660E, |
0x76DF, |
0x8FF7, |
0x9298, |
0x9CF4, |
0x59EA, |
0x725D, |
0x6EC5, |
0x514D, |
0x68C9, |
0x7DBF, |
0x7DEC, |
0x9762, |
0x9EBA, |
0x6478, |
0x6A21, |
0x8302, |
0x5984, |
0x5B5F, |
0x6BDB, |
0x731B, |
0x76F2, |
0x7DB2, |
0x8017, |
0x8499, |
0x5132, |
0x6728, |
0x9ED9, |
0x76EE, |
0x6762, |
0x52FF, |
0x9905, |
0x5C24, |
0x623B, |
0x7C7E, |
0x8CB0, |
0x554F, |
0x60B6, |
0x7D0B, |
0x9580, |
0x5301, |
0x4E5F, |
0x51B6, |
0x591C, |
0x723A, |
0x8036, |
0x91CE, |
0x5F25, |
0x77E2, |
0x5384, |
0x5F79, |
0x7D04, |
0x85AC, |
0x8A33, |
0x8E8D, |
0x9756, |
0x67F3, |
0x85AE, |
0x9453, |
0x6109, |
0x6108, |
0x6CB9, |
0x7652, |
0x8AED, |
0x8F38, |
0x552F, |
0x4F51, |
0x512A, |
0x52C7, |
0x53CB, |
0x5BA5, |
0x5E7D, |
0x60A0, |
0x6182, |
0x63D6, |
0x6709, |
0x67DA, |
0x6E67, |
0x6D8C, |
0x7336, |
0x7337, |
0x7531, |
0x7950, |
0x88D5, |
0x8A98, |
0x904A, |
0x9091, |
0x90F5, |
0x96C4, |
0x878D, |
0x5915, |
0x4E88, |
0x4F59, |
0x4E0E, |
0x8A89, |
0x8F3F, |
0x9810, |
0x50AD, |
0x5E7C, |
0x5996, |
0x5BB9, |
0x5EB8, |
0x63DA, |
0x63FA, |
0x64C1, |
0x66DC, |
0x694A, |
0x69D8, |
0x6D0B, |
0x6EB6, |
0x7194, |
0x7528, |
0x7AAF, |
0x7F8A, |
0x8000, |
0x8449, |
0x84C9, |
0x8981, |
0x8B21, |
0x8E0A, |
0x9065, |
0x967D, |
0x990A, |
0x617E, |
0x6291, |
0x6B32, |
0x6C83, |
0x6D74, |
0x7FCC, |
0x7FFC, |
0x6DC0, |
0x7F85, |
0x87BA, |
0x88F8, |
0x6765, |
0x83B1, |
0x983C, |
0x96F7, |
0x6D1B, |
0x7D61, |
0x843D, |
0x916A, |
0x4E71, |
0x5375, |
0x5D50, |
0x6B04, |
0x6FEB, |
0x85CD, |
0x862D, |
0x89A7, |
0x5229, |
0x540F, |
0x5C65, |
0x674E, |
0x68A8, |
0x7406, |
0x7483, |
0x75E2, |
0x88CF, |
0x88E1, |
0x91CC, |
0x96E2, |
0x9678, |
0x5F8B, |
0x7387, |
0x7ACB, |
0x844E, |
0x63A0, |
0x7565, |
0x5289, |
0x6D41, |
0x6E9C, |
0x7409, |
0x7559, |
0x786B, |
0x7C92, |
0x9686, |
0x7ADC, |
0x9F8D, |
0x4FB6, |
0x616E, |
0x65C5, |
0x865C, |
0x4E86, |
0x4EAE, |
0x50DA, |
0x4E21, |
0x51CC, |
0x5BEE, |
0x6599, |
0x6881, |
0x6DBC, |
0x731F, |
0x7642, |
0x77AD, |
0x7A1C, |
0x7CE7, |
0x826F, |
0x8AD2, |
0x907C, |
0x91CF, |
0x9675, |
0x9818, |
0x529B, |
0x7DD1, |
0x502B, |
0x5398, |
0x6797, |
0x6DCB, |
0x71D0, |
0x7433, |
0x81E8, |
0x8F2A, |
0x96A3, |
0x9C57, |
0x9E9F, |
0x7460, |
0x5841, |
0x6D99, |
0x7D2F, |
0x985E, |
0x4EE4, |
0x4F36, |
0x4F8B, |
0x51B7, |
0x52B1, |
0x5DBA, |
0x601C, |
0x73B2, |
0x793C, |
0x82D3, |
0x9234, |
0x96B7, |
0x96F6, |
0x970A, |
0x9E97, |
0x9F62, |
0x66A6, |
0x6B74, |
0x5217, |
0x52A3, |
0x70C8, |
0x88C2, |
0x5EC9, |
0x604B, |
0x6190, |
0x6F23, |
0x7149, |
0x7C3E, |
0x7DF4, |
0x806F, |
0x84EE, |
0x9023, |
0x932C, |
0x5442, |
0x9B6F, |
0x6AD3, |
0x7089, |
0x8CC2, |
0x8DEF, |
0x9732, |
0x52B4, |
0x5A41, |
0x5ECA, |
0x5F04, |
0x6717, |
0x697C, |
0x6994, |
0x6D6A, |
0x6F0F, |
0x7262, |
0x72FC, |
0x7BED, |
0x8001, |
0x807E, |
0x874B, |
0x90CE, |
0x516D, |
0x9E93, |
0x7984, |
0x808B, |
0x9332, |
0x8AD6, |
0x502D, |
0x548C, |
0x8A71, |
0x6B6A, |
0x8CC4, |
0x8107, |
0x60D1, |
0x67A0, |
0x9DF2, |
0x4E99, |
0x4E98, |
0x9C10, |
0x8A6B, |
0x85C1, |
0x8568, |
0x6900, |
0x6E7E, |
0x7897, |
0x8155 |
}; |
/* d0a1 to f4a6 is contiguous */ |
static unsigned short d02f4[] = { |
0x5F0C, |
0x4E10, |
0x4E15, |
0x4E2A, |
0x4E31, |
0x4E36, |
0x4E3C, |
0x4E3F, |
0x4E42, |
0x4E56, |
0x4E58, |
0x4E82, |
0x4E85, |
0x8C6B, |
0x4E8A, |
0x8212, |
0x5F0D, |
0x4E8E, |
0x4E9E, |
0x4E9F, |
0x4EA0, |
0x4EA2, |
0x4EB0, |
0x4EB3, |
0x4EB6, |
0x4ECE, |
0x4ECD, |
0x4EC4, |
0x4EC6, |
0x4EC2, |
0x4ED7, |
0x4EDE, |
0x4EED, |
0x4EDF, |
0x4EF7, |
0x4F09, |
0x4F5A, |
0x4F30, |
0x4F5B, |
0x4F5D, |
0x4F57, |
0x4F47, |
0x4F76, |
0x4F88, |
0x4F8F, |
0x4F98, |
0x4F7B, |
0x4F69, |
0x4F70, |
0x4F91, |
0x4F6F, |
0x4F86, |
0x4F96, |
0x5118, |
0x4FD4, |
0x4FDF, |
0x4FCE, |
0x4FD8, |
0x4FDB, |
0x4FD1, |
0x4FDA, |
0x4FD0, |
0x4FE4, |
0x4FE5, |
0x501A, |
0x5028, |
0x5014, |
0x502A, |
0x5025, |
0x5005, |
0x4F1C, |
0x4FF6, |
0x5021, |
0x5029, |
0x502C, |
0x4FFE, |
0x4FEF, |
0x5011, |
0x5006, |
0x5043, |
0x5047, |
0x6703, |
0x5055, |
0x5050, |
0x5048, |
0x505A, |
0x5056, |
0x506C, |
0x5078, |
0x5080, |
0x509A, |
0x5085, |
0x50B4, |
0x50B2, |
0x50C9, |
0x50CA, |
0x50B3, |
0x50C2, |
0x50D6, |
0x50DE, |
0x50E5, |
0x50ED, |
0x50E3, |
0x50EE, |
0x50F9, |
0x50F5, |
0x5109, |
0x5101, |
0x5102, |
0x5116, |
0x5115, |
0x5114, |
0x511A, |
0x5121, |
0x513A, |
0x5137, |
0x513C, |
0x513B, |
0x513F, |
0x5140, |
0x5152, |
0x514C, |
0x5154, |
0x5162, |
0x7AF8, |
0x5169, |
0x516A, |
0x516E, |
0x5180, |
0x5182, |
0x56D8, |
0x518C, |
0x5189, |
0x518F, |
0x5191, |
0x5193, |
0x5195, |
0x5196, |
0x51A4, |
0x51A6, |
0x51A2, |
0x51A9, |
0x51AA, |
0x51AB, |
0x51B3, |
0x51B1, |
0x51B2, |
0x51B0, |
0x51B5, |
0x51BD, |
0x51C5, |
0x51C9, |
0x51DB, |
0x51E0, |
0x8655, |
0x51E9, |
0x51ED, |
0x51F0, |
0x51F5, |
0x51FE, |
0x5204, |
0x520B, |
0x5214, |
0x520E, |
0x5227, |
0x522A, |
0x522E, |
0x5233, |
0x5239, |
0x524F, |
0x5244, |
0x524B, |
0x524C, |
0x525E, |
0x5254, |
0x526A, |
0x5274, |
0x5269, |
0x5273, |
0x527F, |
0x527D, |
0x528D, |
0x5294, |
0x5292, |
0x5271, |
0x5288, |
0x5291, |
0x8FA8, |
0x8FA7, |
0x52AC, |
0x52AD, |
0x52BC, |
0x52B5, |
0x52C1, |
0x52CD, |
0x52D7, |
0x52DE, |
0x52E3, |
0x52E6, |
0x98ED, |
0x52E0, |
0x52F3, |
0x52F5, |
0x52F8, |
0x52F9, |
0x5306, |
0x5308, |
0x7538, |
0x530D, |
0x5310, |
0x530F, |
0x5315, |
0x531A, |
0x5323, |
0x532F, |
0x5331, |
0x5333, |
0x5338, |
0x5340, |
0x5346, |
0x5345, |
0x4E17, |
0x5349, |
0x534D, |
0x51D6, |
0x535E, |
0x5369, |
0x536E, |
0x5918, |
0x537B, |
0x5377, |
0x5382, |
0x5396, |
0x53A0, |
0x53A6, |
0x53A5, |
0x53AE, |
0x53B0, |
0x53B6, |
0x53C3, |
0x7C12, |
0x96D9, |
0x53DF, |
0x66FC, |
0x71EE, |
0x53EE, |
0x53E8, |
0x53ED, |
0x53FA, |
0x5401, |
0x543D, |
0x5440, |
0x542C, |
0x542D, |
0x543C, |
0x542E, |
0x5436, |
0x5429, |
0x541D, |
0x544E, |
0x548F, |
0x5475, |
0x548E, |
0x545F, |
0x5471, |
0x5477, |
0x5470, |
0x5492, |
0x547B, |
0x5480, |
0x5476, |
0x5484, |
0x5490, |
0x5486, |
0x54C7, |
0x54A2, |
0x54B8, |
0x54A5, |
0x54AC, |
0x54C4, |
0x54C8, |
0x54A8, |
0x54AB, |
0x54C2, |
0x54A4, |
0x54BE, |
0x54BC, |
0x54D8, |
0x54E5, |
0x54E6, |
0x550F, |
0x5514, |
0x54FD, |
0x54EE, |
0x54ED, |
0x54FA, |
0x54E2, |
0x5539, |
0x5540, |
0x5563, |
0x554C, |
0x552E, |
0x555C, |
0x5545, |
0x5556, |
0x5557, |
0x5538, |
0x5533, |
0x555D, |
0x5599, |
0x5580, |
0x54AF, |
0x558A, |
0x559F, |
0x557B, |
0x557E, |
0x5598, |
0x559E, |
0x55AE, |
0x557C, |
0x5583, |
0x55A9, |
0x5587, |
0x55A8, |
0x55DA, |
0x55C5, |
0x55DF, |
0x55C4, |
0x55DC, |
0x55E4, |
0x55D4, |
0x5614, |
0x55F7, |
0x5616, |
0x55FE, |
0x55FD, |
0x561B, |
0x55F9, |
0x564E, |
0x5650, |
0x71DF, |
0x5634, |
0x5636, |
0x5632, |
0x5638, |
0x566B, |
0x5664, |
0x562F, |
0x566C, |
0x566A, |
0x5686, |
0x5680, |
0x568A, |
0x56A0, |
0x5694, |
0x568F, |
0x56A5, |
0x56AE, |
0x56B6, |
0x56B4, |
0x56C2, |
0x56BC, |
0x56C1, |
0x56C3, |
0x56C0, |
0x56C8, |
0x56CE, |
0x56D1, |
0x56D3, |
0x56D7, |
0x56EE, |
0x56F9, |
0x5700, |
0x56FF, |
0x5704, |
0x5709, |
0x5708, |
0x570B, |
0x570D, |
0x5713, |
0x5718, |
0x5716, |
0x55C7, |
0x571C, |
0x5726, |
0x5737, |
0x5738, |
0x574E, |
0x573B, |
0x5740, |
0x574F, |
0x5769, |
0x57C0, |
0x5788, |
0x5761, |
0x577F, |
0x5789, |
0x5793, |
0x57A0, |
0x57B3, |
0x57A4, |
0x57AA, |
0x57B0, |
0x57C3, |
0x57C6, |
0x57D4, |
0x57D2, |
0x57D3, |
0x580A, |
0x57D6, |
0x57E3, |
0x580B, |
0x5819, |
0x581D, |
0x5872, |
0x5821, |
0x5862, |
0x584B, |
0x5870, |
0x6BC0, |
0x5852, |
0x583D, |
0x5879, |
0x5885, |
0x58B9, |
0x589F, |
0x58AB, |
0x58BA, |
0x58DE, |
0x58BB, |
0x58B8, |
0x58AE, |
0x58C5, |
0x58D3, |
0x58D1, |
0x58D7, |
0x58D9, |
0x58D8, |
0x58E5, |
0x58DC, |
0x58E4, |
0x58DF, |
0x58EF, |
0x58FA, |
0x58F9, |
0x58FB, |
0x58FC, |
0x58FD, |
0x5902, |
0x590A, |
0x5910, |
0x591B, |
0x68A6, |
0x5925, |
0x592C, |
0x592D, |
0x5932, |
0x5938, |
0x593E, |
0x7AD2, |
0x5955, |
0x5950, |
0x594E, |
0x595A, |
0x5958, |
0x5962, |
0x5960, |
0x5967, |
0x596C, |
0x5969, |
0x5978, |
0x5981, |
0x599D, |
0x4F5E, |
0x4FAB, |
0x59A3, |
0x59B2, |
0x59C6, |
0x59E8, |
0x59DC, |
0x598D, |
0x59D9, |
0x59DA, |
0x5A25, |
0x5A1F, |
0x5A11, |
0x5A1C, |
0x5A09, |
0x5A1A, |
0x5A40, |
0x5A6C, |
0x5A49, |
0x5A35, |
0x5A36, |
0x5A62, |
0x5A6A, |
0x5A9A, |
0x5ABC, |
0x5ABE, |
0x5ACB, |
0x5AC2, |
0x5ABD, |
0x5AE3, |
0x5AD7, |
0x5AE6, |
0x5AE9, |
0x5AD6, |
0x5AFA, |
0x5AFB, |
0x5B0C, |
0x5B0B, |
0x5B16, |
0x5B32, |
0x5AD0, |
0x5B2A, |
0x5B36, |
0x5B3E, |
0x5B43, |
0x5B45, |
0x5B40, |
0x5B51, |
0x5B55, |
0x5B5A, |
0x5B5B, |
0x5B65, |
0x5B69, |
0x5B70, |
0x5B73, |
0x5B75, |
0x5B78, |
0x6588, |
0x5B7A, |
0x5B80, |
0x5B83, |
0x5BA6, |
0x5BB8, |
0x5BC3, |
0x5BC7, |
0x5BC9, |
0x5BD4, |
0x5BD0, |
0x5BE4, |
0x5BE6, |
0x5BE2, |
0x5BDE, |
0x5BE5, |
0x5BEB, |
0x5BF0, |
0x5BF6, |
0x5BF3, |
0x5C05, |
0x5C07, |
0x5C08, |
0x5C0D, |
0x5C13, |
0x5C20, |
0x5C22, |
0x5C28, |
0x5C38, |
0x5C39, |
0x5C41, |
0x5C46, |
0x5C4E, |
0x5C53, |
0x5C50, |
0x5C4F, |
0x5B71, |
0x5C6C, |
0x5C6E, |
0x4E62, |
0x5C76, |
0x5C79, |
0x5C8C, |
0x5C91, |
0x5C94, |
0x599B, |
0x5CAB, |
0x5CBB, |
0x5CB6, |
0x5CBC, |
0x5CB7, |
0x5CC5, |
0x5CBE, |
0x5CC7, |
0x5CD9, |
0x5CE9, |
0x5CFD, |
0x5CFA, |
0x5CED, |
0x5D8C, |
0x5CEA, |
0x5D0B, |
0x5D15, |
0x5D17, |
0x5D5C, |
0x5D1F, |
0x5D1B, |
0x5D11, |
0x5D14, |
0x5D22, |
0x5D1A, |
0x5D19, |
0x5D18, |
0x5D4C, |
0x5D52, |
0x5D4E, |
0x5D4B, |
0x5D6C, |
0x5D73, |
0x5D76, |
0x5D87, |
0x5D84, |
0x5D82, |
0x5DA2, |
0x5D9D, |
0x5DAC, |
0x5DAE, |
0x5DBD, |
0x5D90, |
0x5DB7, |
0x5DBC, |
0x5DC9, |
0x5DCD, |
0x5DD3, |
0x5DD2, |
0x5DD6, |
0x5DDB, |
0x5DEB, |
0x5DF2, |
0x5DF5, |
0x5E0B, |
0x5E1A, |
0x5E19, |
0x5E11, |
0x5E1B, |
0x5E36, |
0x5E37, |
0x5E44, |
0x5E43, |
0x5E40, |
0x5E4E, |
0x5E57, |
0x5E54, |
0x5E5F, |
0x5E62, |
0x5E64, |
0x5E47, |
0x5E75, |
0x5E76, |
0x5E7A, |
0x9EBC, |
0x5E7F, |
0x5EA0, |
0x5EC1, |
0x5EC2, |
0x5EC8, |
0x5ED0, |
0x5ECF, |
0x5ED6, |
0x5EE3, |
0x5EDD, |
0x5EDA, |
0x5EDB, |
0x5EE2, |
0x5EE1, |
0x5EE8, |
0x5EE9, |
0x5EEC, |
0x5EF1, |
0x5EF3, |
0x5EF0, |
0x5EF4, |
0x5EF8, |
0x5EFE, |
0x5F03, |
0x5F09, |
0x5F5D, |
0x5F5C, |
0x5F0B, |
0x5F11, |
0x5F16, |
0x5F29, |
0x5F2D, |
0x5F38, |
0x5F41, |
0x5F48, |
0x5F4C, |
0x5F4E, |
0x5F2F, |
0x5F51, |
0x5F56, |
0x5F57, |
0x5F59, |
0x5F61, |
0x5F6D, |
0x5F73, |
0x5F77, |
0x5F83, |
0x5F82, |
0x5F7F, |
0x5F8A, |
0x5F88, |
0x5F91, |
0x5F87, |
0x5F9E, |
0x5F99, |
0x5F98, |
0x5FA0, |
0x5FA8, |
0x5FAD, |
0x5FBC, |
0x5FD6, |
0x5FFB, |
0x5FE4, |
0x5FF8, |
0x5FF1, |
0x5FDD, |
0x60B3, |
0x5FFF, |
0x6021, |
0x6060, |
0x6019, |
0x6010, |
0x6029, |
0x600E, |
0x6031, |
0x601B, |
0x6015, |
0x602B, |
0x6026, |
0x600F, |
0x603A, |
0x605A, |
0x6041, |
0x606A, |
0x6077, |
0x605F, |
0x604A, |
0x6046, |
0x604D, |
0x6063, |
0x6043, |
0x6064, |
0x6042, |
0x606C, |
0x606B, |
0x6059, |
0x6081, |
0x608D, |
0x60E7, |
0x6083, |
0x609A, |
0x6084, |
0x609B, |
0x6096, |
0x6097, |
0x6092, |
0x60A7, |
0x608B, |
0x60E1, |
0x60B8, |
0x60E0, |
0x60D3, |
0x60B4, |
0x5FF0, |
0x60BD, |
0x60C6, |
0x60B5, |
0x60D8, |
0x614D, |
0x6115, |
0x6106, |
0x60F6, |
0x60F7, |
0x6100, |
0x60F4, |
0x60FA, |
0x6103, |
0x6121, |
0x60FB, |
0x60F1, |
0x610D, |
0x610E, |
0x6147, |
0x613E, |
0x6128, |
0x6127, |
0x614A, |
0x613F, |
0x613C, |
0x612C, |
0x6134, |
0x613D, |
0x6142, |
0x6144, |
0x6173, |
0x6177, |
0x6158, |
0x6159, |
0x615A, |
0x616B, |
0x6174, |
0x616F, |
0x6165, |
0x6171, |
0x615F, |
0x615D, |
0x6153, |
0x6175, |
0x6199, |
0x6196, |
0x6187, |
0x61AC, |
0x6194, |
0x619A, |
0x618A, |
0x6191, |
0x61AB, |
0x61AE, |
0x61CC, |
0x61CA, |
0x61C9, |
0x61F7, |
0x61C8, |
0x61C3, |
0x61C6, |
0x61BA, |
0x61CB, |
0x7F79, |
0x61CD, |
0x61E6, |
0x61E3, |
0x61F6, |
0x61FA, |
0x61F4, |
0x61FF, |
0x61FD, |
0x61FC, |
0x61FE, |
0x6200, |
0x6208, |
0x6209, |
0x620D, |
0x620C, |
0x6214, |
0x621B, |
0x621E, |
0x6221, |
0x622A, |
0x622E, |
0x6230, |
0x6232, |
0x6233, |
0x6241, |
0x624E, |
0x625E, |
0x6263, |
0x625B, |
0x6260, |
0x6268, |
0x627C, |
0x6282, |
0x6289, |
0x627E, |
0x6292, |
0x6293, |
0x6296, |
0x62D4, |
0x6283, |
0x6294, |
0x62D7, |
0x62D1, |
0x62BB, |
0x62CF, |
0x62FF, |
0x62C6, |
0x64D4, |
0x62C8, |
0x62DC, |
0x62CC, |
0x62CA, |
0x62C2, |
0x62C7, |
0x629B, |
0x62C9, |
0x630C, |
0x62EE, |
0x62F1, |
0x6327, |
0x6302, |
0x6308, |
0x62EF, |
0x62F5, |
0x6350, |
0x633E, |
0x634D, |
0x641C, |
0x634F, |
0x6396, |
0x638E, |
0x6380, |
0x63AB, |
0x6376, |
0x63A3, |
0x638F, |
0x6389, |
0x639F, |
0x63B5, |
0x636B, |
0x6369, |
0x63BE, |
0x63E9, |
0x63C0, |
0x63C6, |
0x63E3, |
0x63C9, |
0x63D2, |
0x63F6, |
0x63C4, |
0x6416, |
0x6434, |
0x6406, |
0x6413, |
0x6426, |
0x6436, |
0x651D, |
0x6417, |
0x6428, |
0x640F, |
0x6467, |
0x646F, |
0x6476, |
0x644E, |
0x652A, |
0x6495, |
0x6493, |
0x64A5, |
0x64A9, |
0x6488, |
0x64BC, |
0x64DA, |
0x64D2, |
0x64C5, |
0x64C7, |
0x64BB, |
0x64D8, |
0x64C2, |
0x64F1, |
0x64E7, |
0x8209, |
0x64E0, |
0x64E1, |
0x62AC, |
0x64E3, |
0x64EF, |
0x652C, |
0x64F6, |
0x64F4, |
0x64F2, |
0x64FA, |
0x6500, |
0x64FD, |
0x6518, |
0x651C, |
0x6505, |
0x6524, |
0x6523, |
0x652B, |
0x6534, |
0x6535, |
0x6537, |
0x6536, |
0x6538, |
0x754B, |
0x6548, |
0x6556, |
0x6555, |
0x654D, |
0x6558, |
0x655E, |
0x655D, |
0x6572, |
0x6578, |
0x6582, |
0x6583, |
0x8B8A, |
0x659B, |
0x659F, |
0x65AB, |
0x65B7, |
0x65C3, |
0x65C6, |
0x65C1, |
0x65C4, |
0x65CC, |
0x65D2, |
0x65DB, |
0x65D9, |
0x65E0, |
0x65E1, |
0x65F1, |
0x6772, |
0x660A, |
0x6603, |
0x65FB, |
0x6773, |
0x6635, |
0x6636, |
0x6634, |
0x661C, |
0x664F, |
0x6644, |
0x6649, |
0x6641, |
0x665E, |
0x665D, |
0x6664, |
0x6667, |
0x6668, |
0x665F, |
0x6662, |
0x6670, |
0x6683, |
0x6688, |
0x668E, |
0x6689, |
0x6684, |
0x6698, |
0x669D, |
0x66C1, |
0x66B9, |
0x66C9, |
0x66BE, |
0x66BC, |
0x66C4, |
0x66B8, |
0x66D6, |
0x66DA, |
0x66E0, |
0x663F, |
0x66E6, |
0x66E9, |
0x66F0, |
0x66F5, |
0x66F7, |
0x670F, |
0x6716, |
0x671E, |
0x6726, |
0x6727, |
0x9738, |
0x672E, |
0x673F, |
0x6736, |
0x6741, |
0x6738, |
0x6737, |
0x6746, |
0x675E, |
0x6760, |
0x6759, |
0x6763, |
0x6764, |
0x6789, |
0x6770, |
0x67A9, |
0x677C, |
0x676A, |
0x678C, |
0x678B, |
0x67A6, |
0x67A1, |
0x6785, |
0x67B7, |
0x67EF, |
0x67B4, |
0x67EC, |
0x67B3, |
0x67E9, |
0x67B8, |
0x67E4, |
0x67DE, |
0x67DD, |
0x67E2, |
0x67EE, |
0x67B9, |
0x67CE, |
0x67C6, |
0x67E7, |
0x6A9C, |
0x681E, |
0x6846, |
0x6829, |
0x6840, |
0x684D, |
0x6832, |
0x684E, |
0x68B3, |
0x682B, |
0x6859, |
0x6863, |
0x6877, |
0x687F, |
0x689F, |
0x688F, |
0x68AD, |
0x6894, |
0x689D, |
0x689B, |
0x6883, |
0x6AAE, |
0x68B9, |
0x6874, |
0x68B5, |
0x68A0, |
0x68BA, |
0x690F, |
0x688D, |
0x687E, |
0x6901, |
0x68CA, |
0x6908, |
0x68D8, |
0x6922, |
0x6926, |
0x68E1, |
0x690C, |
0x68CD, |
0x68D4, |
0x68E7, |
0x68D5, |
0x6936, |
0x6912, |
0x6904, |
0x68D7, |
0x68E3, |
0x6925, |
0x68F9, |
0x68E0, |
0x68EF, |
0x6928, |
0x692A, |
0x691A, |
0x6923, |
0x6921, |
0x68C6, |
0x6979, |
0x6977, |
0x695C, |
0x6978, |
0x696B, |
0x6954, |
0x697E, |
0x696E, |
0x6939, |
0x6974, |
0x693D, |
0x6959, |
0x6930, |
0x6961, |
0x695E, |
0x695D, |
0x6981, |
0x696A, |
0x69B2, |
0x69AE, |
0x69D0, |
0x69BF, |
0x69C1, |
0x69D3, |
0x69BE, |
0x69CE, |
0x5BE8, |
0x69CA, |
0x69DD, |
0x69BB, |
0x69C3, |
0x69A7, |
0x6A2E, |
0x6991, |
0x69A0, |
0x699C, |
0x6995, |
0x69B4, |
0x69DE, |
0x69E8, |
0x6A02, |
0x6A1B, |
0x69FF, |
0x6B0A, |
0x69F9, |
0x69F2, |
0x69E7, |
0x6A05, |
0x69B1, |
0x6A1E, |
0x69ED, |
0x6A14, |
0x69EB, |
0x6A0A, |
0x6A12, |
0x6AC1, |
0x6A23, |
0x6A13, |
0x6A44, |
0x6A0C, |
0x6A72, |
0x6A36, |
0x6A78, |
0x6A47, |
0x6A62, |
0x6A59, |
0x6A66, |
0x6A48, |
0x6A38, |
0x6A22, |
0x6A90, |
0x6A8D, |
0x6AA0, |
0x6A84, |
0x6AA2, |
0x6AA3, |
0x6A97, |
0x8617, |
0x6ABB, |
0x6AC3, |
0x6AC2, |
0x6AB8, |
0x6AB3, |
0x6AAC, |
0x6ADE, |
0x6AD1, |
0x6ADF, |
0x6AAA, |
0x6ADA, |
0x6AEA, |
0x6AFB, |
0x6B05, |
0x8616, |
0x6AFA, |
0x6B12, |
0x6B16, |
0x9B31, |
0x6B1F, |
0x6B38, |
0x6B37, |
0x76DC, |
0x6B39, |
0x98EE, |
0x6B47, |
0x6B43, |
0x6B49, |
0x6B50, |
0x6B59, |
0x6B54, |
0x6B5B, |
0x6B5F, |
0x6B61, |
0x6B78, |
0x6B79, |
0x6B7F, |
0x6B80, |
0x6B84, |
0x6B83, |
0x6B8D, |
0x6B98, |
0x6B95, |
0x6B9E, |
0x6BA4, |
0x6BAA, |
0x6BAB, |
0x6BAF, |
0x6BB2, |
0x6BB1, |
0x6BB3, |
0x6BB7, |
0x6BBC, |
0x6BC6, |
0x6BCB, |
0x6BD3, |
0x6BDF, |
0x6BEC, |
0x6BEB, |
0x6BF3, |
0x6BEF, |
0x9EBE, |
0x6C08, |
0x6C13, |
0x6C14, |
0x6C1B, |
0x6C24, |
0x6C23, |
0x6C5E, |
0x6C55, |
0x6C62, |
0x6C6A, |
0x6C82, |
0x6C8D, |
0x6C9A, |
0x6C81, |
0x6C9B, |
0x6C7E, |
0x6C68, |
0x6C73, |
0x6C92, |
0x6C90, |
0x6CC4, |
0x6CF1, |
0x6CD3, |
0x6CBD, |
0x6CD7, |
0x6CC5, |
0x6CDD, |
0x6CAE, |
0x6CB1, |
0x6CBE, |
0x6CBA, |
0x6CDB, |
0x6CEF, |
0x6CD9, |
0x6CEA, |
0x6D1F, |
0x884D, |
0x6D36, |
0x6D2B, |
0x6D3D, |
0x6D38, |
0x6D19, |
0x6D35, |
0x6D33, |
0x6D12, |
0x6D0C, |
0x6D63, |
0x6D93, |
0x6D64, |
0x6D5A, |
0x6D79, |
0x6D59, |
0x6D8E, |
0x6D95, |
0x6FE4, |
0x6D85, |
0x6DF9, |
0x6E15, |
0x6E0A, |
0x6DB5, |
0x6DC7, |
0x6DE6, |
0x6DB8, |
0x6DC6, |
0x6DEC, |
0x6DDE, |
0x6DCC, |
0x6DE8, |
0x6DD2, |
0x6DC5, |
0x6DFA, |
0x6DD9, |
0x6DE4, |
0x6DD5, |
0x6DEA, |
0x6DEE, |
0x6E2D, |
0x6E6E, |
0x6E2E, |
0x6E19, |
0x6E72, |
0x6E5F, |
0x6E3E, |
0x6E23, |
0x6E6B, |
0x6E2B, |
0x6E76, |
0x6E4D, |
0x6E1F, |
0x6E43, |
0x6E3A, |
0x6E4E, |
0x6E24, |
0x6EFF, |
0x6E1D, |
0x6E38, |
0x6E82, |
0x6EAA, |
0x6E98, |
0x6EC9, |
0x6EB7, |
0x6ED3, |
0x6EBD, |
0x6EAF, |
0x6EC4, |
0x6EB2, |
0x6ED4, |
0x6ED5, |
0x6E8F, |
0x6EA5, |
0x6EC2, |
0x6E9F, |
0x6F41, |
0x6F11, |
0x704C, |
0x6EEC, |
0x6EF8, |
0x6EFE, |
0x6F3F, |
0x6EF2, |
0x6F31, |
0x6EEF, |
0x6F32, |
0x6ECC, |
0x6F3E, |
0x6F13, |
0x6EF7, |
0x6F86, |
0x6F7A, |
0x6F78, |
0x6F81, |
0x6F80, |
0x6F6F, |
0x6F5B, |
0x6FF3, |
0x6F6D, |
0x6F82, |
0x6F7C, |
0x6F58, |
0x6F8E, |
0x6F91, |
0x6FC2, |
0x6F66, |
0x6FB3, |
0x6FA3, |
0x6FA1, |
0x6FA4, |
0x6FB9, |
0x6FC6, |
0x6FAA, |
0x6FDF, |
0x6FD5, |
0x6FEC, |
0x6FD4, |
0x6FD8, |
0x6FF1, |
0x6FEE, |
0x6FDB, |
0x7009, |
0x700B, |
0x6FFA, |
0x7011, |
0x7001, |
0x700F, |
0x6FFE, |
0x701B, |
0x701A, |
0x6F74, |
0x701D, |
0x7018, |
0x701F, |
0x7030, |
0x703E, |
0x7032, |
0x7051, |
0x7063, |
0x7099, |
0x7092, |
0x70AF, |
0x70F1, |
0x70AC, |
0x70B8, |
0x70B3, |
0x70AE, |
0x70DF, |
0x70CB, |
0x70DD, |
0x70D9, |
0x7109, |
0x70FD, |
0x711C, |
0x7119, |
0x7165, |
0x7155, |
0x7188, |
0x7166, |
0x7162, |
0x714C, |
0x7156, |
0x716C, |
0x718F, |
0x71FB, |
0x7184, |
0x7195, |
0x71A8, |
0x71AC, |
0x71D7, |
0x71B9, |
0x71BE, |
0x71D2, |
0x71C9, |
0x71D4, |
0x71CE, |
0x71E0, |
0x71EC, |
0x71E7, |
0x71F5, |
0x71FC, |
0x71F9, |
0x71FF, |
0x720D, |
0x7210, |
0x721B, |
0x7228, |
0x722D, |
0x722C, |
0x7230, |
0x7232, |
0x723B, |
0x723C, |
0x723F, |
0x7240, |
0x7246, |
0x724B, |
0x7258, |
0x7274, |
0x727E, |
0x7282, |
0x7281, |
0x7287, |
0x7292, |
0x7296, |
0x72A2, |
0x72A7, |
0x72B9, |
0x72B2, |
0x72C3, |
0x72C6, |
0x72C4, |
0x72CE, |
0x72D2, |
0x72E2, |
0x72E0, |
0x72E1, |
0x72F9, |
0x72F7, |
0x500F, |
0x7317, |
0x730A, |
0x731C, |
0x7316, |
0x731D, |
0x7334, |
0x732F, |
0x7329, |
0x7325, |
0x733E, |
0x734E, |
0x734F, |
0x9ED8, |
0x7357, |
0x736A, |
0x7368, |
0x7370, |
0x7378, |
0x7375, |
0x737B, |
0x737A, |
0x73C8, |
0x73B3, |
0x73CE, |
0x73BB, |
0x73C0, |
0x73E5, |
0x73EE, |
0x73DE, |
0x74A2, |
0x7405, |
0x746F, |
0x7425, |
0x73F8, |
0x7432, |
0x743A, |
0x7455, |
0x743F, |
0x745F, |
0x7459, |
0x7441, |
0x745C, |
0x7469, |
0x7470, |
0x7463, |
0x746A, |
0x7476, |
0x747E, |
0x748B, |
0x749E, |
0x74A7, |
0x74CA, |
0x74CF, |
0x74D4, |
0x73F1, |
0x74E0, |
0x74E3, |
0x74E7, |
0x74E9, |
0x74EE, |
0x74F2, |
0x74F0, |
0x74F1, |
0x74F8, |
0x74F7, |
0x7504, |
0x7503, |
0x7505, |
0x750C, |
0x750E, |
0x750D, |
0x7515, |
0x7513, |
0x751E, |
0x7526, |
0x752C, |
0x753C, |
0x7544, |
0x754D, |
0x754A, |
0x7549, |
0x755B, |
0x7546, |
0x755A, |
0x7569, |
0x7564, |
0x7567, |
0x756B, |
0x756D, |
0x7578, |
0x7576, |
0x7586, |
0x7587, |
0x7574, |
0x758A, |
0x7589, |
0x7582, |
0x7594, |
0x759A, |
0x759D, |
0x75A5, |
0x75A3, |
0x75C2, |
0x75B3, |
0x75C3, |
0x75B5, |
0x75BD, |
0x75B8, |
0x75BC, |
0x75B1, |
0x75CD, |
0x75CA, |
0x75D2, |
0x75D9, |
0x75E3, |
0x75DE, |
0x75FE, |
0x75FF, |
0x75FC, |
0x7601, |
0x75F0, |
0x75FA, |
0x75F2, |
0x75F3, |
0x760B, |
0x760D, |
0x7609, |
0x761F, |
0x7627, |
0x7620, |
0x7621, |
0x7622, |
0x7624, |
0x7634, |
0x7630, |
0x763B, |
0x7647, |
0x7648, |
0x7646, |
0x765C, |
0x7658, |
0x7661, |
0x7662, |
0x7668, |
0x7669, |
0x766A, |
0x7667, |
0x766C, |
0x7670, |
0x7672, |
0x7676, |
0x7678, |
0x767C, |
0x7680, |
0x7683, |
0x7688, |
0x768B, |
0x768E, |
0x7696, |
0x7693, |
0x7699, |
0x769A, |
0x76B0, |
0x76B4, |
0x76B8, |
0x76B9, |
0x76BA, |
0x76C2, |
0x76CD, |
0x76D6, |
0x76D2, |
0x76DE, |
0x76E1, |
0x76E5, |
0x76E7, |
0x76EA, |
0x862F, |
0x76FB, |
0x7708, |
0x7707, |
0x7704, |
0x7729, |
0x7724, |
0x771E, |
0x7725, |
0x7726, |
0x771B, |
0x7737, |
0x7738, |
0x7747, |
0x775A, |
0x7768, |
0x776B, |
0x775B, |
0x7765, |
0x777F, |
0x777E, |
0x7779, |
0x778E, |
0x778B, |
0x7791, |
0x77A0, |
0x779E, |
0x77B0, |
0x77B6, |
0x77B9, |
0x77BF, |
0x77BC, |
0x77BD, |
0x77BB, |
0x77C7, |
0x77CD, |
0x77D7, |
0x77DA, |
0x77DC, |
0x77E3, |
0x77EE, |
0x77FC, |
0x780C, |
0x7812, |
0x7926, |
0x7820, |
0x792A, |
0x7845, |
0x788E, |
0x7874, |
0x7886, |
0x787C, |
0x789A, |
0x788C, |
0x78A3, |
0x78B5, |
0x78AA, |
0x78AF, |
0x78D1, |
0x78C6, |
0x78CB, |
0x78D4, |
0x78BE, |
0x78BC, |
0x78C5, |
0x78CA, |
0x78EC, |
0x78E7, |
0x78DA, |
0x78FD, |
0x78F4, |
0x7907, |
0x7912, |
0x7911, |
0x7919, |
0x792C, |
0x792B, |
0x7940, |
0x7960, |
0x7957, |
0x795F, |
0x795A, |
0x7955, |
0x7953, |
0x797A, |
0x797F, |
0x798A, |
0x799D, |
0x79A7, |
0x9F4B, |
0x79AA, |
0x79AE, |
0x79B3, |
0x79B9, |
0x79BA, |
0x79C9, |
0x79D5, |
0x79E7, |
0x79EC, |
0x79E1, |
0x79E3, |
0x7A08, |
0x7A0D, |
0x7A18, |
0x7A19, |
0x7A20, |
0x7A1F, |
0x7980, |
0x7A31, |
0x7A3B, |
0x7A3E, |
0x7A37, |
0x7A43, |
0x7A57, |
0x7A49, |
0x7A61, |
0x7A62, |
0x7A69, |
0x9F9D, |
0x7A70, |
0x7A79, |
0x7A7D, |
0x7A88, |
0x7A97, |
0x7A95, |
0x7A98, |
0x7A96, |
0x7AA9, |
0x7AC8, |
0x7AB0, |
0x7AB6, |
0x7AC5, |
0x7AC4, |
0x7ABF, |
0x9083, |
0x7AC7, |
0x7ACA, |
0x7ACD, |
0x7ACF, |
0x7AD5, |
0x7AD3, |
0x7AD9, |
0x7ADA, |
0x7ADD, |
0x7AE1, |
0x7AE2, |
0x7AE6, |
0x7AED, |
0x7AF0, |
0x7B02, |
0x7B0F, |
0x7B0A, |
0x7B06, |
0x7B33, |
0x7B18, |
0x7B19, |
0x7B1E, |
0x7B35, |
0x7B28, |
0x7B36, |
0x7B50, |
0x7B7A, |
0x7B04, |
0x7B4D, |
0x7B0B, |
0x7B4C, |
0x7B45, |
0x7B75, |
0x7B65, |
0x7B74, |
0x7B67, |
0x7B70, |
0x7B71, |
0x7B6C, |
0x7B6E, |
0x7B9D, |
0x7B98, |
0x7B9F, |
0x7B8D, |
0x7B9C, |
0x7B9A, |
0x7B8B, |
0x7B92, |
0x7B8F, |
0x7B5D, |
0x7B99, |
0x7BCB, |
0x7BC1, |
0x7BCC, |
0x7BCF, |
0x7BB4, |
0x7BC6, |
0x7BDD, |
0x7BE9, |
0x7C11, |
0x7C14, |
0x7BE6, |
0x7BE5, |
0x7C60, |
0x7C00, |
0x7C07, |
0x7C13, |
0x7BF3, |
0x7BF7, |
0x7C17, |
0x7C0D, |
0x7BF6, |
0x7C23, |
0x7C27, |
0x7C2A, |
0x7C1F, |
0x7C37, |
0x7C2B, |
0x7C3D, |
0x7C4C, |
0x7C43, |
0x7C54, |
0x7C4F, |
0x7C40, |
0x7C50, |
0x7C58, |
0x7C5F, |
0x7C64, |
0x7C56, |
0x7C65, |
0x7C6C, |
0x7C75, |
0x7C83, |
0x7C90, |
0x7CA4, |
0x7CAD, |
0x7CA2, |
0x7CAB, |
0x7CA1, |
0x7CA8, |
0x7CB3, |
0x7CB2, |
0x7CB1, |
0x7CAE, |
0x7CB9, |
0x7CBD, |
0x7CC0, |
0x7CC5, |
0x7CC2, |
0x7CD8, |
0x7CD2, |
0x7CDC, |
0x7CE2, |
0x9B3B, |
0x7CEF, |
0x7CF2, |
0x7CF4, |
0x7CF6, |
0x7CFA, |
0x7D06, |
0x7D02, |
0x7D1C, |
0x7D15, |
0x7D0A, |
0x7D45, |
0x7D4B, |
0x7D2E, |
0x7D32, |
0x7D3F, |
0x7D35, |
0x7D46, |
0x7D73, |
0x7D56, |
0x7D4E, |
0x7D72, |
0x7D68, |
0x7D6E, |
0x7D4F, |
0x7D63, |
0x7D93, |
0x7D89, |
0x7D5B, |
0x7D8F, |
0x7D7D, |
0x7D9B, |
0x7DBA, |
0x7DAE, |
0x7DA3, |
0x7DB5, |
0x7DC7, |
0x7DBD, |
0x7DAB, |
0x7E3D, |
0x7DA2, |
0x7DAF, |
0x7DDC, |
0x7DB8, |
0x7D9F, |
0x7DB0, |
0x7DD8, |
0x7DDD, |
0x7DE4, |
0x7DDE, |
0x7DFB, |
0x7DF2, |
0x7DE1, |
0x7E05, |
0x7E0A, |
0x7E23, |
0x7E21, |
0x7E12, |
0x7E31, |
0x7E1F, |
0x7E09, |
0x7E0B, |
0x7E22, |
0x7E46, |
0x7E66, |
0x7E3B, |
0x7E35, |
0x7E39, |
0x7E43, |
0x7E37, |
0x7E32, |
0x7E3A, |
0x7E67, |
0x7E5D, |
0x7E56, |
0x7E5E, |
0x7E59, |
0x7E5A, |
0x7E79, |
0x7E6A, |
0x7E69, |
0x7E7C, |
0x7E7B, |
0x7E83, |
0x7DD5, |
0x7E7D, |
0x8FAE, |
0x7E7F, |
0x7E88, |
0x7E89, |
0x7E8C, |
0x7E92, |
0x7E90, |
0x7E93, |
0x7E94, |
0x7E96, |
0x7E8E, |
0x7E9B, |
0x7E9C, |
0x7F38, |
0x7F3A, |
0x7F45, |
0x7F4C, |
0x7F4D, |
0x7F4E, |
0x7F50, |
0x7F51, |
0x7F55, |
0x7F54, |
0x7F58, |
0x7F5F, |
0x7F60, |
0x7F68, |
0x7F69, |
0x7F67, |
0x7F78, |
0x7F82, |
0x7F86, |
0x7F83, |
0x7F88, |
0x7F87, |
0x7F8C, |
0x7F94, |
0x7F9E, |
0x7F9D, |
0x7F9A, |
0x7FA3, |
0x7FAF, |
0x7FB2, |
0x7FB9, |
0x7FAE, |
0x7FB6, |
0x7FB8, |
0x8B71, |
0x7FC5, |
0x7FC6, |
0x7FCA, |
0x7FD5, |
0x7FD4, |
0x7FE1, |
0x7FE6, |
0x7FE9, |
0x7FF3, |
0x7FF9, |
0x98DC, |
0x8006, |
0x8004, |
0x800B, |
0x8012, |
0x8018, |
0x8019, |
0x801C, |
0x8021, |
0x8028, |
0x803F, |
0x803B, |
0x804A, |
0x8046, |
0x8052, |
0x8058, |
0x805A, |
0x805F, |
0x8062, |
0x8068, |
0x8073, |
0x8072, |
0x8070, |
0x8076, |
0x8079, |
0x807D, |
0x807F, |
0x8084, |
0x8086, |
0x8085, |
0x809B, |
0x8093, |
0x809A, |
0x80AD, |
0x5190, |
0x80AC, |
0x80DB, |
0x80E5, |
0x80D9, |
0x80DD, |
0x80C4, |
0x80DA, |
0x80D6, |
0x8109, |
0x80EF, |
0x80F1, |
0x811B, |
0x8129, |
0x8123, |
0x812F, |
0x814B, |
0x968B, |
0x8146, |
0x813E, |
0x8153, |
0x8151, |
0x80FC, |
0x8171, |
0x816E, |
0x8165, |
0x8166, |
0x8174, |
0x8183, |
0x8188, |
0x818A, |
0x8180, |
0x8182, |
0x81A0, |
0x8195, |
0x81A4, |
0x81A3, |
0x815F, |
0x8193, |
0x81A9, |
0x81B0, |
0x81B5, |
0x81BE, |
0x81B8, |
0x81BD, |
0x81C0, |
0x81C2, |
0x81BA, |
0x81C9, |
0x81CD, |
0x81D1, |
0x81D9, |
0x81D8, |
0x81C8, |
0x81DA, |
0x81DF, |
0x81E0, |
0x81E7, |
0x81FA, |
0x81FB, |
0x81FE, |
0x8201, |
0x8202, |
0x8205, |
0x8207, |
0x820A, |
0x820D, |
0x8210, |
0x8216, |
0x8229, |
0x822B, |
0x8238, |
0x8233, |
0x8240, |
0x8259, |
0x8258, |
0x825D, |
0x825A, |
0x825F, |
0x8264, |
0x8262, |
0x8268, |
0x826A, |
0x826B, |
0x822E, |
0x8271, |
0x8277, |
0x8278, |
0x827E, |
0x828D, |
0x8292, |
0x82AB, |
0x829F, |
0x82BB, |
0x82AC, |
0x82E1, |
0x82E3, |
0x82DF, |
0x82D2, |
0x82F4, |
0x82F3, |
0x82FA, |
0x8393, |
0x8303, |
0x82FB, |
0x82F9, |
0x82DE, |
0x8306, |
0x82DC, |
0x8309, |
0x82D9, |
0x8335, |
0x8334, |
0x8316, |
0x8332, |
0x8331, |
0x8340, |
0x8339, |
0x8350, |
0x8345, |
0x832F, |
0x832B, |
0x8317, |
0x8318, |
0x8385, |
0x839A, |
0x83AA, |
0x839F, |
0x83A2, |
0x8396, |
0x8323, |
0x838E, |
0x8387, |
0x838A, |
0x837C, |
0x83B5, |
0x8373, |
0x8375, |
0x83A0, |
0x8389, |
0x83A8, |
0x83F4, |
0x8413, |
0x83EB, |
0x83CE, |
0x83FD, |
0x8403, |
0x83D8, |
0x840B, |
0x83C1, |
0x83F7, |
0x8407, |
0x83E0, |
0x83F2, |
0x840D, |
0x8422, |
0x8420, |
0x83BD, |
0x8438, |
0x8506, |
0x83FB, |
0x846D, |
0x842A, |
0x843C, |
0x855A, |
0x8484, |
0x8477, |
0x846B, |
0x84AD, |
0x846E, |
0x8482, |
0x8469, |
0x8446, |
0x842C, |
0x846F, |
0x8479, |
0x8435, |
0x84CA, |
0x8462, |
0x84B9, |
0x84BF, |
0x849F, |
0x84D9, |
0x84CD, |
0x84BB, |
0x84DA, |
0x84D0, |
0x84C1, |
0x84C6, |
0x84D6, |
0x84A1, |
0x8521, |
0x84FF, |
0x84F4, |
0x8517, |
0x8518, |
0x852C, |
0x851F, |
0x8515, |
0x8514, |
0x84FC, |
0x8540, |
0x8563, |
0x8558, |
0x8548, |
0x8541, |
0x8602, |
0x854B, |
0x8555, |
0x8580, |
0x85A4, |
0x8588, |
0x8591, |
0x858A, |
0x85A8, |
0x856D, |
0x8594, |
0x859B, |
0x85EA, |
0x8587, |
0x859C, |
0x8577, |
0x857E, |
0x8590, |
0x85C9, |
0x85BA, |
0x85CF, |
0x85B9, |
0x85D0, |
0x85D5, |
0x85DD, |
0x85E5, |
0x85DC, |
0x85F9, |
0x860A, |
0x8613, |
0x860B, |
0x85FE, |
0x85FA, |
0x8606, |
0x8622, |
0x861A, |
0x8630, |
0x863F, |
0x864D, |
0x4E55, |
0x8654, |
0x865F, |
0x8667, |
0x8671, |
0x8693, |
0x86A3, |
0x86A9, |
0x86AA, |
0x868B, |
0x868C, |
0x86B6, |
0x86AF, |
0x86C4, |
0x86C6, |
0x86B0, |
0x86C9, |
0x8823, |
0x86AB, |
0x86D4, |
0x86DE, |
0x86E9, |
0x86EC, |
0x86DF, |
0x86DB, |
0x86EF, |
0x8712, |
0x8706, |
0x8708, |
0x8700, |
0x8703, |
0x86FB, |
0x8711, |
0x8709, |
0x870D, |
0x86F9, |
0x870A, |
0x8734, |
0x873F, |
0x8737, |
0x873B, |
0x8725, |
0x8729, |
0x871A, |
0x8760, |
0x875F, |
0x8778, |
0x874C, |
0x874E, |
0x8774, |
0x8757, |
0x8768, |
0x876E, |
0x8759, |
0x8753, |
0x8763, |
0x876A, |
0x8805, |
0x87A2, |
0x879F, |
0x8782, |
0x87AF, |
0x87CB, |
0x87BD, |
0x87C0, |
0x87D0, |
0x96D6, |
0x87AB, |
0x87C4, |
0x87B3, |
0x87C7, |
0x87C6, |
0x87BB, |
0x87EF, |
0x87F2, |
0x87E0, |
0x880F, |
0x880D, |
0x87FE, |
0x87F6, |
0x87F7, |
0x880E, |
0x87D2, |
0x8811, |
0x8816, |
0x8815, |
0x8822, |
0x8821, |
0x8831, |
0x8836, |
0x8839, |
0x8827, |
0x883B, |
0x8844, |
0x8842, |
0x8852, |
0x8859, |
0x885E, |
0x8862, |
0x886B, |
0x8881, |
0x887E, |
0x889E, |
0x8875, |
0x887D, |
0x88B5, |
0x8872, |
0x8882, |
0x8897, |
0x8892, |
0x88AE, |
0x8899, |
0x88A2, |
0x888D, |
0x88A4, |
0x88B0, |
0x88BF, |
0x88B1, |
0x88C3, |
0x88C4, |
0x88D4, |
0x88D8, |
0x88D9, |
0x88DD, |
0x88F9, |
0x8902, |
0x88FC, |
0x88F4, |
0x88E8, |
0x88F2, |
0x8904, |
0x890C, |
0x890A, |
0x8913, |
0x8943, |
0x891E, |
0x8925, |
0x892A, |
0x892B, |
0x8941, |
0x8944, |
0x893B, |
0x8936, |
0x8938, |
0x894C, |
0x891D, |
0x8960, |
0x895E, |
0x8966, |
0x8964, |
0x896D, |
0x896A, |
0x896F, |
0x8974, |
0x8977, |
0x897E, |
0x8983, |
0x8988, |
0x898A, |
0x8993, |
0x8998, |
0x89A1, |
0x89A9, |
0x89A6, |
0x89AC, |
0x89AF, |
0x89B2, |
0x89BA, |
0x89BD, |
0x89BF, |
0x89C0, |
0x89DA, |
0x89DC, |
0x89DD, |
0x89E7, |
0x89F4, |
0x89F8, |
0x8A03, |
0x8A16, |
0x8A10, |
0x8A0C, |
0x8A1B, |
0x8A1D, |
0x8A25, |
0x8A36, |
0x8A41, |
0x8A5B, |
0x8A52, |
0x8A46, |
0x8A48, |
0x8A7C, |
0x8A6D, |
0x8A6C, |
0x8A62, |
0x8A85, |
0x8A82, |
0x8A84, |
0x8AA8, |
0x8AA1, |
0x8A91, |
0x8AA5, |
0x8AA6, |
0x8A9A, |
0x8AA3, |
0x8AC4, |
0x8ACD, |
0x8AC2, |
0x8ADA, |
0x8AEB, |
0x8AF3, |
0x8AE7, |
0x8AE4, |
0x8AF1, |
0x8B14, |
0x8AE0, |
0x8AE2, |
0x8AF7, |
0x8ADE, |
0x8ADB, |
0x8B0C, |
0x8B07, |
0x8B1A, |
0x8AE1, |
0x8B16, |
0x8B10, |
0x8B17, |
0x8B20, |
0x8B33, |
0x97AB, |
0x8B26, |
0x8B2B, |
0x8B3E, |
0x8B28, |
0x8B41, |
0x8B4C, |
0x8B4F, |
0x8B4E, |
0x8B49, |
0x8B56, |
0x8B5B, |
0x8B5A, |
0x8B6B, |
0x8B5F, |
0x8B6C, |
0x8B6F, |
0x8B74, |
0x8B7D, |
0x8B80, |
0x8B8C, |
0x8B8E, |
0x8B92, |
0x8B93, |
0x8B96, |
0x8B99, |
0x8B9A, |
0x8C3A, |
0x8C41, |
0x8C3F, |
0x8C48, |
0x8C4C, |
0x8C4E, |
0x8C50, |
0x8C55, |
0x8C62, |
0x8C6C, |
0x8C78, |
0x8C7A, |
0x8C82, |
0x8C89, |
0x8C85, |
0x8C8A, |
0x8C8D, |
0x8C8E, |
0x8C94, |
0x8C7C, |
0x8C98, |
0x621D, |
0x8CAD, |
0x8CAA, |
0x8CBD, |
0x8CB2, |
0x8CB3, |
0x8CAE, |
0x8CB6, |
0x8CC8, |
0x8CC1, |
0x8CE4, |
0x8CE3, |
0x8CDA, |
0x8CFD, |
0x8CFA, |
0x8CFB, |
0x8D04, |
0x8D05, |
0x8D0A, |
0x8D07, |
0x8D0F, |
0x8D0D, |
0x8D10, |
0x9F4E, |
0x8D13, |
0x8CCD, |
0x8D14, |
0x8D16, |
0x8D67, |
0x8D6D, |
0x8D71, |
0x8D73, |
0x8D81, |
0x8D99, |
0x8DC2, |
0x8DBE, |
0x8DBA, |
0x8DCF, |
0x8DDA, |
0x8DD6, |
0x8DCC, |
0x8DDB, |
0x8DCB, |
0x8DEA, |
0x8DEB, |
0x8DDF, |
0x8DE3, |
0x8DFC, |
0x8E08, |
0x8E09, |
0x8DFF, |
0x8E1D, |
0x8E1E, |
0x8E10, |
0x8E1F, |
0x8E42, |
0x8E35, |
0x8E30, |
0x8E34, |
0x8E4A, |
0x8E47, |
0x8E49, |
0x8E4C, |
0x8E50, |
0x8E48, |
0x8E59, |
0x8E64, |
0x8E60, |
0x8E2A, |
0x8E63, |
0x8E55, |
0x8E76, |
0x8E72, |
0x8E7C, |
0x8E81, |
0x8E87, |
0x8E85, |
0x8E84, |
0x8E8B, |
0x8E8A, |
0x8E93, |
0x8E91, |
0x8E94, |
0x8E99, |
0x8EAA, |
0x8EA1, |
0x8EAC, |
0x8EB0, |
0x8EC6, |
0x8EB1, |
0x8EBE, |
0x8EC5, |
0x8EC8, |
0x8ECB, |
0x8EDB, |
0x8EE3, |
0x8EFC, |
0x8EFB, |
0x8EEB, |
0x8EFE, |
0x8F0A, |
0x8F05, |
0x8F15, |
0x8F12, |
0x8F19, |
0x8F13, |
0x8F1C, |
0x8F1F, |
0x8F1B, |
0x8F0C, |
0x8F26, |
0x8F33, |
0x8F3B, |
0x8F39, |
0x8F45, |
0x8F42, |
0x8F3E, |
0x8F4C, |
0x8F49, |
0x8F46, |
0x8F4E, |
0x8F57, |
0x8F5C, |
0x8F62, |
0x8F63, |
0x8F64, |
0x8F9C, |
0x8F9F, |
0x8FA3, |
0x8FAD, |
0x8FAF, |
0x8FB7, |
0x8FDA, |
0x8FE5, |
0x8FE2, |
0x8FEA, |
0x8FEF, |
0x9087, |
0x8FF4, |
0x9005, |
0x8FF9, |
0x8FFA, |
0x9011, |
0x9015, |
0x9021, |
0x900D, |
0x901E, |
0x9016, |
0x900B, |
0x9027, |
0x9036, |
0x9035, |
0x9039, |
0x8FF8, |
0x904F, |
0x9050, |
0x9051, |
0x9052, |
0x900E, |
0x9049, |
0x903E, |
0x9056, |
0x9058, |
0x905E, |
0x9068, |
0x906F, |
0x9076, |
0x96A8, |
0x9072, |
0x9082, |
0x907D, |
0x9081, |
0x9080, |
0x908A, |
0x9089, |
0x908F, |
0x90A8, |
0x90AF, |
0x90B1, |
0x90B5, |
0x90E2, |
0x90E4, |
0x6248, |
0x90DB, |
0x9102, |
0x9112, |
0x9119, |
0x9132, |
0x9130, |
0x914A, |
0x9156, |
0x9158, |
0x9163, |
0x9165, |
0x9169, |
0x9173, |
0x9172, |
0x918B, |
0x9189, |
0x9182, |
0x91A2, |
0x91AB, |
0x91AF, |
0x91AA, |
0x91B5, |
0x91B4, |
0x91BA, |
0x91C0, |
0x91C1, |
0x91C9, |
0x91CB, |
0x91D0, |
0x91D6, |
0x91DF, |
0x91E1, |
0x91DB, |
0x91FC, |
0x91F5, |
0x91F6, |
0x921E, |
0x91FF, |
0x9214, |
0x922C, |
0x9215, |
0x9211, |
0x925E, |
0x9257, |
0x9245, |
0x9249, |
0x9264, |
0x9248, |
0x9295, |
0x923F, |
0x924B, |
0x9250, |
0x929C, |
0x9296, |
0x9293, |
0x929B, |
0x925A, |
0x92CF, |
0x92B9, |
0x92B7, |
0x92E9, |
0x930F, |
0x92FA, |
0x9344, |
0x932E, |
0x9319, |
0x9322, |
0x931A, |
0x9323, |
0x933A, |
0x9335, |
0x933B, |
0x935C, |
0x9360, |
0x937C, |
0x936E, |
0x9356, |
0x93B0, |
0x93AC, |
0x93AD, |
0x9394, |
0x93B9, |
0x93D6, |
0x93D7, |
0x93E8, |
0x93E5, |
0x93D8, |
0x93C3, |
0x93DD, |
0x93D0, |
0x93C8, |
0x93E4, |
0x941A, |
0x9414, |
0x9413, |
0x9403, |
0x9407, |
0x9410, |
0x9436, |
0x942B, |
0x9435, |
0x9421, |
0x943A, |
0x9441, |
0x9452, |
0x9444, |
0x945B, |
0x9460, |
0x9462, |
0x945E, |
0x946A, |
0x9229, |
0x9470, |
0x9475, |
0x9477, |
0x947D, |
0x945A, |
0x947C, |
0x947E, |
0x9481, |
0x947F, |
0x9582, |
0x9587, |
0x958A, |
0x9594, |
0x9596, |
0x9598, |
0x9599, |
0x95A0, |
0x95A8, |
0x95A7, |
0x95AD, |
0x95BC, |
0x95BB, |
0x95B9, |
0x95BE, |
0x95CA, |
0x6FF6, |
0x95C3, |
0x95CD, |
0x95CC, |
0x95D5, |
0x95D4, |
0x95D6, |
0x95DC, |
0x95E1, |
0x95E5, |
0x95E2, |
0x9621, |
0x9628, |
0x962E, |
0x962F, |
0x9642, |
0x964C, |
0x964F, |
0x964B, |
0x9677, |
0x965C, |
0x965E, |
0x965D, |
0x965F, |
0x9666, |
0x9672, |
0x966C, |
0x968D, |
0x9698, |
0x9695, |
0x9697, |
0x96AA, |
0x96A7, |
0x96B1, |
0x96B2, |
0x96B0, |
0x96B4, |
0x96B6, |
0x96B8, |
0x96B9, |
0x96CE, |
0x96CB, |
0x96C9, |
0x96CD, |
0x894D, |
0x96DC, |
0x970D, |
0x96D5, |
0x96F9, |
0x9704, |
0x9706, |
0x9708, |
0x9713, |
0x970E, |
0x9711, |
0x970F, |
0x9716, |
0x9719, |
0x9724, |
0x972A, |
0x9730, |
0x9739, |
0x973D, |
0x973E, |
0x9744, |
0x9746, |
0x9748, |
0x9742, |
0x9749, |
0x975C, |
0x9760, |
0x9764, |
0x9766, |
0x9768, |
0x52D2, |
0x976B, |
0x9771, |
0x9779, |
0x9785, |
0x977C, |
0x9781, |
0x977A, |
0x9786, |
0x978B, |
0x978F, |
0x9790, |
0x979C, |
0x97A8, |
0x97A6, |
0x97A3, |
0x97B3, |
0x97B4, |
0x97C3, |
0x97C6, |
0x97C8, |
0x97CB, |
0x97DC, |
0x97ED, |
0x9F4F, |
0x97F2, |
0x7ADF, |
0x97F6, |
0x97F5, |
0x980F, |
0x980C, |
0x9838, |
0x9824, |
0x9821, |
0x9837, |
0x983D, |
0x9846, |
0x984F, |
0x984B, |
0x986B, |
0x986F, |
0x9870, |
0x9871, |
0x9874, |
0x9873, |
0x98AA, |
0x98AF, |
0x98B1, |
0x98B6, |
0x98C4, |
0x98C3, |
0x98C6, |
0x98E9, |
0x98EB, |
0x9903, |
0x9909, |
0x9912, |
0x9914, |
0x9918, |
0x9921, |
0x991D, |
0x991E, |
0x9924, |
0x9920, |
0x992C, |
0x992E, |
0x993D, |
0x993E, |
0x9942, |
0x9949, |
0x9945, |
0x9950, |
0x994B, |
0x9951, |
0x9952, |
0x994C, |
0x9955, |
0x9997, |
0x9998, |
0x99A5, |
0x99AD, |
0x99AE, |
0x99BC, |
0x99DF, |
0x99DB, |
0x99DD, |
0x99D8, |
0x99D1, |
0x99ED, |
0x99EE, |
0x99F1, |
0x99F2, |
0x99FB, |
0x99F8, |
0x9A01, |
0x9A0F, |
0x9A05, |
0x99E2, |
0x9A19, |
0x9A2B, |
0x9A37, |
0x9A45, |
0x9A42, |
0x9A40, |
0x9A43, |
0x9A3E, |
0x9A55, |
0x9A4D, |
0x9A5B, |
0x9A57, |
0x9A5F, |
0x9A62, |
0x9A65, |
0x9A64, |
0x9A69, |
0x9A6B, |
0x9A6A, |
0x9AAD, |
0x9AB0, |
0x9ABC, |
0x9AC0, |
0x9ACF, |
0x9AD1, |
0x9AD3, |
0x9AD4, |
0x9ADE, |
0x9ADF, |
0x9AE2, |
0x9AE3, |
0x9AE6, |
0x9AEF, |
0x9AEB, |
0x9AEE, |
0x9AF4, |
0x9AF1, |
0x9AF7, |
0x9AFB, |
0x9B06, |
0x9B18, |
0x9B1A, |
0x9B1F, |
0x9B22, |
0x9B23, |
0x9B25, |
0x9B27, |
0x9B28, |
0x9B29, |
0x9B2A, |
0x9B2E, |
0x9B2F, |
0x9B32, |
0x9B44, |
0x9B43, |
0x9B4F, |
0x9B4D, |
0x9B4E, |
0x9B51, |
0x9B58, |
0x9B74, |
0x9B93, |
0x9B83, |
0x9B91, |
0x9B96, |
0x9B97, |
0x9B9F, |
0x9BA0, |
0x9BA8, |
0x9BB4, |
0x9BC0, |
0x9BCA, |
0x9BB9, |
0x9BC6, |
0x9BCF, |
0x9BD1, |
0x9BD2, |
0x9BE3, |
0x9BE2, |
0x9BE4, |
0x9BD4, |
0x9BE1, |
0x9C3A, |
0x9BF2, |
0x9BF1, |
0x9BF0, |
0x9C15, |
0x9C14, |
0x9C09, |
0x9C13, |
0x9C0C, |
0x9C06, |
0x9C08, |
0x9C12, |
0x9C0A, |
0x9C04, |
0x9C2E, |
0x9C1B, |
0x9C25, |
0x9C24, |
0x9C21, |
0x9C30, |
0x9C47, |
0x9C32, |
0x9C46, |
0x9C3E, |
0x9C5A, |
0x9C60, |
0x9C67, |
0x9C76, |
0x9C78, |
0x9CE7, |
0x9CEC, |
0x9CF0, |
0x9D09, |
0x9D08, |
0x9CEB, |
0x9D03, |
0x9D06, |
0x9D2A, |
0x9D26, |
0x9DAF, |
0x9D23, |
0x9D1F, |
0x9D44, |
0x9D15, |
0x9D12, |
0x9D41, |
0x9D3F, |
0x9D3E, |
0x9D46, |
0x9D48, |
0x9D5D, |
0x9D5E, |
0x9D64, |
0x9D51, |
0x9D50, |
0x9D59, |
0x9D72, |
0x9D89, |
0x9D87, |
0x9DAB, |
0x9D6F, |
0x9D7A, |
0x9D9A, |
0x9DA4, |
0x9DA9, |
0x9DB2, |
0x9DC4, |
0x9DC1, |
0x9DBB, |
0x9DB8, |
0x9DBA, |
0x9DC6, |
0x9DCF, |
0x9DC2, |
0x9DD9, |
0x9DD3, |
0x9DF8, |
0x9DE6, |
0x9DED, |
0x9DEF, |
0x9DFD, |
0x9E1A, |
0x9E1B, |
0x9E1E, |
0x9E75, |
0x9E79, |
0x9E7D, |
0x9E81, |
0x9E88, |
0x9E8B, |
0x9E8C, |
0x9E92, |
0x9E95, |
0x9E91, |
0x9E9D, |
0x9EA5, |
0x9EA9, |
0x9EB8, |
0x9EAA, |
0x9EAD, |
0x9761, |
0x9ECC, |
0x9ECE, |
0x9ECF, |
0x9ED0, |
0x9ED4, |
0x9EDC, |
0x9EDE, |
0x9EDD, |
0x9EE0, |
0x9EE5, |
0x9EE8, |
0x9EEF, |
0x9EF4, |
0x9EF6, |
0x9EF7, |
0x9EF9, |
0x9EFB, |
0x9EFC, |
0x9EFD, |
0x9F07, |
0x9F08, |
0x76B7, |
0x9F15, |
0x9F21, |
0x9F2C, |
0x9F3E, |
0x9F4A, |
0x9F52, |
0x9F54, |
0x9F63, |
0x9F5F, |
0x9F60, |
0x9F61, |
0x9F66, |
0x9F67, |
0x9F6C, |
0x9F6A, |
0x9F77, |
0x9F72, |
0x9F76, |
0x9F95, |
0x9F9C, |
0x9FA0, |
0x582F, |
0x69C7, |
0x9059, |
0x7464, |
0x51DC, |
0x7199 |
}; |
/* f5 to fe is non-existent */ |
/contrib/sdk/sources/libc/ctype/local.h |
---|
0,0 → 1,32 |
/* wctrans constants */ |
#include <_ansi.h> |
/* valid values for wctrans_t */ |
#define WCT_TOLOWER 1 |
#define WCT_TOUPPER 2 |
/* valid values for wctype_t */ |
#define WC_ALNUM 1 |
#define WC_ALPHA 2 |
#define WC_BLANK 3 |
#define WC_CNTRL 4 |
#define WC_DIGIT 5 |
#define WC_GRAPH 6 |
#define WC_LOWER 7 |
#define WC_PRINT 8 |
#define WC_PUNCT 9 |
#define WC_SPACE 10 |
#define WC_UPPER 11 |
#define WC_XDIGIT 12 |
extern char *__locale_charset(_NOARGS); |
/* internal function to translate JP to Unicode */ |
#ifdef __CYGWIN__ |
/* Under Cygwin, the incoming wide character is already given in UTF due |
to the requirements of the underlying OS. */ |
#define _jp2uc(c) (c) |
#else |
wint_t _EXFUN (_jp2uc, (wint_t)); |
#endif |
/contrib/sdk/sources/libc/ctype/toascii.c |
---|
0,0 → 1,41 |
/* |
FUNCTION |
<<toascii>>---force integers to ASCII range |
INDEX |
toascii |
ANSI_SYNOPSIS |
#include <ctype.h> |
int toascii(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int toascii(<[c]>); |
int (<[c]>); |
DESCRIPTION |
<<toascii>> is a macro which coerces integers to the ASCII range (0--127) by zeroing any higher-order bits. |
You can use a compiled subroutine instead of the macro definition by |
undefining this macro using `<<#undef toascii>>'. |
RETURNS |
<<toascii>> returns integers between 0 and 127. |
PORTABILITY |
<<toascii>> is not ANSI C. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#undef toascii |
int |
_DEFUN(toascii,(c),int c) |
{ |
return (c)&0177; |
} |
/contrib/sdk/sources/libc/ctype/tolower.c |
---|
0,0 → 1,76 |
/* |
FUNCTION |
<<tolower>>---translate characters to lowercase |
INDEX |
tolower |
INDEX |
_tolower |
ANSI_SYNOPSIS |
#include <ctype.h> |
int tolower(int <[c]>); |
int _tolower(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int tolower(<[c]>); |
int _tolower(<[c]>); |
DESCRIPTION |
<<tolower>> is a macro which converts uppercase characters to lowercase, |
leaving all other characters unchanged. It is only defined when |
<[c]> is an integer in the range <<EOF>> to <<255>>. |
You can use a compiled subroutine instead of the macro definition by |
undefining this macro using `<<#undef tolower>>'. |
<<_tolower>> performs the same conversion as <<tolower>>, but should |
only be used when <[c]> is known to be an uppercase character (<<A>>--<<Z>>). |
RETURNS |
<<tolower>> returns the lowercase equivalent of <[c]> when it is a |
character between <<A>> and <<Z>>, and <[c]> otherwise. |
<<_tolower>> returns the lowercase equivalent of <[c]> when it is a |
character between <<A>> and <<Z>>. If <[c]> is not one of these |
characters, the behaviour of <<_tolower>> is undefined. |
PORTABILITY |
<<tolower>> is ANSI C. <<_tolower>> is not recommended for portable |
programs. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
#include <limits.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <wctype.h> |
#include <wchar.h> |
#endif |
#undef tolower |
int |
_DEFUN(tolower,(c),int c) |
{ |
#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
if ((unsigned char) c <= 0x7f) |
return isupper (c) ? c - 'A' + 'a' : c; |
else if (c != EOF && MB_CUR_MAX == 1 && isupper (c)) |
{ |
char s[MB_LEN_MAX] = { c, '\0' }; |
wchar_t wc; |
if (mbtowc (&wc, s, 1) >= 0 |
&& wctomb (s, (wchar_t) towlower ((wint_t) wc)) == 1) |
c = (unsigned char) s[0]; |
} |
return c; |
#else |
return isupper(c) ? (c) - 'A' + 'a' : c; |
#endif |
} |
/contrib/sdk/sources/libc/ctype/toupper.c |
---|
0,0 → 1,75 |
/* |
FUNCTION |
<<toupper>>---translate characters to uppercase |
INDEX |
toupper |
INDEX |
_toupper |
ANSI_SYNOPSIS |
#include <ctype.h> |
int toupper(int <[c]>); |
int _toupper(int <[c]>); |
TRAD_SYNOPSIS |
#include <ctype.h> |
int toupper(<[c]>); |
int _toupper(<[c]>); |
DESCRIPTION |
<<toupper>> is a macro which converts lowercase characters to uppercase, |
leaving all other characters unchanged. It is only defined when |
<[c]> is an integer in the range <<EOF>> to <<255>>. |
You can use a compiled subroutine instead of the macro definition by |
undefining this macro using `<<#undef toupper>>'. |
<<_toupper>> performs the same conversion as <<toupper>>, but should |
only be used when <[c]> is known to be a lowercase character (<<a>>--<<z>>). |
RETURNS |
<<toupper>> returns the uppercase equivalent of <[c]> when it is a |
character between <<a>> and <<z>>, and <[c]> otherwise. |
<<_toupper>> returns the uppercase equivalent of <[c]> when it is a |
character between <<a>> and <<z>>. If <[c]> is not one of these |
characters, the behaviour of <<_toupper>> is undefined. |
PORTABILITY |
<<toupper>> is ANSI C. <<_toupper>> is not recommended for portable programs. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <ctype.h> |
#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
#include <limits.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <wctype.h> |
#include <wchar.h> |
#endif |
#undef toupper |
int |
_DEFUN(toupper,(c),int c) |
{ |
#if defined (_MB_EXTENDED_CHARSETS_ISO) || defined (_MB_EXTENDED_CHARSETS_WINDOWS) |
if ((unsigned char) c <= 0x7f) |
return islower (c) ? c - 'a' + 'A' : c; |
else if (c != EOF && MB_CUR_MAX == 1 && islower (c)) |
{ |
char s[MB_LEN_MAX] = { c, '\0' }; |
wchar_t wc; |
if (mbtowc (&wc, s, 1) >= 0 |
&& wctomb (s, (wchar_t) towupper ((wint_t) wc)) == 1) |
c = (unsigned char) s[0]; |
} |
return c; |
#else |
return islower (c) ? c - 'a' + 'A' : c; |
#endif |
} |
/contrib/sdk/sources/libc/ctype/towctrans.c |
---|
0,0 → 1,97 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<towctrans>>---extensible wide-character translation |
INDEX |
towctrans |
ANSI_SYNOPSIS |
#include <wctype.h> |
wint_t towctrans(wint_t <[c]>, wctrans_t <[w]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
wint_t towctrans(<[c]>, <[w]>) |
wint_t <[c]>; |
wctrans_t <[w]>; |
DESCRIPTION |
<<towctrans>> is a function which converts wide characters based on |
a specified translation type <[w]>. If the translation type is |
invalid or cannot be applied to the current character, no change |
to the character is made. |
RETURNS |
<<towctrans>> returns the translated equivalent of <[c]> when it is a |
valid for the given translation, otherwise, it returns the input character. |
When the translation type is invalid, <<errno>> is set <<EINVAL>>. |
PORTABILITY |
<<towctrans>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <string.h> |
#include <reent.h> |
#include <wctype.h> |
#include <errno.h> |
#include "local.h" |
wint_t |
_DEFUN (_towctrans_r, (r, c, w), |
struct _reent *r _AND |
wint_t c _AND |
wctrans_t w) |
{ |
if (w == WCT_TOLOWER) |
return towlower (c); |
else if (w == WCT_TOUPPER) |
return towupper (c); |
else |
{ |
r->_errno = EINVAL; |
return c; |
} |
} |
#ifndef _REENT_ONLY |
wint_t |
_DEFUN (towctrans, (c, w), |
wint_t c _AND |
wctrans_t w) |
{ |
return _towctrans_r (_REENT, c, w); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/ctype/towlower.c |
---|
0,0 → 1,569 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<towlower>>---translate wide characters to lowercase |
INDEX |
towlower |
ANSI_SYNOPSIS |
#include <wctype.h> |
wint_t towlower(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
wint_t towlower(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<towlower>> is a function which converts uppercase wide characters to |
lowercase, leaving all other characters unchanged. |
RETURNS |
<<towlower>> returns the lowercase equivalent of <[c]> when it is a |
uppercase wide character; otherwise, it returns the input character. |
PORTABILITY |
<<towlower>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <string.h> |
#include <reent.h> |
#include <ctype.h> |
#include <wctype.h> |
#include "local.h" |
wint_t |
_DEFUN(towlower,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
c = _jp2uc (c); |
/* Based on and tested against Unicode 5.2 */ |
/* Expression used to filter out the characters for the below code: |
awk -F\; '{ if ( $14 != "" ) print $1; }' UnicodeData.txt |
*/ |
if (c < 0x100) |
{ |
if ((c >= 0x0041 && c <= 0x005a) || |
(c >= 0x00c0 && c <= 0x00d6) || |
(c >= 0x00d8 && c <= 0x00de)) |
return (c + 0x20); |
return c; |
} |
else if (c < 0x300) |
{ |
if ((c >= 0x0100 && c <= 0x012e) || |
(c >= 0x0132 && c <= 0x0136) || |
(c >= 0x014a && c <= 0x0176) || |
(c >= 0x01de && c <= 0x01ee) || |
(c >= 0x01f8 && c <= 0x021e) || |
(c >= 0x0222 && c <= 0x0232)) |
{ |
if (!(c & 0x01)) |
return (c + 1); |
return c; |
} |
if (c == 0x0130) |
return 0x0069; |
if ((c >= 0x0139 && c <= 0x0147) || |
(c >= 0x01cd && c <= 0x01db)) |
{ |
if (c & 0x01) |
return (c + 1); |
return c; |
} |
if (c >= 0x178 && c <= 0x01f7) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x0178: |
k = 0x00ff; |
break; |
case 0x0179: |
case 0x017b: |
case 0x017d: |
case 0x0182: |
case 0x0184: |
case 0x0187: |
case 0x018b: |
case 0x0191: |
case 0x0198: |
case 0x01a0: |
case 0x01a2: |
case 0x01a4: |
case 0x01a7: |
case 0x01ac: |
case 0x01af: |
case 0x01b3: |
case 0x01b5: |
case 0x01b8: |
case 0x01bc: |
case 0x01c5: |
case 0x01c8: |
case 0x01cb: |
case 0x01cd: |
case 0x01cf: |
case 0x01d1: |
case 0x01d3: |
case 0x01d5: |
case 0x01d7: |
case 0x01d9: |
case 0x01db: |
case 0x01f2: |
case 0x01f4: |
k = c + 1; |
break; |
case 0x0181: |
k = 0x0253; |
break; |
case 0x0186: |
k = 0x0254; |
break; |
case 0x0189: |
k = 0x0256; |
break; |
case 0x018a: |
k = 0x0257; |
break; |
case 0x018e: |
k = 0x01dd; |
break; |
case 0x018f: |
k = 0x0259; |
break; |
case 0x0190: |
k = 0x025b; |
break; |
case 0x0193: |
k = 0x0260; |
break; |
case 0x0194: |
k = 0x0263; |
break; |
case 0x0196: |
k = 0x0269; |
break; |
case 0x0197: |
k = 0x0268; |
break; |
case 0x019c: |
k = 0x026f; |
break; |
case 0x019d: |
k = 0x0272; |
break; |
case 0x019f: |
k = 0x0275; |
break; |
case 0x01a6: |
k = 0x0280; |
break; |
case 0x01a9: |
k = 0x0283; |
break; |
case 0x01ae: |
k = 0x0288; |
break; |
case 0x01b1: |
k = 0x028a; |
break; |
case 0x01b2: |
k = 0x028b; |
break; |
case 0x01b7: |
k = 0x0292; |
break; |
case 0x01c4: |
case 0x01c7: |
case 0x01ca: |
case 0x01f1: |
k = c + 2; |
break; |
case 0x01f6: |
k = 0x0195; |
break; |
case 0x01f7: |
k = 0x01bf; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
else if (c == 0x0220) |
return 0x019e; |
else if (c >= 0x023a && c <= 0x024e) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x023a: |
k = 0x2c65; |
break; |
case 0x023b: |
case 0x0241: |
case 0x0246: |
case 0x0248: |
case 0x024a: |
case 0x024c: |
case 0x024e: |
k = c + 1; |
break; |
case 0x023d: |
k = 0x019a; |
break; |
case 0x023e: |
k = 0x2c66; |
break; |
case 0x0243: |
k = 0x0180; |
break; |
case 0x0244: |
k = 0x0289; |
break; |
case 0x0245: |
k = 0x028c; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
} |
else if (c < 0x0400) |
{ |
if (c == 0x0370 || c == 0x0372 || c == 0x0376) |
return (c + 1); |
if (c >= 0x0391 && c <= 0x03ab && c != 0x03a2) |
return (c + 0x20); |
if (c >= 0x03d8 && c <= 0x03ee && !(c & 0x01)) |
return (c + 1); |
if (c >= 0x0386 && c <= 0x03ff) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x0386: |
k = 0x03ac; |
break; |
case 0x0388: |
k = 0x03ad; |
break; |
case 0x0389: |
k = 0x03ae; |
break; |
case 0x038a: |
k = 0x03af; |
break; |
case 0x038c: |
k = 0x03cc; |
break; |
case 0x038e: |
k = 0x03cd; |
break; |
case 0x038f: |
k = 0x03ce; |
break; |
case 0x03cf: |
k = 0x03d7; |
break; |
case 0x03f4: |
k = 0x03b8; |
break; |
case 0x03f7: |
k = 0x03f8; |
break; |
case 0x03f9: |
k = 0x03f2; |
break; |
case 0x03fa: |
k = 0x03fb; |
break; |
case 0x03fd: |
k = 0x037b; |
break; |
case 0x03fe: |
k = 0x037c; |
break; |
case 0x03ff: |
k = 0x037d; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
} |
else if (c < 0x500) |
{ |
if (c >= 0x0400 && c <= 0x040f) |
return (c + 0x50); |
if (c >= 0x0410 && c <= 0x042f) |
return (c + 0x20); |
if ((c >= 0x0460 && c <= 0x0480) || |
(c >= 0x048a && c <= 0x04be) || |
(c >= 0x04d0 && c <= 0x04fe)) |
{ |
if (!(c & 0x01)) |
return (c + 1); |
return c; |
} |
if (c == 0x04c0) |
return 0x04cf; |
if (c >= 0x04c1 && c <= 0x04cd) |
{ |
if (c & 0x01) |
return (c + 1); |
return c; |
} |
} |
else if (c < 0x1f00) |
{ |
if ((c >= 0x0500 && c <= 0x050e) || |
(c >= 0x0510 && c <= 0x0524) || |
(c >= 0x1e00 && c <= 0x1e94) || |
(c >= 0x1ea0 && c <= 0x1ef8)) |
{ |
if (!(c & 0x01)) |
return (c + 1); |
return c; |
} |
if (c >= 0x0531 && c <= 0x0556) |
return (c + 0x30); |
if (c >= 0x10a0 && c <= 0x10c5) |
return (c + 0x1c60); |
if (c == 0x1e9e) |
return 0x00df; |
if (c >= 0x1efa && c <= 0x1efe && !(c & 0x01)) |
return (c + 1); |
} |
else if (c < 0x2000) |
{ |
if ((c >= 0x1f08 && c <= 0x1f0f) || |
(c >= 0x1f18 && c <= 0x1f1d) || |
(c >= 0x1f28 && c <= 0x1f2f) || |
(c >= 0x1f38 && c <= 0x1f3f) || |
(c >= 0x1f48 && c <= 0x1f4d) || |
(c >= 0x1f68 && c <= 0x1f6f) || |
(c >= 0x1f88 && c <= 0x1f8f) || |
(c >= 0x1f98 && c <= 0x1f9f) || |
(c >= 0x1fa8 && c <= 0x1faf)) |
return (c - 0x08); |
if (c >= 0x1f59 && c <= 0x1f5f) |
{ |
if (c & 0x01) |
return (c - 0x08); |
return c; |
} |
if (c >= 0x1fb8 && c <= 0x1ffc) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x1fb8: |
case 0x1fb9: |
case 0x1fd8: |
case 0x1fd9: |
case 0x1fe8: |
case 0x1fe9: |
k = c - 0x08; |
break; |
case 0x1fba: |
case 0x1fbb: |
k = c - 0x4a; |
break; |
case 0x1fbc: |
k = 0x1fb3; |
break; |
case 0x1fc8: |
case 0x1fc9: |
case 0x1fca: |
case 0x1fcb: |
k = c - 0x56; |
break; |
case 0x1fcc: |
k = 0x1fc3; |
break; |
case 0x1fda: |
case 0x1fdb: |
k = c - 0x64; |
break; |
case 0x1fea: |
case 0x1feb: |
k = c - 0x70; |
break; |
case 0x1fec: |
k = 0x1fe5; |
break; |
case 0x1ff8: |
case 0x1ff9: |
k = c - 0x80; |
break; |
case 0x1ffa: |
case 0x1ffb: |
k = c - 0x7e; |
break; |
case 0x1ffc: |
k = 0x1ff3; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
} |
else if (c < 0x2c00) |
{ |
if (c >= 0x2160 && c <= 0x216f) |
return (c + 0x10); |
if (c >= 0x24b6 && c <= 0x24cf) |
return (c + 0x1a); |
switch (c) |
{ |
case 0x2126: |
return 0x03c9; |
case 0x212a: |
return 0x006b; |
case 0x212b: |
return 0x00e5; |
case 0x2132: |
return 0x214e; |
case 0x2183: |
return 0x2184; |
} |
} |
else if (c < 0x2d00) |
{ |
if (c >= 0x2c00 && c <= 0x2c2e) |
return (c + 0x30); |
if (c >= 0x2c80 && c <= 0x2ce2 && !(c & 0x01)) |
return (c + 1); |
switch (c) |
{ |
case 0x2c60: |
return 0x2c61; |
case 0x2c62: |
return 0x026b; |
case 0x2c63: |
return 0x1d7d; |
case 0x2c64: |
return 0x027d; |
case 0x2c67: |
case 0x2c69: |
case 0x2c6b: |
case 0x2c72: |
case 0x2c75: |
case 0x2ceb: |
case 0x2ced: |
return c + 1; |
case 0x2c6d: |
return 0x0251; |
case 0x2c6e: |
return 0x0271; |
case 0x2c6f: |
return 0x0250; |
case 0x2c70: |
return 0x0252; |
case 0x2c7e: |
return 0x023f; |
case 0x2c7f: |
return 0x0240; |
} |
} |
else if (c >= 0xa600 && c < 0xa800) |
{ |
if ((c >= 0xa640 && c <= 0xa65e) || |
(c >= 0xa662 && c <= 0xa66c) || |
(c >= 0xa680 && c <= 0xa696) || |
(c >= 0xa722 && c <= 0xa72e) || |
(c >= 0xa732 && c <= 0xa76e) || |
(c >= 0xa77f && c <= 0xa786)) |
{ |
if (!(c & 1)) |
return (c + 1); |
return c; |
} |
switch (c) |
{ |
case 0xa779: |
case 0xa77b: |
case 0xa77e: |
case 0xa78b: |
return (c + 1); |
case 0xa77d: |
return 0x1d79; |
} |
} |
else |
{ |
if (c >= 0xff21 && c <= 0xff3a) |
return (c + 0x20); |
if (c >= 0x10400 && c <= 0x10427) |
return (c + 0x28); |
} |
return c; |
#else |
return (c < 0x00ff ? (wint_t)(tolower ((int)c)) : c); |
#endif /* _MB_CAPABLE */ |
} |
/contrib/sdk/sources/libc/ctype/towupper.c |
---|
0,0 → 1,590 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<towupper>>---translate wide characters to uppercase |
INDEX |
towupper |
ANSI_SYNOPSIS |
#include <wctype.h> |
wint_t towupper(wint_t <[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
wint_t towupper(<[c]>) |
wint_t <[c]>; |
DESCRIPTION |
<<towupper>> is a function which converts lowercase wide characters to |
uppercase, leaving all other characters unchanged. |
RETURNS |
<<towupper>> returns the uppercase equivalent of <[c]> when it is a |
lowercase wide character, otherwise, it returns the input character. |
PORTABILITY |
<<towupper>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <newlib.h> |
#include <string.h> |
#include <reent.h> |
#include <ctype.h> |
#include <wctype.h> |
#include "local.h" |
wint_t |
_DEFUN(towupper,(c), wint_t c) |
{ |
#ifdef _MB_CAPABLE |
c = _jp2uc (c); |
/* Based on and tested against Unicode 5.2 */ |
/* Expression used to filter out the characters for the below code: |
awk -F\; '{ if ( $13 != "" ) print $1; }' UnicodeData.txt |
*/ |
if (c < 0x100) |
{ |
if (c == 0x00b5) |
return 0x039c; |
if ((c >= 0x00e0 && c <= 0x00fe && c != 0x00f7) || |
(c >= 0x0061 && c <= 0x007a)) |
return (c - 0x20); |
if (c == 0xff) |
return 0x0178; |
return c; |
} |
else if (c < 0x300) |
{ |
if ((c >= 0x0101 && c <= 0x012f) || |
(c >= 0x0133 && c <= 0x0137) || |
(c >= 0x014b && c <= 0x0177) || |
(c >= 0x01df && c <= 0x01ef) || |
(c >= 0x01f9 && c <= 0x021f) || |
(c >= 0x0223 && c <= 0x0233) || |
(c >= 0x0247 && c <= 0x024f)) |
{ |
if (c & 0x01) |
return (c - 1); |
return c; |
} |
if ((c >= 0x013a && c <= 0x0148) || |
(c >= 0x01ce && c <= 0x01dc) || |
c == 0x023c || c == 0x0242) |
{ |
if (!(c & 0x01)) |
return (c - 1); |
return c; |
} |
if (c == 0x0131) |
return 0x0049; |
if (c == 0x017a || c == 0x017c || c == 0x017e) |
return (c - 1); |
if (c >= 0x017f && c <= 0x0292) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x017f: |
k = 0x0053; |
break; |
case 0x0180: |
k = 0x0243; |
break; |
case 0x0183: |
k = 0x0182; |
break; |
case 0x0185: |
k = 0x0184; |
break; |
case 0x0188: |
k = 0x0187; |
break; |
case 0x018c: |
k = 0x018b; |
break; |
case 0x0192: |
k = 0x0191; |
break; |
case 0x0195: |
k = 0x01f6; |
break; |
case 0x0199: |
k = 0x0198; |
break; |
case 0x019a: |
k = 0x023d; |
break; |
case 0x019e: |
k = 0x0220; |
break; |
case 0x01a1: |
case 0x01a3: |
case 0x01a5: |
case 0x01a8: |
case 0x01ad: |
case 0x01b0: |
case 0x01b4: |
case 0x01b6: |
case 0x01b9: |
case 0x01bd: |
case 0x01c5: |
case 0x01c8: |
case 0x01cb: |
case 0x01f2: |
case 0x01f5: |
k = c - 1; |
break; |
case 0x01bf: |
k = 0x01f7; |
break; |
case 0x01c6: |
case 0x01c9: |
case 0x01cc: |
k = c - 2; |
break; |
case 0x01dd: |
k = 0x018e; |
break; |
case 0x01f3: |
k = 0x01f1; |
break; |
case 0x023f: |
k = 0x2c7e; |
break; |
case 0x0240: |
k = 0x2c7f; |
break; |
case 0x0250: |
k = 0x2c6f; |
break; |
case 0x0251: |
k = 0x2c6d; |
break; |
case 0x0252: |
k = 0x2c70; |
break; |
case 0x0253: |
k = 0x0181; |
break; |
case 0x0254: |
k = 0x0186; |
break; |
case 0x0256: |
k = 0x0189; |
break; |
case 0x0257: |
k = 0x018a; |
break; |
case 0x0259: |
k = 0x018f; |
break; |
case 0x025b: |
k = 0x0190; |
break; |
case 0x0260: |
k = 0x0193; |
break; |
case 0x0263: |
k = 0x0194; |
break; |
case 0x0268: |
k = 0x0197; |
break; |
case 0x0269: |
k = 0x0196; |
break; |
case 0x026b: |
k = 0x2c62; |
break; |
case 0x026f: |
k = 0x019c; |
break; |
case 0x0271: |
k = 0x2c6e; |
break; |
case 0x0272: |
k = 0x019d; |
break; |
case 0x0275: |
k = 0x019f; |
break; |
case 0x027d: |
k = 0x2c64; |
break; |
case 0x0280: |
k = 0x01a6; |
break; |
case 0x0283: |
k = 0x01a9; |
break; |
case 0x0288: |
k = 0x01ae; |
break; |
case 0x0289: |
k = 0x0244; |
break; |
case 0x028a: |
k = 0x01b1; |
break; |
case 0x028b: |
k = 0x01b2; |
break; |
case 0x028c: |
k = 0x0245; |
break; |
case 0x0292: |
k = 0x01b7; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
} |
else if (c < 0x0400) |
{ |
wint_t k; |
if (c >= 0x03ad && c <= 0x03af) |
return (c - 0x25); |
if (c >= 0x03b1 && c <= 0x03cb && c != 0x03c2) |
return (c - 0x20); |
if (c >= 0x03d9 && c <= 0x03ef && (c & 1)) |
return (c - 1); |
switch (c) |
{ |
case 0x0345: |
k = 0x0399; |
break; |
case 0x0371: |
case 0x0373: |
case 0x0377: |
case 0x03f8: |
case 0x03fb: |
k = c - 1; |
break; |
case 0x037b: |
case 0x037c: |
case 0x037d: |
k = c + 0x82; |
break; |
case 0x03ac: |
k = 0x0386; |
break; |
case 0x03c2: |
k = 0x03a3; |
break; |
case 0x03cc: |
k = 0x038c; |
break; |
case 0x03cd: |
case 0x03ce: |
k = c - 0x3f; |
break; |
case 0x03d0: |
k = 0x0392; |
break; |
case 0x03d1: |
k = 0x0398; |
break; |
case 0x03d5: |
k = 0x03a6; |
break; |
case 0x03d6: |
k = 0x03a0; |
break; |
case 0x03d7: |
k = 0x03cf; |
break; |
case 0x03f0: |
k = 0x039a; |
break; |
case 0x03f1: |
k = 0x03a1; |
break; |
case 0x03f2: |
k = 0x03f9; |
break; |
case 0x03f5: |
k = 0x0395; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
else if (c < 0x500) |
{ |
if (c >= 0x0430 && c <= 0x044f) |
return (c - 0x20); |
if (c >= 0x0450 && c <= 0x045f) |
return (c - 0x50); |
if ((c >= 0x0461 && c <= 0x0481) || |
(c >= 0x048b && c <= 0x04bf) || |
(c >= 0x04d1 && c <= 0x04ff)) |
{ |
if (c & 0x01) |
return (c - 1); |
return c; |
} |
if (c >= 0x04c2 && c <= 0x04ce) |
{ |
if (!(c & 0x01)) |
return (c - 1); |
return c; |
} |
if (c == 0x04cf) |
return 0x04c0; |
if (c >= 0x04f7 && c <= 0x04f9) |
return (c - 1); |
} |
else if (c < 0x0600) |
{ |
if (c >= 0x0501 && c <= 0x0525 && (c & 1)) |
return c - 1; |
if (c >= 0x0561 && c <= 0x0586) |
return (c - 0x30); |
} |
else if (c < 0x1f00) |
{ |
if (c == 0x1d79) |
return 0xa77d; |
if (c == 0x1d7d) |
return 0x2c63; |
if ((c >= 0x1e01 && c <= 0x1e95) || |
(c >= 0x1ea1 && c <= 0x1eff)) |
{ |
if (c & 0x01) |
return (c - 1); |
return c; |
} |
if (c == 0x1e9b) |
return 0x1e60; |
} |
else if (c < 0x2000) |
{ |
if ((c >= 0x1f00 && c <= 0x1f07) || |
(c >= 0x1f10 && c <= 0x1f15) || |
(c >= 0x1f20 && c <= 0x1f27) || |
(c >= 0x1f30 && c <= 0x1f37) || |
(c >= 0x1f40 && c <= 0x1f45) || |
(c >= 0x1f60 && c <= 0x1f67) || |
(c >= 0x1f80 && c <= 0x1f87) || |
(c >= 0x1f90 && c <= 0x1f97) || |
(c >= 0x1fa0 && c <= 0x1fa7)) |
return (c + 0x08); |
if (c >= 0x1f51 && c <= 0x1f57 && (c & 0x01)) |
return (c + 0x08); |
if (c >= 0x1f70 && c <= 0x1ff3) |
{ |
wint_t k; |
switch (c) |
{ |
case 0x1fb0: |
k = 0x1fb8; |
break; |
case 0x1fb1: |
k = 0x1fb9; |
break; |
case 0x1f70: |
k = 0x1fba; |
break; |
case 0x1f71: |
k = 0x1fbb; |
break; |
case 0x1fb3: |
k = 0x1fbc; |
break; |
case 0x1fbe: |
k = 0x0399; |
break; |
case 0x1f72: |
k = 0x1fc8; |
break; |
case 0x1f73: |
k = 0x1fc9; |
break; |
case 0x1f74: |
k = 0x1fca; |
break; |
case 0x1f75: |
k = 0x1fcb; |
break; |
case 0x1fc3: |
k = 0x1fcc; |
break; |
case 0x1fd0: |
k = 0x1fd8; |
break; |
case 0x1fd1: |
k = 0x1fd9; |
break; |
case 0x1f76: |
k = 0x1fda; |
break; |
case 0x1f77: |
k = 0x1fdb; |
break; |
case 0x1fe0: |
k = 0x1fe8; |
break; |
case 0x1fe1: |
k = 0x1fe9; |
break; |
case 0x1f7a: |
k = 0x1fea; |
break; |
case 0x1f7b: |
k = 0x1feb; |
break; |
case 0x1fe5: |
k = 0x1fec; |
break; |
case 0x1f78: |
k = 0x1ff8; |
break; |
case 0x1f79: |
k = 0x1ff9; |
break; |
case 0x1f7c: |
k = 0x1ffa; |
break; |
case 0x1f7d: |
k = 0x1ffb; |
break; |
case 0x1ff3: |
k = 0x1ffc; |
break; |
default: |
k = 0; |
} |
if (k != 0) |
return k; |
} |
} |
else if (c < 0x3000) |
{ |
if (c == 0x214e) |
return 0x2132; |
if (c == 0x2184) |
return 0x2183; |
if (c >= 0x2170 && c <= 0x217f) |
return (c - 0x10); |
if (c >= 0x24d0 && c <= 0x24e9) |
return (c - 0x1a); |
if (c >= 0x2c30 && c <= 0x2c5e) |
return (c - 0x30); |
if ((c >= 0x2c68 && c <= 0x2c6c && !(c & 1)) || |
(c >= 0x2c81 && c <= 0x2ce3 && (c & 1)) || |
c == 0x2c73 || c == 0x2c76 || |
c == 0x2cec || c == 0x2cee) |
return (c - 1); |
if (c >= 0x2c81 && c <= 0x2ce3 && (c & 1)) |
return (c - 1); |
if (c >= 0x2d00 && c <= 0x2d25) |
return (c - 0x1c60); |
switch (c) |
{ |
case 0x2c61: |
return 0x2c60; |
case 0x2c65: |
return 0x023a; |
case 0x2c66: |
return 0x023e; |
} |
} |
else if (c >= 0xa000 && c < 0xb000) |
{ |
if (((c >= 0xa641 && c <= 0xa65f) || |
(c >= 0xa663 && c <= 0xa66d) || |
(c >= 0xa681 && c <= 0xa697) || |
(c >= 0xa723 && c <= 0xa72f) || |
(c >= 0xa733 && c <= 0xa76f) || |
(c >= 0xa77f && c <= 0xa787)) && |
(c & 1)) |
return (c - 1); |
if (c == 0xa77a || c == 0xa77c || c == 0xa78c) |
return (c - 1); |
} |
else |
{ |
if (c >= 0xff41 && c <= 0xff5a) |
return (c - 0x20); |
if (c >= 0x10428 && c <= 0x1044f) |
return (c - 0x28); |
} |
return c; |
#else |
return (c < 0x00ff ? (wint_t)(toupper ((int)c)) : c); |
#endif /* _MB_CAPABLE */ |
} |
/contrib/sdk/sources/libc/ctype/utf8alpha.h |
---|
0,0 → 1,355 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* Generated using UnicodeData.txt 5.2 */ |
/* Expression used to filter out the characters for the below tables: |
awk -F\; \ |
'{ \ |
VAL = strtonum (sprintf("0x%s", $1)); \ |
# All of general category "L", except for two Thai characters which \ |
# are actually punctuation characters. Old Unicode weirdness. \ |
# The character "COMBINING GREEK YPOGEGRAMMENI", as well as all Thai \ |
# characters which are in "Mn" category. Old Unicode weirdness. \ |
# All numerical digit or letter characters, except the ASCII variants. \ |
# This is necessary due to the unfortunate ISO C definition for the \ |
# iswdigit class, otherwise these characters are missing in iswalnum. \ |
# All "Other Symbols" which are named as "LETTER" characters. \ |
# \ |
# Before running this test, make sure to expand all Unicode blocks \ |
# which are just marked by their first and last character! \ |
# \ |
if ( (match($3, "^L") && VAL != 0x0e2f && VAL != 0x0e46) \ |
|| (match($3, "^Mn") && (VAL == 0x0345 || match($2, "\\<CHARACTER\\>"))) \ |
|| (match($3, "^N[dl]") && VAL >= 0x100) \ |
|| (match($3, "^So") && match($2, "\\<LETTER\\>"))) \ |
print $1; \ |
}' UnicodeData.txt |
*/ |
static const unsigned char u0[] = { |
0x41, 0x0, 0x5a, 0x61, 0x0, 0x7a, 0xaa, 0xb5, |
0xba, 0xc0, 0x0, 0xd6, 0xd8, 0x0, 0xf6, 0xf8, |
0x0, 0xff }; |
/* u1 all alphabetic */ |
static const unsigned char u2[] = { |
0x00, 0x0, 0xc1, 0xc6, 0x0, 0xd1, |
0xe0, 0x0, 0xe4, 0xec, 0xee }; |
static const unsigned char u3[] = { |
0x45, 0x70, 0x0, 0x74, 0x76, 0x77, |
0x7a, 0x0, 0x7d, 0x86, 0x88, 0x0, 0x8a, 0x8c, |
0x8e, 0x0, 0xa1, 0xa3, 0x0, 0xf5, |
0xf7, 0x0, 0xff }; |
static const unsigned char u4[] = { |
0x00, 0x0, 0x81, 0x8a, 0x0, 0xff }; |
static const unsigned char u5[] = { |
0x00, 0x0, 0x25, 0x31, 0x0, 0x56, 0x59, |
0x61, 0x0, 0x87, 0xd0, 0x0, 0xea, |
0xf0, 0x0, 0xf2 }; |
static const unsigned char u6[] = { |
0x21, 0x0, 0x4a, 0x60, 0x0, 0x69, |
0x6e, 0x0, 0x6f, 0x71, 0x0, 0xd3, |
0xd5, 0xe5, 0x0, 0xe6, 0xee, 0x0, 0xfc, 0xff }; |
static const unsigned char u7[] = { |
0x10, 0x12, 0x0, 0x2f, 0x4d, 0x0, 0xa5, 0xb1, |
0xc0, 0x0, 0xea, 0xf4, 0xf5, 0xfa }; |
static const unsigned char u8[] = { |
0x00, 0x0, 0x15, 0x1a, 0x24, 0x28 }; |
static const unsigned char u9[] = { |
0x04, 0x0, 0x39, 0x3d, 0x50, 0x58, 0x0, 0x61, |
0x66, 0x0, 0x6f, 0x71, 0x72, 0x79, 0x0, 0x7f, |
0x85, 0x0, 0x8c, 0x8f, 0x0, 0x90, |
0x93, 0x0, 0xa8, 0xaa, 0x0, 0xb0, 0xb2, |
0xb6, 0x0, 0xb9, 0xbd, 0xce, 0xdc, 0x0, 0xdd, |
0xdf, 0x0, 0xe1, 0xe6, 0x0, 0xf1 }; |
static const unsigned char ua[] = { |
0x05, 0x0, 0x0a, 0x0f, 0x0, 0x10, |
0x13, 0x0, 0x28, 0x2a, 0x0, 0x30, |
0x32, 0x0, 0x33, 0x35, 0x0, 0x36, |
0x38, 0x0, 0x39, 0x59, 0x0, 0x5c, |
0x5e, 0x66, 0x0, 0x6f, 0x72, 0x0, 0x74, |
0x85, 0x0, 0x8d, 0x8f, 0x0, 0x91, |
0x93, 0x0, 0xa8, 0xaa, 0x0, 0xb0, |
0xb2, 0x0, 0xb3, 0xb5, 0x0, 0xb9, |
0xbd, 0xd0, 0xe0, 0xe1, 0xe6, 0x0, 0xef }; |
static const unsigned char ub[] = { |
0x05, 0x0, 0x0c, 0x0f, 0x0, 0x10, |
0x13, 0x0, 0x28, 0x2a, 0x0, 0x30, |
0x32, 0x0, 0x33, 0x35, 0x0, 0x39, 0x3d, |
0x5c, 0x0, 0x5d, 0x5f, 0x0, 0x61, |
0x66, 0x0, 0x6f, 0x71, 0x83, 0x85, 0x0, 0x8a, |
0x8e, 0x0, 0x90, 0x92, 0x0, 0x95, |
0x99, 0x0, 0x9a, 0x9c, 0x9e, 0x0, 0x9f, |
0xa3, 0x0, 0xa4, 0xa8, 0x0, 0xaa, |
0xae, 0x0, 0xb9, 0xd0, 0xe6, 0x0, 0xef }; |
static const unsigned char uc[] = { |
0x05, 0x0, 0x0c, 0x0e, 0x0, 0x10, |
0x12, 0x0, 0x28, 0x2a, 0x0, 0x33, |
0x35, 0x0, 0x39, 0x3d, 0x58, 0x59, |
0x60, 0x0, 0x61, 0x66, 0x0, 0x6f, |
0x85, 0x0, 0x8c, 0x8e, 0x0, 0x90, |
0x92, 0x0, 0xa8, 0xaa, 0x0, 0xb3, |
0xb5, 0x0, 0xb9, 0xbd, 0xde, 0xe0, 0x0, 0xe1, |
0xe6, 0x0, 0xef }; |
static const unsigned char ud[] = { |
0x05, 0x0, 0x0c, 0x0e, 0x0, 0x10, |
0x12, 0x0, 0x28, 0x2a, 0x0, 0x39, 0x3d, |
0x60, 0x0, 0x61, 0x66, 0x0, 0x6f, |
0x7a, 0x0, 0x7f, 0x85, 0x0, 0x96, 0x9a, |
0x0, 0xb1, 0xb3, 0x0, 0xbb, 0xbd, |
0xc0, 0x0, 0xc6 }; |
static const unsigned char ue[] = { |
0x01, 0x0, 0x2e, 0x30, 0x0, 0x3a, 0x40, |
0x0, 0x45, 0x47, 0x0, 0x4e, 0x50, 0x0, 0x59, |
0x81, 0x0, 0x82, 0x84, 0x87, 0x0, 0x88, 0x8a, |
0x8d, 0x94, 0x0, 0x97, 0x99, 0x0, 0x9f, 0xa1, |
0x0, 0xa3, 0xa5, 0xa7, 0xaa, 0x0, 0xab, 0xad, |
0x0, 0xb0, 0xb2, 0x0, 0xb3, 0xbd, 0xc0, 0x0, |
0xc4, 0xc6, 0xd0, 0x0, 0xd9, 0xdc, 0x0, 0xdd }; |
static const unsigned char uf[] = { |
0x00, 0x20, 0x0, 0x29, 0x40, 0x0, 0x47, 0x49, |
0x0, 0x6c, 0x88, 0x0, 0x8b }; |
static const unsigned char u10[] = { |
0x00, 0x0, 0x2a, 0x3f, 0x0, 0x49, |
0x50, 0x0, 0x55, 0x5a, 0x0, 0x5d, |
0x61, 0x65, 0x66, 0x6e, 0x0, 0x70, |
0x75, 0x0, 0x81, 0x8e, 0x90, 0x0, 0x99, |
0xa0, 0x0, 0xc5, 0xd0, 0x0, 0xfa, 0xfc }; |
/* u11 all alphabetic */ |
static const unsigned char u12[] = { |
0x00, 0x0, 0x48, 0x4a, 0x0, 0x4d, |
0x50, 0x0, 0x56, 0x58, 0x5a, 0x0, 0x5d, |
0x60, 0x0, 0x88, 0x8a, 0x0, 0x8d, |
0x90, 0x0, 0xb0, 0xb2, 0x0, 0xb5, |
0xb8, 0x0, 0xbe, 0xc0, 0xc2, 0x0, 0xc5, |
0xc8, 0x0, 0xd6, 0xd8, 0x0, 0xff }; |
static const unsigned char u13[] = { |
0x00, 0x0, 0x10, 0x12, 0x0, 0x15, |
0x18, 0x0, 0x5a, 0x80, 0x0, 0x8f, |
0xa0, 0x0, 0xf4 }; |
static const unsigned char u14[] = { |
0x01, 0x0, 0xff }; |
/* u15 all alphabetic */ |
static const unsigned char u16[] = { |
0x00, 0x0, 0x6c, 0x6f, 0x0, 0x7f, |
0x81, 0x0, 0x9a, 0xa0, 0x0, 0xea, |
0xee, 0x0, 0xf0 }; |
static const unsigned char u17[] = { |
0x00, 0x0, 0x0c, 0x0e, 0x0, 0x11, |
0x20, 0x0, 0x31, 0x40, 0x0, 0x51, |
0x60, 0x0, 0x6c, 0x6e, 0x0, 0x70, |
0x80, 0x0, 0xb3, 0xd7, 0xdc, 0xe0, 0x0, 0xe9 }; |
static const unsigned char u18[] = { |
0x10, 0x0, 0x19, 0x20, 0x0, 0x77, |
0x80, 0x0, 0xa8, 0xaa, 0xb0, 0x0, 0xf5 }; |
static const unsigned char u19[] = { |
0x00, 0x0, 0x1c, 0x46, 0x0, 0x6d, |
0x70, 0x0, 0x74, 0x80, 0x0, 0xab, |
0xc1, 0x0, 0xc7, 0xd0, 0x0, 0xda }; |
static const unsigned char u1a[] = { |
0x00, 0x0, 0x16, 0x20, 0x0, 0x54, |
0x80, 0x0, 0x89, 0x90, 0x0, 0x99, 0xa7 }; |
static const unsigned char u1b[] = { |
0x05, 0x0, 0x33, 0x45, 0x0, 0x4b, |
0x50, 0x0, 0x59, 0x83, 0x0, 0xa0, |
0xae, 0x0, 0xb9 }; |
static const unsigned char u1c[] = { |
0x00, 0x0, 0x23, 0x40, 0x0, 0x49, |
0x4d, 0x0, 0x7d, 0xe9, 0x0, 0xec, |
0xee, 0x0, 0xf1 }; |
static const unsigned char u1d[] = { |
0x00, 0x0, 0xbf }; |
/* u1e all alphabetic */ |
static const unsigned char u1f[] = { |
0x00, 0x0, 0x15, 0x18, 0x0, 0x1d, |
0x20, 0x0, 0x45, 0x48, 0x0, 0x4d, 0x50, 0x0, 0x57, 0x59, |
0x5b, 0x5d, 0x5f, 0x0, 0x7d, 0x80, 0x0, 0xb4, |
0xb6, 0x0, 0xbc, 0xbe, 0xc2, 0x0, 0xc4, 0xc6, |
0x0, 0xcc, 0xd0, 0x0, 0xd3, 0xd6, 0x0, 0xdb, |
0xe0, 0x0, 0xec, 0xf2, 0x0, 0xf4, 0xf6, 0x0, |
0xfc }; |
static const unsigned char u20[] = { |
0x71, 0x7f, 0x90, 0x0, 0x94 }; |
static const unsigned char u21[] = { |
0x02, 0x07, 0x0a, 0x0, 0x13, 0x15, |
0x19, 0x0, 0x1d, 0x24, 0x26, 0x28, 0x0, 0x2d, |
0x2f, 0x0, 0x39, 0x3c, 0x0, 0x3f, |
0x45, 0x0, 0x49, 0x4e, 0x60, 0x0, 0x88 }; |
static const unsigned char u24[] = { |
0x9c, 0x0, 0xe9 }; |
static const unsigned char u2c[] = { |
0x00, 0x0, 0x2e, 0x30, 0x0, 0x5e, |
0x60, 0x0, 0xe4, 0xeb, 0x0, 0xee }; |
static const unsigned char u2d[] = { |
0x00, 0x0, 0x25, 0x30, 0x0, 0x65, 0x6f, |
0x80, 0x0, 0x96, 0xa0, 0x0, 0xa6, |
0xa8, 0x0, 0xae, 0xb0, 0x0, 0xb6, |
0xb8, 0x0, 0xbe, 0xc0, 0x0, 0xc6, |
0xc8, 0x0, 0xce, 0xd0, 0x0, 0xd6, |
0xd8, 0x0, 0xde }; |
static const unsigned char u2e[] = { |
0x2f }; |
static const unsigned char u30[] = { |
0x05, 0x0, 0x07, 0x21, 0x0, |
0x29, 0x31, 0x0, 0x35, 0x38, 0x0, 0x3c, 0x41, |
0x0, 0x96, 0x9d, 0x0, 0x9f, 0xa1, 0x0, 0xfa, |
0xfc, 0x0, 0xff }; |
static const unsigned char u31[] = { |
0x05, 0x0, 0x2d, 0x31, 0x0, |
0x8e, 0xa0, 0x0, 0xb7, 0xf0, 0x0, 0xff }; |
/* u34 to u4c all alphabetic */ |
static const unsigned char u4d[] = { |
0x00, 0x0, 0xb5 }; |
/* u4e to u9e all alphabetic */ |
static const unsigned char u9f[] = { |
0x00, 0x0, 0xcb }; |
/* ua0 to ua3 all alphabetic */ |
static const unsigned char ua4[] = { |
0x00, 0x0, 0x8c, 0xd0, 0x0, 0xfd }; |
/* ua5 all alphabetic */ |
static const unsigned char ua6[] = { |
0x00, 0x0, 0x0c, 0x10, 0x0, 0x2b, |
0x40, 0x0, 0x5f, 0x62, 0x0, 0x6e, |
0x7f, 0x0, 0x97, 0xa0, 0x0, 0xef }; |
static const unsigned char ua7[] = { |
0x17, 0x0, 0x1f, 0x22, 0x0, 0x88, |
0x8b, 0x8c, |
0xfb, 0x0, 0xff }; |
static const unsigned char ua8[] = { |
0x00, 0x01, 0x03, 0x0, 0x05, 0x07, 0x0, 0x0a, |
0x0c, 0x0, 0x22, 0x40, 0x0, 0x73, |
0x82, 0x0, 0xb3, 0xd0, 0x0, 0xd9, |
0xf2, 0x0, 0xf7, 0xfb }; |
static const unsigned char ua9[] = { |
0x00, 0x0, 0x25, 0x30, 0x0, 0x46, |
0x60, 0x0, 0x7c, 0x84, 0x0, 0xb2, |
0xcf, 0x0, 0xd9 }; |
static const unsigned char uaa[] = { |
0x00, 0x0, 0x28, 0x40, 0x0, 0x42, |
0x44, 0x0, 0x4b, 0x50, 0x0, 0x59, |
0x60, 0x0, 0x76, 0x7a, 0x80, 0x0, 0xaf, |
0xb1, 0xb5, 0xb6, 0xb9, 0x0, 0xbd, |
0xc0, 0xc2, 0xdb, 0x0, 0xdd }; |
static const unsigned char uab[] = { |
0xc0, 0x0, 0xe2, 0xf0, 0x0, 0xf9 }; |
/* uac to ud6 all alphabetic */ |
static const unsigned char ud7[] = { |
0x00, 0x0, 0xa3, 0xb0, 0x0, 0xc6, |
0xcb, 0x0, 0xfb }; |
/* uf9 all alphabetic */ |
static const unsigned char ufa[] = { |
0x00, 0x0, 0x2d, 0x30, 0x0, 0x6d, |
0x70, 0x0, 0xd9 }; |
static const unsigned char ufb[] = { |
0x00, 0x0, 0x06, 0x13, 0x0, 0x17, 0x1d, |
0x1f, 0x0, 0x28, 0x2a, 0x0, 0x36, 0x38, 0x0, |
0x3c, 0x3e, 0x40, 0x0, 0x41, 0x43, 0x0, 0x44, |
0x46, 0x0, 0xb1, 0xd3, 0x0, 0xff }; |
/* ufc all alphabetic */ |
static const unsigned char ufd[] = { |
0x00, 0x0, 0x3d, 0x50, 0x0, |
0x8f, 0x92, 0x0, 0xc7, 0xf0, 0x0, 0xfb }; |
static const unsigned char ufe[] = { |
0x70, |
0x0, 0x74, 0x76, 0x0, 0xfc }; |
static const unsigned char uff[] = { |
0x10, 0x0, 0x19, |
0x21, 0x0, 0x3a, 0x41, 0x0, 0x5a, 0x66, 0x0, |
0xbe, 0xc2, 0x0, 0xc7, 0xca, 0x0, 0xcf, 0xd2, |
0x0, 0xd7, 0xda, 0x0, 0xdc }; |
static const unsigned char u100[] = { |
0x00, 0x0, 0x0b, 0x0d, 0x0, 0x26, |
0x28, 0x0, 0x3a, 0x3c, 0x3d, 0x3f, 0x0, 0x4d, |
0x50, 0x0, 0x5d, 0x80, 0x0, 0xfa }; |
static const unsigned char u101[] = { |
0x40, 0x0, 0x74 }; |
static const unsigned char u102[] = { |
0x80, 0x0, 0x9c, 0xa0, 0x0, 0xd0 }; |
static const unsigned char u103[] = { |
0x00, 0x0, 0x1e, 0x30, 0x0, 0x4a, |
0x80, 0x0, 0x9d, 0xa0, 0x0, 0xc3, |
0xc8, 0x0, 0xcf, 0xd1, 0x0, 0xd5 }; |
static const unsigned char u104[] = { |
0x00, 0x0, 0x9d, 0xa0, 0x0, 0xa9 }; |
static const unsigned char u108[] = { |
0x00, 0x0, 0x05, 0x08, 0x0a, 0x0, 0x35, |
0x37, 0x38, 0x3c, 0x3f, 0x0, 0x55 }; |
static const unsigned char u109[] = { |
0x00, 0x0, 0x15, 0x20, 0x0, 0x39 }; |
static const unsigned char u10a[] = { |
0x00, 0x10, 0x0, 0x13, 0x15, 0x0, 0x17, |
0x19, 0x0, 0x33, 0x60, 0x0, 0x7c }; |
static const unsigned char u10b[] = { |
0x00, 0x0, 0x35, 0x40, 0x0, 0x55, |
0x60, 0x0, 0x72 }; |
static const unsigned char u10c[] = { |
0x00, 0x0, 0x48 }; |
static const unsigned char u110[] = { |
0x83, 0x0, 0xaf }; |
/* u120 to u122 all alphabetic */ |
static const unsigned char u123[] = { |
0x00, 0x0, 0x6e }; |
static const unsigned char u124[] = { |
0x00, 0x0, 0x62 }; |
/* u130 to u133 all alphabetic */ |
static const unsigned char u134[] = { |
0x00, 0x0, 0x2e }; |
static const unsigned char u1d4[] = { |
0x00, 0x0, 0x54, 0x56, 0x0, 0x9c, |
0x9e, 0x0, 0x9f, 0xa2, 0xa5, 0x0, 0xa6, |
0xa9, 0x0, 0xac, 0xae, 0x0, 0xb9, 0xbb, |
0xbd, 0x0, 0xc3, 0xc5, 0x0, 0xff }; |
static const unsigned char u1d5[] = { |
0x00, 0x0, 0x05, 0x07, 0x0, |
0x0a, 0x0d, 0x0, 0x14, 0x16, 0x0, 0x1c, 0x1e, |
0x0, 0x39, 0x3b, 0x0, 0x3e, 0x40, 0x0, 0x44, |
0x46, 0x4a, 0x0, 0x50, 0x52, 0x0, 0xff }; |
static const unsigned char u1d6[] = { |
0x00, 0x0, 0xa5, 0xa8, 0x0, 0xc0, |
0xc2, 0x0, 0xda, 0xdc, 0x0, 0xfa, |
0xfc, 0x0, 0xff }; |
static const unsigned char u1d7[] = { |
0x00, 0x0, 0x14, 0x16, 0x0, 0x34, |
0x36, 0x0, 0x4e, 0x50, 0x0, 0x6e, |
0x70, 0x0, 0x88, 0x8a, 0x0, 0xa8, |
0xaa, 0x0, 0xc2, 0xc4, 0x0, 0xcb, |
0xce, 0x0, 0xff }; |
static const unsigned char u1f1[] = { |
0x10, 0x0, 0x2c, 0x31, 0x3d, 0x3f, 0x42, 0x46, |
0x57, 0x5f, 0x79, 0x7b, 0x7c, 0x7f, 0x8a }; |
/* u200 to u2a5 all alphabetic */ |
static const unsigned char u2a6[] = { |
0x00, 0x0, 0xd6 }; |
/* u2a7 to u2b6 all alphabetic */ |
static const unsigned char u2b7[] = { |
0x00, 0x0, 0x34 }; |
/* u2f8 to u2f9 all alphabetic */ |
static const unsigned char u2fa[] = { |
0x00, 0x0, 0x1d }; |
/contrib/sdk/sources/libc/ctype/utf8print.h |
---|
0,0 → 1,389 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* Generated using UnicodeData.txt 5.2 */ |
/* Expression used to filter out the characters for the below tables: |
awk -F\; \ |
'{ \ |
VAL = strtonum (sprintf("0x%s", $1)); \ |
# All valid characters except from categories Cc (C0 or C1 control code), \ |
# Cs (Surrogates), Zl (Line separator), and Zp (Paragraph separator).\ |
# \ |
# Before running this test, make sure to expand all Unicode blocks \ |
# which are just marked by their first and last character! \ |
# \ |
if (!match($3, "^C[cs]") && !match($3, "^Z[lp]")) \ |
print $1; \ |
}' UnicodeData.txt |
*/ |
static const unsigned char u0[] = { |
0x20, 0x0, 0x7e, 0xa0, 0x0, 0xff }; |
/* u1 is all-print */ |
/* u2 is all-print */ |
static const unsigned char u3[] = { |
0x00, 0x0, 0x77, 0x7a, 0x0, 0x7e, |
0x84, 0x0, 0x8a, 0x8c, 0x8e, 0x0, |
0xa1, 0xa3, 0x0, 0xff }; |
/* u4 is all-print */ |
static const unsigned char u5[] = { |
0x00, 0x0, 0x25, 0x31, 0x0, |
0x56, 0x59, 0x0, 0x5f, 0x61, 0x0, 0x87, 0x89, |
0x0, 0x8a, 0x91, 0x0, 0xc7, 0xd0, 0x0, 0xea, |
0xf0, 0x0, 0xf4 }; |
static const unsigned char u6[] = { |
0x00, 0x0, 0x03, 0x06, 0x0, 0x1b, 0x1e, 0x1f, |
0x21, 0x0, 0x5e, 0x60, 0x0, 0xff }; |
static const unsigned char u7[] = { |
0x00, 0x0, 0x0d, 0x0f, 0x0, 0x4a, 0x4d, 0x0, 0xb1, |
0xc0, 0x0, 0xfa }; |
static const unsigned char u8[] = { |
0x00, 0x0, 0x2d, 0x30, 0x0, 0x3e, }; |
static const unsigned char u9[] = { |
0x00, 0x0, 0x39, 0x3c, 0x0, 0x4e, 0x50, 0x0, 0x55, |
0x58, 0x0, 0x72, 0x79, 0x0, 0x7f, 0x81, 0x0, 0x83, |
0x85, 0x0, 0x8c, 0x8f, 0x0, 0x90, 0x93, 0x0, 0xa8, |
0xaa, 0x0, 0xb0, 0xb2, 0xb6, 0x0, 0xb9, 0xbc, |
0x0, 0xc4, 0xc7, 0xc8, 0xcb, 0x0, 0xce, |
0xd7, 0xdc, 0x0, 0xdd, 0xdf, 0x0, 0xe3, 0xe6, |
0x0, 0xfb }; |
static const unsigned char ua[] = { |
0x01, 0x0, 0x03, 0x05, 0x0, 0x0a, 0x0f, 0x0, |
0x10, 0x13, 0x0, 0x28, 0x2a, 0x0, 0x30, 0x32, |
0x0, 0x33, 0x35, 0x0, 0x36, 0x38, 0x0, 0x39, |
0x3c, 0x3e, 0x0, 0x42, 0x47, 0x0, 0x48, 0x4b, |
0x0, 0x4d, 0x51, 0x59, 0x0, 0x5c, 0x5e, 0x66, 0x0, |
0x75, 0x81, 0x0, 0x83, 0x85, 0x0, 0x8d, |
0x8f, 0x0, 0x91, 0x93, 0x0, 0xa8, 0xaa, 0x0, |
0xb0, 0xb2, 0x0, 0xb3, 0xb5, 0x0, 0xb9, 0xbc, |
0x0, 0xc5, 0xc7, 0x0, 0xc9, 0xcb, 0x0, 0xcd, |
0xd0, 0xe0, 0x0, 0xe3, 0xe6, 0x0, 0xef, 0xf1 }; |
static const unsigned char ub[] = { |
0x01, 0x0, 0x03, |
0x05, 0x0, 0x0c, 0x0f, 0x0, 0x10, 0x13, 0x0, |
0x28, 0x2a, 0x0, 0x30, 0x32, 0x0, 0x33, 0x35, |
0x0, 0x39, 0x3c, 0x0, 0x44, 0x47, 0x0, 0x48, |
0x4b, 0x0, 0x4d, 0x56, 0x0, 0x57, 0x5c, 0x0, |
0x5d, 0x5f, 0x0, 0x63, 0x66, 0x0, 0x71, 0x82, |
0x0, 0x83, 0x85, 0x0, 0x8a, 0x8e, 0x0, 0x90, |
0x92, 0x0, 0x95, 0x99, 0x0, 0x9a, 0x9c, 0x9e, |
0x0, 0x9f, 0xa3, 0x0, 0xa4, 0xa8, 0x0, 0xaa, |
0xae, 0x0, 0xb9, 0xbe, 0x0, |
0xc2, 0xc6, 0x0, 0xc8, 0xca, 0x0, 0xcd, 0xd0, |
0xd7, 0xe6, 0xe7, 0x0, 0xfa }; |
static const unsigned char uc[] = { |
0x01, 0x0, 0x03, 0x05, 0x0, |
0x0c, 0x0e, 0x0, 0x10, 0x12, 0x0, 0x28, 0x2a, |
0x0, 0x33, 0x35, 0x0, 0x39, 0x3d, 0x0, 0x44, |
0x46, 0x0, 0x48, 0x4a, 0x0, 0x4d, 0x55, 0x0, |
0x56, 0x58, 0x59, 0x60, 0x0, 0x63, 0x66, 0x0, 0x6f, |
0x78, 0x0, 0x7f, 0x82, 0x83, 0x85, 0x0, 0x8c, |
0x8e, 0x0, 0x90, 0x92, 0x0, 0xa8, 0xaa, 0x0, 0xb3, |
0xb5, 0x0, 0xb9, 0xbc, 0x0, 0xc4, 0xc6, 0x0, 0xc8, |
0xca, 0x0, 0xcd, 0xd5, 0x0, 0xd6, 0xde, 0xe0, 0x0, |
0xe3, 0xe6, 0x0, 0xef, 0xf1, 0xf2 }; |
static const unsigned char ud[] = { |
0x02, 0x0, 0x03, 0x05, |
0x0, 0x0c, 0x0e, 0x0, 0x10, 0x12, 0x0, 0x28, |
0x2a, 0x0, 0x39, 0x3d, 0x0, 0x44, 0x46, 0x0, |
0x48, 0x4a, 0x0, 0x4d, 0x57, 0x60, 0x0, 0x63, |
0x66, 0x0, 0x75, 0x79, 0x0, 0x7f, 0x82, 0x0, 0x83, |
0x85, 0x0, 0x96, 0x9a, 0x0, 0xb1, 0xb3, 0x0, 0xbb, |
0xbd, 0xc0, 0x0, 0xc6, 0xca, 0xcf, 0x0, 0xd4, 0xd6, |
0xd8, 0x0, 0xdf, 0xf2, 0x0, 0xf4 }; |
static const unsigned char ue[] = { |
0x01, 0x0, |
0x3a, 0x3f, 0x0, 0x5b, 0x81, 0x0, 0x82, 0x84, |
0x87, 0x0, 0x88, 0x8a, 0x8d, 0x94, 0x0, 0x97, |
0x99, 0x0, 0x9f, 0xa1, 0x0, 0xa3, 0xa5, 0xa7, |
0xaa, 0x0, 0xab, 0xad, 0x0, 0xb9, 0xbb, 0x0, |
0xbd, 0xc0, 0x0, 0xc4, 0xc6, 0xc8, 0x0, 0xcd, |
0xd0, 0x0, 0xd9, 0xdc, 0x0, 0xdd }; |
static const unsigned char uf[] = { |
0x00, 0x0, 0x47, 0x49, 0x0, 0x6c, |
0x71, 0x0, 0x8b, 0x90, 0x0, 0x97, |
0x99, 0x0, 0xbc, 0xbe, 0x0, 0xcc, |
0xce, 0x0, 0xd8 }; |
static const unsigned char u10[] = { |
0x00, 0x0, 0xc5, 0xd0, 0x0, 0xfc }; |
/* u11 is all-print */ |
static const unsigned char u12[] = { |
0x00, 0x0, 0x48, 0x4a, 0x0, 0x4d, 0x50, 0x0, 0x56, |
0x58, 0x5a, 0x0, 0x5d, 0x60, 0x0, 0x88, |
0x8a, 0x0, 0x8d, 0x90, 0x0, 0xb0, 0xb2, |
0x0, 0xb5, 0xb8, 0x0, 0xbe, 0xc0, 0xc2, 0x0, |
0xc5, 0xc8, 0x0, 0xd6, 0xd8, 0x0, 0xff }; |
static const unsigned char u13[] = { |
0x00, 0x0, 0x10, 0x12, 0x0, 0x15, |
0x18, 0x0, 0x5a, 0x5f, 0x0, 0x7c, |
0x80, 0x0, 0x99, 0xa0, 0x0, 0xf4 }; |
/* u14 is all-print */ |
/* u15 is all-print */ |
static const unsigned char u16[] = { |
0x00, 0x0, 0x9c, 0xa0, 0x0, 0xf0 }; |
static const unsigned char u17[] = { |
0x00, 0x0, 0x0c, 0x0e, 0x0, 0x14, 0x20, |
0x0, 0x36, 0x40, 0x0, 0x53, 0x60, 0x0, 0x6c, |
0x6e, 0x0, 0x70, 0x72, 0x0, 0x73, 0x80, 0x0, |
0xdd, 0xe0, 0x0, 0xe9, 0xf0, 0x0, 0xf9 }; |
static const unsigned char u18[] = { |
0x00, 0x0, 0x0e, 0x10, |
0x0, 0x19, 0x20, 0x0, 0x77, 0x80, 0x0, 0xaa, |
0xb0, 0x0, 0xf5 }; |
static const unsigned char u19[] = { |
0x00, 0x0, 0x1c, 0x20, 0x0, 0x2b, |
0x30, 0x0, 0x3b, 0x40, 0x44, 0x0, 0x6d, |
0x70, 0x0, 0x74, 0x80, 0x0, 0xab, |
0xb0, 0x0, 0xc9, 0xd0, 0x0, 0xda, |
0xde, 0x0, 0xff }; |
static const unsigned char u1a[] = { |
0x00, 0x0, 0x1b, 0x1e, 0x0, 0x5e, |
0x60, 0x0, 0x7c, 0x7f, 0x0, 0x89, |
0x90, 0x0, 0x99, 0xa0, 0x0, 0xad }; |
static const unsigned char u1b[] = { |
0x00, 0x0, 0x4b, 0x50, 0x0, 0x7c, |
0x80, 0x0, 0xaa, 0xae, 0x0, 0xb9 }; |
static const unsigned char u1c[] = { |
0x00, 0x0, 0x37, 0x3b, 0x0, 0x49, |
0x4d, 0x0, 0x7f, 0xd0, 0x0, 0xf2 }; |
static const unsigned char u1d[] = { |
0x00, 0x0, 0xe6, 0xfd, 0x0, 0xff }; |
/* u1e is all-print */ |
static const unsigned char u1f[] = { |
0x00, 0x0, |
0x15, 0x18, 0x0, 0x1d, 0x20, 0x0, 0x45, 0x48, |
0x0, 0x4d, 0x50, 0x0, 0x57, 0x59, 0x5b, 0x5d, |
0x5f, 0x0, 0x7d, 0x80, 0x0, 0xb4, 0xb6, 0x0, |
0xc4, 0xc6, 0x0, 0xd3, 0xd6, 0x0, 0xdb, 0xdd, |
0x0, 0xef, 0xf2, 0x0, 0xf4, 0xf6, 0x0, 0xfe }; |
static const unsigned char u20[] = { |
0x00, 0x0, 0x27, 0x2a, 0x0, 0x64, |
0x6a, 0x0, 0x71, 0x74, 0x0, 0x8e, |
0x90, 0x0, 0x94, 0xa0, 0x0, 0xb8, |
0xd0, 0x0, 0xf0 }; |
static const unsigned char u21[] = { |
0x00, 0x0, 0x89, 0x90, 0x0, 0xff }; |
/* u22 is all-print */ |
static const unsigned char u23[] = { |
0x00, 0x0, 0xe8 }; |
static const unsigned char u24[] = { |
0x00, 0x0, 0x26, 0x40, 0x0, 0x4a, |
0x60, 0x0, 0xff }; |
/* u25 is all-print */ |
static const unsigned char u26[] = { |
0x00, 0x0, 0xcd, 0xcf, 0x0, 0xe1, |
0xe3, 0xe8, 0x0, 0xff }; |
static const unsigned char u27[] = { |
0x01, 0x0, 0x04, 0x06, 0x0, 0x09, |
0x0c, 0x0, 0x27, 0x29, 0x0, 0x4b, 0x4d, |
0x4f, 0x0, 0x52, 0x56, 0x0, 0x5e, |
0x61, 0x0, 0x94, 0x98, 0x0, 0xaf, |
0xb1, 0x0, 0xbe, 0xc0, 0x0, 0xca, 0xcc, |
0xd0, 0x0, 0xff }; |
/* u28 to u2a are all-print */ |
static const unsigned char u2b[] = { |
0x00, 0x0, 0x4c, 0x50, 0x0, 0x59 }; |
static const unsigned char u2c[] = { |
0x00, 0x0, 0x2e, 0x30, 0x0, 0x5e, |
0x60, 0x0, 0xf1, 0xf9, 0x0, 0xff }; |
static const unsigned char u2d[] = { |
0x00, 0x0, 0x25, 0x30, 0x0, 0x65, 0x6f, |
0x80, 0x0, 0x96, 0xa0, 0x0, 0xa6, |
0xa8, 0x0, 0xae, 0xb0, 0x0, 0xb6, |
0xb8, 0x0, 0xbe, 0xc0, 0x0, 0xc6, |
0xc8, 0x0, 0xce, 0xd0, 0x0, 0xd6, |
0xd8, 0x0, 0xde, 0xe0, 0x0, 0xff }; |
static const unsigned char u2e[] = { |
0x00, 0x0, 0x31, 0x80, 0x0, 0x99, |
0x9b, 0x0, 0xf3 }; |
static const unsigned char u2f[] = { |
0x00, 0x0, 0xd5, 0xf0, 0x0, 0xfb }; |
static const unsigned char u30[] = { |
0x00, 0x0, |
0x3f, 0x41, 0x0, 0x96, 0x99, 0x0, 0xff }; |
static const unsigned char u31[] = { |
0x05, 0x0, 0x2d, 0x31, 0x0, 0x8e, |
0x90, 0x0, 0xb7, 0xc0, 0x0, 0xe3, |
0xf0, 0x0, 0xff }; |
static const unsigned char u32[] = { |
0x00, 0x0, 0x1e, 0x20, 0x0, 0xfe }; |
/* u33 to u4c is all-print */ |
static const unsigned char u4d[] = { |
0x00, 0x0, 0xb5, 0xc0, 0x0, 0xff }; |
/* u4e to u9e is all-print */ |
static const unsigned char u9f[] = { |
0x00, 0x0, 0xcb }; |
/* ua0 to ua3 is all-print */ |
static const unsigned char ua4[] = { |
0x00, 0x0, 0x8c, 0x90, 0x0, 0xc6, |
0xd0, 0x0, 0xff }; |
/* ua5 is all-print */ |
static const unsigned char ua6[] = { |
0x00, 0x0, 0x2b, 0x40, 0x0, 0x5f, |
0x62, 0x0, 0x73, 0x7c, 0x0, 0x97, |
0xa0, 0x0, 0xf7 }; |
static const unsigned char ua7[] = { |
0x00, 0x0, 0x8c, 0xfb, 0x0, 0xff }; |
static const unsigned char ua8[] = { |
0x00, 0x0, 0x2b, 0x30, 0x0, 0x39, |
0x40, 0x0, 0x77, 0x80, 0x0, 0xc4, |
0xce, 0x0, 0xd9, 0xe0, 0x0, 0xfb }; |
static const unsigned char ua9[] = { |
0x00, 0x0, 0x53, 0x5f, 0x0, 0x7c, |
0x80, 0x0, 0xcd, 0xcf, 0x0, 0xd9, |
0xde, 0xdf }; |
static const unsigned char uaa[] = { |
0x00, 0x0, 0x36, 0x40, 0x0, 0x4d, |
0x50, 0x0, 0x59, 0x5c, 0x0, 0x7b, |
0x80, 0x0, 0xc2, 0xdb, 0x0, 0xdf }; |
static const unsigned char uab[] = { |
0xc0, 0x0, 0xed, 0xf0, 0x0, 0xf9 }; |
/* uac to ud6 is all-print */ |
static const unsigned char ud7[] = { |
0x00, 0x0, 0xa3, 0xb0, 0x0, 0xc6, |
0xcb, 0x0, 0xfb }; |
/* ud8 to udf are UTF-16 surrogates, non-printable */ |
/* ue0 to uf9 is all-print */ |
static const unsigned char ufa[] = { |
0x00, 0x0, 0x2d, 0x30, 0x0, 0x6d, |
0x70, 0x0, 0xd9 }; |
static const unsigned char ufb[] = { |
0x00, 0x0, 0x06, 0x13, 0x0, 0x17, |
0x1d, 0x0, 0x36, 0x38, 0x0, 0x3c, |
0x3e, 0x40, 0x41, 0x43, 0x44, |
0x46, 0x0, 0xb1, 0xd3, 0x0, 0xff }; |
/* ufc is all-print */ |
static const unsigned char ufd[] = { |
0x00, 0x0, 0x3f, 0x50, 0x0, 0x8f, |
0x92, 0x0, 0xc7, 0xf0, 0x0, 0xfd }; |
static const unsigned char ufe[] = { |
0x00, 0x0, 0x19, 0x20, 0x0, 0x26, |
0x30, 0x0, 0x52, 0x54, 0x0, 0x66, |
0x68, 0x0, 0x6b, 0x70, 0x0, 0x74, |
0x76, 0x0, 0xfc, 0xff }; |
static const unsigned char uff[] = { |
0x01, 0x0, 0xbe, 0xc2, 0x0, 0xc7, 0xca, 0x0, |
0xcf, 0xd2, 0x0, 0xd7, 0xda, 0x0, 0xdc, 0xe0, |
0x0, 0xe6, 0xe8, 0x0, 0xee, 0xf9, 0x0, 0xfd }; |
static const unsigned char u100[] = { |
0x00, 0x0, 0x0b, 0x0d, 0x0, 0x26, |
0x28, 0x0, 0x3a, 0x3c, 0x3d, 0x3f, 0x0, 0x4d, |
0x50, 0x0, 0x5d, 0x80, 0x0, 0xfa }; |
static const unsigned char u101[] = { |
0x00, 0x0, 0x02, 0x07, 0x0, 0x33, |
0x37, 0x0, 0x8a, 0x90, 0x0, 0x9b, |
0xd0, 0x0, 0xfd }; |
static const unsigned char u102[] = { |
0x80, 0x0, 0x9c, 0xa0, 0x0, 0xd0 }; |
static const unsigned char u103[] = { |
0x00, 0x0, 0x1e, 0x20, 0x0, 0x23, |
0x30, 0x0, 0x4a, 0x80, 0x0, 0x9d, |
0x9f, 0x0, 0xc3, 0xc8, 0x0, 0xd5 }; |
static const unsigned char u104[] = { |
0x00, 0x0, 0x9d, 0xa0, 0x0, 0xa9 }; |
static const unsigned char u108[] = { |
0x00, 0x0, 0x05, 0x08, 0x0a, 0x0, 0x35, |
0x37, 0x38, 0x3c, 0x3f, 0x0, 0x55, |
0x57, 0x0, 0x5f }; |
static const unsigned char u109[] = { |
0x00, 0x0, 0x1b, 0x1f, 0x0, 0x39, 0x3f }; |
static const unsigned char u10a[] = { |
0x00, 0x0, 0x03, 0x05, 0x06, 0x0c, 0x0, 0x13, |
0x15, 0x0, 0x17, 0x19, 0x0, 0x33, |
0x38, 0x0, 0x3a, 0x3f, 0x0, 0x47, |
0x50, 0x0, 0x58, 0x60, 0x0, 0x7f }; |
static const unsigned char u10b[] = { |
0x00, 0x0, 0x35, 0x39, 0x0, 0x55, |
0x58, 0x0, 0x72, 0x78, 0x0, 0x7f }; |
static const unsigned char u10c[] = { |
0x00, 0x0, 0x48 }; |
static const unsigned char u10e[] = { |
0x60, 0x0, 0x7e }; |
static const unsigned char u110[] = { |
0x80, 0x0, 0xc1 }; |
/* u120 to u122 is all-print */ |
static const unsigned char u123[] = { |
0x00, 0x0, 0x6e }; |
static const unsigned char u124[] = { |
0x00, 0x0, 0x62, 0x70, 0x0, 0x73 }; |
/* u130 to u133 is all-print */ |
static const unsigned char u134[] = { |
0x00, 0x0, 0x2e }; |
static const unsigned char u1d0[] = { |
0x00, 0x0, 0xf5 }; |
static const unsigned char u1d1[] = { |
0x00, 0x0, 0x26, 0x29, 0x0, 0xdd }; |
static const unsigned char u1d2[] = { |
0x00, 0x0, 0x45 }; |
static const unsigned char u1d3[] = { |
0x00, 0x0, 0x56, 0x60, 0x0, 0x71 }; |
static const unsigned char u1d4[] = { |
0x00, 0x0, 0x54, 0x56, 0x0, 0x9c, 0x9e, 0x0, |
0x9f, 0xa2, 0xa5, 0x0, 0xa6, 0xa9, 0x0, 0xac, |
0xae, 0x0, 0xb9, 0xbb, 0xbd, 0x0, 0xc3, |
0xc5, 0x0, 0xff }; |
static const unsigned char u1d5[] = { |
0x00, 0x0, 0x05, 0x07, 0x0, 0x0a, |
0x0d, 0x0, 0x14, 0x16, 0x0, 0x1c, 0x1e, 0x0, |
0x39, 0x3b, 0x0, 0x3e, 0x40, 0x0, 0x44, 0x46, |
0x4a, 0x0, 0x50, 0x52, 0x0, 0xff }; |
static const unsigned char u1d6[] = { |
0x00, 0x0, 0xa5, 0xa8, 0x0, 0xff }; |
static const unsigned char u1d7[] = { |
0x00, 0x0, 0xcb, 0xce, 0x0, 0xff }; |
static const unsigned char u1f0[] = { |
0x00, 0x0, 0x2b, 0x30, 0x0, 0x93 }; |
static const unsigned char u1f1[] = { |
0x00, 0x0, 0x0a, 0x10, 0x0, 0x2e, |
0x31, 0x3d, 0x3f, 0x42, 0x46, 0x4a, 0x0, 0x4e, |
0x57, 0x5f, 0x79, 0x7b, 0x7c, 0x7f, 0x8a, 0x0, |
0x8c, 0x8d, 0x90 }; |
static const unsigned char u1f2[] = { |
0x00, 0x10, 0x0, 0x31, 0x40, 0x0, 0x48 }; |
/* u200 to u2a5 is all-print */ |
static const unsigned char u2a6[] = { |
0x00, 0x0, 0xd6 }; |
/* u2a7 to u2b6 is all-print */ |
static const unsigned char u2b7[] = { |
0x00, 0x0, 0x34 }; |
/* u2f8 to u2f9 is all-print */ |
static const unsigned char u2fa[] = { |
0x00, |
0x0, 0x1d }; |
static const unsigned char ue00[] = { |
0x01, 0x20, 0x0, 0x7f }; |
static const unsigned char ue01[] = { |
0x00, 0x0, 0xef }; |
/* uf00 to uffe is all-print */ |
static const unsigned char ufff[] = { |
0x00, 0x0, 0xfd }; |
/* u1000 to u10fe is all-print */ |
static const unsigned char u10ff[] = { |
0x00, 0x0, 0xfd }; |
/contrib/sdk/sources/libc/ctype/wctrans.c |
---|
0,0 → 1,94 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<wctrans>>---get wide-character translation type |
INDEX |
wctrans |
ANSI_SYNOPSIS |
#include <wctype.h> |
wctrans_t wctrans(const char *<[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
wctrans_t wctrans(<[c]>) |
const char * <[c]>; |
DESCRIPTION |
<<wctrans>> is a function which takes a string <[c]> and gives back |
the appropriate wctrans_t type value associated with the string, |
if one exists. The following values are guaranteed to be recognized: |
"tolower" and "toupper". |
RETURNS |
<<wctrans>> returns 0 and sets <<errno>> to <<EINVAL>> if the |
given name is invalid. Otherwise, it returns a valid non-zero wctrans_t |
value. |
PORTABILITY |
<<wctrans>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <string.h> |
#include <reent.h> |
#include <wctype.h> |
#include <errno.h> |
#include "local.h" |
wctrans_t |
_DEFUN (_wctrans_r, (r, c), |
struct _reent *r _AND |
const char *c) |
{ |
if (!strcmp (c, "tolower")) |
return WCT_TOLOWER; |
else if (!strcmp (c, "toupper")) |
return WCT_TOUPPER; |
else |
{ |
r->_errno = EINVAL; |
return 0; |
} |
} |
#ifndef _REENT_ONLY |
wctrans_t |
_DEFUN (wctrans, (c), |
const char *c) |
{ |
return _wctrans_r (_REENT, c); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/ctype/wctype.c |
---|
0,0 → 1,137 |
/* Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<wctype>>---get wide-character classification type |
INDEX |
wctype |
ANSI_SYNOPSIS |
#include <wctype.h> |
wctype_t wctype(const char *<[c]>); |
TRAD_SYNOPSIS |
#include <wctype.h> |
wctype_t wctype(<[c]>) |
const char * <[c]>; |
DESCRIPTION |
<<wctype>> is a function which takes a string <[c]> and gives back |
the appropriate wctype_t type value associated with the string, |
if one exists. The following values are guaranteed to be recognized: |
"alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower", "print", |
"punct", "space", "upper", and "xdigit". |
RETURNS |
<<wctype>> returns 0 and sets <<errno>> to <<EINVAL>> if the |
given name is invalid. Otherwise, it returns a valid non-zero wctype_t |
value. |
PORTABILITY |
<<wctype>> is C99. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <string.h> |
#include <reent.h> |
#include <wctype.h> |
#include <errno.h> |
#include "local.h" |
wctype_t |
_DEFUN (_wctype_r, (r, c), |
struct _reent *r _AND |
const char *c) |
{ |
switch (*c) |
{ |
case 'a': |
if (!strcmp (c, "alnum")) |
return WC_ALNUM; |
else if (!strcmp (c, "alpha")) |
return WC_ALPHA; |
break; |
case 'b': |
if (!strcmp (c, "blank")) |
return WC_BLANK; |
break; |
case 'c': |
if (!strcmp (c, "cntrl")) |
return WC_CNTRL; |
break; |
case 'd': |
if (!strcmp (c, "digit")) |
return WC_DIGIT; |
break; |
case 'g': |
if (!strcmp (c, "graph")) |
return WC_GRAPH; |
break; |
case 'l': |
if (!strcmp (c, "lower")) |
return WC_LOWER; |
break; |
case 'p': |
if (!strcmp (c, "print")) |
return WC_PRINT; |
else if (!strcmp (c, "punct")) |
return WC_PUNCT; |
break; |
case 's': |
if (!strcmp (c, "space")) |
return WC_SPACE; |
break; |
case 'u': |
if (!strcmp (c, "upper")) |
return WC_UPPER; |
break; |
case 'x': |
if (!strcmp (c, "xdigit")) |
return WC_XDIGIT; |
break; |
} |
/* otherwise invalid */ |
r->_errno = EINVAL; |
return 0; |
} |
#ifndef _REENT_ONLY |
wctype_t |
_DEFUN (wctype, (c), |
const char *c) |
{ |
return _wctype_r (_REENT, c); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/dll.lds |
---|
0,0 → 1,118 |
OUTPUT_FORMAT(pei-i386) |
SECTIONS |
{ |
. = SIZEOF_HEADERS; |
. = ALIGN(__section_alignment__); |
.text __image_base__ + . : |
{ |
*(.text) |
*(SORT(.text$*)) |
*(.text.*) |
*(.gnu.linkonce.t.*) |
*(.glue_7t) |
*(.glue_7) |
___CTOR_LIST__ = .; __CTOR_LIST__ = . ; |
LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); |
___DTOR_LIST__ = .; __DTOR_LIST__ = . ; |
LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); |
*(.fini) |
. = ALIGN(16) ; |
___crt_xc_start__ = . ; |
*(SORT(.CRT$XC*)) /* C initialization */ |
___crt_xc_end__ = . ; |
___crt_xi_start__ = . ; |
*(SORT(.CRT$XI*)) /* C++ initialization */ |
___crt_xi_end__ = . ; |
___crt_xl_start__ = . ; |
*(SORT(.CRT$XL*)) /* TLS callbacks */ |
/* ___crt_xl_end__ is defined in the TLS Directory support code */ |
___crt_xp_start__ = . ; |
*(SORT(.CRT$XP*)) /* Pre-termination */ |
___crt_xp_end__ = . ; |
___crt_xt_start__ = . ; |
*(SORT(.CRT$XT*)) /* Termination */ |
___crt_xt_end__ = . ; |
. = ALIGN(16) ; |
*(.rdata) |
*(SORT(.rdata$*)) |
__rt_psrelocs_start = .; |
*(.rdata_runtime_pseudo_reloc) |
__rt_psrelocs_end = .; |
} |
__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start; |
___RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
__RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size; |
__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size; |
.data ALIGN(__section_alignment__): |
{ |
PROVIDE ( __data_start__ = .) ; |
*(.data) |
*(.data2) |
*(SORT(.data$*)) |
*(.jcr) |
__CRT_MT = .; |
LONG(0); |
PROVIDE ( __data_end__ = .) ; |
*(.data_cygwin_nocopy) |
} |
.bss ALIGN(__section_alignment__): |
{ |
__bss_start__ = . ; |
*(.bss) |
*(COMMON) |
__bss_end__ = . ; |
} |
.edata ALIGN(__section_alignment__): |
{ |
*(.edata) |
} |
/DISCARD/ : |
{ |
*(.debug$S) |
*(.debug$T) |
*(.debug$F) |
*(.drectve) |
*(.note.GNU-stack) |
*(.eh_frame) |
*(.comment) |
*(.debug_abbrev) |
*(.debug_info) |
*(.debug_line) |
*(.debug_frame) |
*(.debug_loc) |
*(.debug_pubnames) |
*(.debug_aranges) |
*(.debug_ranges) |
} |
.idata ALIGN(__section_alignment__): |
{ |
SORT(*)(.idata$2) |
SORT(*)(.idata$3) |
/* These zeroes mark the end of the import list. */ |
LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); |
SORT(*)(.idata$4) |
SORT(*)(.idata$5) |
SORT(*)(.idata$6) |
SORT(*)(.idata$7) |
} |
.reloc ALIGN(__section_alignment__) : |
{ |
*(.reloc) |
} |
} |
/contrib/sdk/sources/libc/errno/errno.c |
---|
0,0 → 1,16 |
/* The errno variable is stored in the reentrancy structure. This |
function returns its address for use by the macro errno defined in |
errno.h. */ |
#include <errno.h> |
#include <reent.h> |
#ifndef _REENT_ONLY |
int * |
__errno () |
{ |
return &_REENT->_errno; |
} |
#endif |
/contrib/sdk/sources/libc/libc.ver |
---|
0,0 → 1,188 |
LIBC { |
global: *; |
local: _PathLocale; |
__chkstk; |
__chkstk_ms; |
_alloca; |
__ChkTTYIOMode; |
__GetIOMode; |
__SetIOMode; |
__SetIOMode_nogrow; |
__allocPOSIXHandle; |
__any_on; |
__ascii_mbtowc; |
__ascii_wctomb; |
__b2d; |
__call_exitprocs; |
__copybits; |
__cpu_features_init; |
__ctype_load_locale; |
__d2b; |
__dorand48; |
__dtoa; |
__emutls_register_common; |
__fp_lock_all; |
__fp_unlock_all; |
__freePOSIXHandle; |
__getOSHandle; |
__get_current_ctype_locale; |
__gethex; |
__gettzinfo; |
__growPOSIXHandles; |
__grow_iomode; |
__gthread_once; |
__hexdig_init; |
__hexnan; |
__hi0bits; |
__i2b; |
__ieee754_acos; |
__ieee754_acosf; |
__ieee754_acosh; |
__ieee754_acoshf; |
__ieee754_asin; |
__ieee754_asinf; |
__ieee754_atan2; |
__ieee754_atan2f; |
__ieee754_atanh; |
__ieee754_atanhf; |
__ieee754_cosh; |
__ieee754_coshf; |
__ieee754_exp; |
__ieee754_expf; |
__ieee754_fmod; |
__ieee754_fmodf; |
__ieee754_gamma_r; |
__ieee754_gammaf_r; |
__ieee754_hypot; |
__ieee754_hypotf; |
__ieee754_j0; |
__ieee754_j0f; |
__ieee754_j1; |
__ieee754_j1f; |
__ieee754_jn; |
__ieee754_jnf; |
__ieee754_lgamma_r; |
__ieee754_lgammaf_r; |
__ieee754_log; |
__ieee754_log10; |
__ieee754_log10f; |
__ieee754_logf; |
__ieee754_pow; |
__ieee754_powf; |
__ieee754_rem_pio; |
__ieee754_rem_pio2f; |
__ieee754_remainder; |
__ieee754_remainderf; |
__ieee754_scalb; |
__ieee754_scalbf; |
__ieee754_sinh; |
__ieee754_sinhf; |
__ieee754_sqrt; |
__ieee754_sqrtf; |
__ieee754_y0; |
__ieee754_y0f; |
__ieee754_y1; |
__ieee754_y1f; |
__ieee754_yn; |
__ieee754_ynf; |
__infinity; |
__infinityf; |
__infinityld; |
__init_mode; |
__io_mode; |
__isinfd; |
__isinff; |
__isnand; |
__isnanf; |
__kernel_cos; |
__kernel_cosf; |
__kernel_rem_pio2; |
__kernel_rem_pio2f; |
__kernel_sin; |
__kernel_sinf; |
__kernel_standard; |
__kernel_tan; |
__kernel_tanf; |
__libc_getenv; |
__lo0bits; |
__locale_charset; |
__locale_cjk_lang; |
__locale_mb_cur_max; |
__locale_msgcharset; |
__lshift; |
__mb_cur_max; |
__mbtowc; |
__mcmp; |
__mdiff; |
__mlocale_changed; |
__mprec_bigtens; |
__mprec_tens; |
__mprec_tinytens; |
__multadd; |
__multiply; |
__nlocale_changed; |
__pow5mult; |
__ratio; |
__register_exitproc; |
__s2b; |
__sccl; |
__sclose; |
__seofread; |
__setOSHandle; |
__set_handles; |
__sflags; |
__sflush_r; |
__sfmoreglue; |
__sfp; |
__sfp_lock_acquire; |
__sfp_lock_release; |
__sfvwrite_r; |
__shrink_iomode; |
__sigtramp; |
__sigtramp_r; |
__sinit; |
__sinit_lock_acquire; |
__sinit_lock_release; |
__smakebuf_r; |
__sprint_r; |
__sread; |
__srefill_r; |
__srget; |
__sseek; |
__ssprint_r; |
__ssrefill_r; |
__ssvfiscanf_r; |
__ssvfscanf_r; |
__strtok_r; |
__submore; |
__svfiscanf; |
__svfiscanf_r; |
__svfscanf; |
__svfscanf_r; |
__swbuf; |
__swrite; |
__swsetup_r; |
__thread_startup; |
__tz_lock; |
__tz_unlock; |
__tzcalc_limits; |
__ulp; |
__wctomb; |
__NFiles; |
__NHandles; |
__OSHandles; |
__appcwd; |
__appcwdlen; |
__appenv; |
__appenv_size; |
__atexit_lock; |
__cpu_features; |
__fdlib_version; |
__hexdig; |
__ieee754_rem_pio2; |
__initPOSIXHandles; |
__malloc_lock; |
__malloc_unlock; |
_argc; |
_argv; |
}; |
/contrib/sdk/sources/libc/libcdll.lds |
---|
0,0 → 1,88 |
OUTPUT_FORMAT(pei-i386) |
ENTRY("_libc_crt_startup") |
SECTIONS |
{ |
. = SIZEOF_HEADERS; |
. = ALIGN(__section_alignment__); |
.text __image_base__ + . : |
{ |
*(.text) |
*(SORT(.text$*)) |
*(.text.*) |
*(.gnu.linkonce.t.*) |
*(.glue_7t) |
*(.glue_7) |
___CTOR_LIST__ = .; __CTOR_LIST__ = . ; |
LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); |
___DTOR_LIST__ = .; __DTOR_LIST__ = . ; |
LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); |
*(.fini) |
*(.rdata) |
*(SORT(.rdata$*)) |
__rt_psrelocs_start = .; |
*(.rdata_runtime_pseudo_reloc) |
__rt_psrelocs_end = .; |
__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start; |
___RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
__RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size; |
__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size; |
} |
.data ALIGN(__section_alignment__): |
{ |
PROVIDE ( __data_start__ = .) ; |
*(.data) |
*(.data2) |
*(SORT(.data$*)) |
*(.jcr) |
__CRT_MT = .; |
LONG(0); |
PROVIDE ( __data_end__ = .) ; |
*(.data_cygwin_nocopy) |
} |
.bss ALIGN(__section_alignment__): |
{ |
__bss_start__ = . ; |
*(.bss) |
*(COMMON) |
__bss_end__ = . ; |
} |
.edata ALIGN(__section_alignment__): |
{ |
*(.edata) |
} |
/DISCARD/ : |
{ |
*(.debug$S) |
*(.debug$T) |
*(.debug$F) |
*(.drectve) |
*(.note.GNU-stack) |
*(.eh_frame) |
*(.comment) |
*(.debug_abbrev) |
*(.debug_info) |
*(.debug_line) |
*(.debug_frame) |
*(.debug_loc) |
*(.debug_pubnames) |
*(.debug_aranges) |
*(.debug_ranges) |
} |
.reloc ALIGN(__section_alignment__) : |
{ |
*(.reloc) |
} |
} |
/contrib/sdk/sources/libc/locale/lctype.c |
---|
0,0 → 1,111 |
/* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <limits.h> |
#include <string.h> |
#include "lctype.h" |
#include "ldpart.h" |
#include "setlocale.h" |
#define LCCTYPE_SIZE (sizeof(struct lc_ctype_T) / sizeof(char *)) |
static char numone[] = { '\1', '\0'}; |
static const struct lc_ctype_T _C_ctype_locale = { |
"ASCII", /* codeset */ |
numone /* mb_cur_max */ |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
, |
{ "0", "1", "2", "3", "4", /* outdigits */ |
"5", "6", "7", "8", "9" }, |
{ L"0", L"1", L"2", L"3", L"4", /* woutdigits */ |
L"5", L"6", L"7", L"8", L"9" } |
#endif |
}; |
static struct lc_ctype_T _ctype_locale; |
static int _ctype_using_locale; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
static char *_ctype_locale_buf; |
#else |
/* Max encoding_len + NUL byte + 1 byte mb_cur_max plus trailing NUL byte */ |
#define _CTYPE_BUF_SIZE (ENCODING_LEN + 3) |
static char _ctype_locale_buf[_CTYPE_BUF_SIZE]; |
#endif |
int |
__ctype_load_locale(const char *name, void *f_wctomb, const char *charset, |
int mb_cur_max) |
{ |
int ret; |
#ifdef __CYGWIN__ |
extern int __set_lc_ctype_from_win (const char *, |
const struct lc_ctype_T *, |
struct lc_ctype_T *, char **, |
void *, const char *, int); |
int old_ctype_using_locale = _ctype_using_locale; |
_ctype_using_locale = 0; |
ret = __set_lc_ctype_from_win (name, &_C_ctype_locale, &_ctype_locale, |
&_ctype_locale_buf, f_wctomb, charset, |
mb_cur_max); |
/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ |
if (ret < 0) |
_ctype_using_locale = old_ctype_using_locale; |
else |
{ |
_ctype_using_locale = ret; |
ret = 0; |
} |
#elif !defined (__HAVE_LOCALE_INFO_EXTENDED__) |
if (!strcmp (name, "C")) |
_ctype_using_locale = 0; |
else |
{ |
_ctype_locale.codeset = strcpy (_ctype_locale_buf, charset); |
char *mbc = _ctype_locale_buf + _CTYPE_BUF_SIZE - 2; |
mbc[0] = mb_cur_max; |
mbc[1] = '\0'; |
_ctype_locale.mb_cur_max = mbc; |
_ctype_using_locale = 1; |
} |
ret = 0; |
#else |
ret = __part_load_locale(name, &_ctype_using_locale, |
_ctype_locale_buf, "LC_CTYPE", |
LCCTYPE_SIZE, LCCTYPE_SIZE, |
(const char **)&_ctype_locale); |
if (ret == 0 && _ctype_using_locale) |
_ctype_locale.grouping = |
__fix_locale_grouping_str(_ctype_locale.grouping); |
#endif |
return ret; |
} |
struct lc_ctype_T * |
__get_current_ctype_locale(void) { |
return (_ctype_using_locale |
? &_ctype_locale |
: (struct lc_ctype_T *)&_C_ctype_locale); |
} |
/contrib/sdk/sources/libc/locale/lctype.h |
---|
0,0 → 1,47 |
/* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#ifndef _LCTYPE_H_ |
#define _LCTYPE_H_ |
#include <_ansi.h> |
#include <sys/cdefs.h> |
#include <wchar.h> |
__BEGIN_DECLS |
struct lc_ctype_T { |
const char *codeset; /* codeset for mbtowc conversion */ |
const char *mb_cur_max; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
const char *outdigits[10]; |
const wchar_t *woutdigits[10]; |
#endif |
}; |
struct lc_ctype_T *__get_current_ctype_locale(void); |
int __ctype_load_locale(const char *, void *, const char *, int); |
__END_DECLS |
#endif /* !_LCTYPE_H_ */ |
/contrib/sdk/sources/libc/locale/ldpart.h |
---|
0,0 → 1,35 |
/*- |
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/locale/ldpart.h,v 1.4 2001/12/20 18:28:52 phantom Exp $ |
*/ |
#ifndef _LDPART_H_ |
#define _LDPART_H_ |
int __part_load_locale(const char *, int*, char *, const char *, |
int, int, const char **); |
#endif /* !_LDPART_H_ */ |
/contrib/sdk/sources/libc/locale/lmessages.h |
---|
0,0 → 1,57 |
/*- |
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/locale/lmessages.h,v 1.3 2001/12/20 18:28:52 phantom Exp $ |
*/ |
#ifndef _LMESSAGES_H_ |
#define _LMESSAGES_H_ |
#include <_ansi.h> |
#include <sys/cdefs.h> |
#include <wchar.h> |
__BEGIN_DECLS |
struct lc_messages_T { |
const char *yesexpr; |
const char *noexpr; |
const char *yesstr; |
const char *nostr; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
const char *codeset; /* codeset for mbtowc conversion */ |
const wchar_t *wyesexpr; |
const wchar_t *wnoexpr; |
const wchar_t *wyesstr; |
const wchar_t *wnostr; |
#endif |
}; |
struct lc_messages_T *__get_current_messages_locale(void); |
int __messages_load_locale(const char *, void *, const char *); |
__END_DECLS |
#endif /* !_LMESSAGES_H_ */ |
/contrib/sdk/sources/libc/locale/lmonetary.h |
---|
0,0 → 1,76 |
/*- |
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/locale/lmonetary.h,v 1.3 2001/12/20 18:28:52 phantom Exp $ |
*/ |
#ifndef _LMONETARY_H_ |
#define _LMONETARY_H_ |
#include <_ansi.h> |
#include <sys/cdefs.h> |
#include <wchar.h> |
__BEGIN_DECLS |
struct lc_monetary_T { |
const char *int_curr_symbol; |
const char *currency_symbol; |
const char *mon_decimal_point; |
const char *mon_thousands_sep; |
const char *mon_grouping; |
const char *positive_sign; |
const char *negative_sign; |
const char *int_frac_digits; |
const char *frac_digits; |
const char *p_cs_precedes; |
const char *p_sep_by_space; |
const char *n_cs_precedes; |
const char *n_sep_by_space; |
const char *p_sign_posn; |
const char *n_sign_posn; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
const char *int_p_cs_precedes; |
const char *int_p_sep_by_space; |
const char *int_n_cs_precedes; |
const char *int_n_sep_by_space; |
const char *int_p_sign_posn; |
const char *int_n_sign_posn; |
const char *codeset; /* codeset for mbtowc conversion */ |
const wchar_t *wint_curr_symbol; |
const wchar_t *wcurrency_symbol; |
const wchar_t *wmon_decimal_point; |
const wchar_t *wmon_thousands_sep; |
const wchar_t *wpositive_sign; |
const wchar_t *wnegative_sign; |
#endif |
}; |
struct lc_monetary_T *__get_current_monetary_locale(void); |
int __monetary_load_locale(const char *, void *, const char *); |
__END_DECLS |
#endif /* !_LMONETARY_H_ */ |
/contrib/sdk/sources/libc/locale/lnumeric.h |
---|
0,0 → 1,54 |
/*- |
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/locale/lnumeric.h,v 1.3 2001/12/20 18:28:52 phantom Exp $ |
*/ |
#ifndef _LNUMERIC_H_ |
#define _LNUMERIC_H_ |
#include <_ansi.h> |
#include <sys/cdefs.h> |
#include <wchar.h> |
__BEGIN_DECLS |
struct lc_numeric_T { |
const char *decimal_point; |
const char *thousands_sep; |
const char *grouping; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
const char *codeset; /* codeset for mbtowc conversion */ |
const wchar_t *wdecimal_point; |
const wchar_t *wthousands_sep; |
#endif |
}; |
struct lc_numeric_T *__get_current_numeric_locale(void); |
int __numeric_load_locale(const char *, void *, const char *); |
__END_DECLS |
#endif /* !_LNUMERIC_H_ */ |
/contrib/sdk/sources/libc/locale/locale.c |
---|
0,0 → 1,1039 |
/* |
FUNCTION |
<<setlocale>>, <<localeconv>>---select or query locale |
INDEX |
setlocale |
INDEX |
localeconv |
INDEX |
_setlocale_r |
INDEX |
_localeconv_r |
ANSI_SYNOPSIS |
#include <locale.h> |
char *setlocale(int <[category]>, const char *<[locale]>); |
lconv *localeconv(void); |
char *_setlocale_r(void *<[reent]>, |
int <[category]>, const char *<[locale]>); |
lconv *_localeconv_r(void *<[reent]>); |
TRAD_SYNOPSIS |
#include <locale.h> |
char *setlocale(<[category]>, <[locale]>) |
int <[category]>; |
char *<[locale]>; |
lconv *localeconv(); |
char *_setlocale_r(<[reent]>, <[category]>, <[locale]>) |
char *<[reent]>; |
int <[category]>; |
char *<[locale]>; |
lconv *_localeconv_r(<[reent]>); |
char *<[reent]>; |
DESCRIPTION |
<<setlocale>> is the facility defined by ANSI C to condition the |
execution environment for international collating and formatting |
information; <<localeconv>> reports on the settings of the current |
locale. |
This is a minimal implementation, supporting only the required <<"POSIX">> |
and <<"C">> values for <[locale]>; strings representing other locales are not |
honored unless _MB_CAPABLE is defined. |
If _MB_CAPABLE is defined, POSIX locale strings are allowed, following |
the form |
language[_TERRITORY][.charset][@@modifier] |
<<"language">> is a two character string per ISO 639, or, if not available |
for a given language, a three character string per ISO 639-3. |
<<"TERRITORY">> is a country code per ISO 3166. For <<"charset">> and |
<<"modifier">> see below. |
Additionally to the POSIX specifier, the following extension is supported |
for backward compatibility with older implementations using newlib: |
<<"C-charset">>. |
Instead of <<"C-">>, you can also specify <<"C.">>. Both variations allow |
to specify language neutral locales while using other charsets than ASCII, |
for instance <<"C.UTF-8">>, which keeps all settings as in the C locale, |
but uses the UTF-8 charset. |
The following charsets are recognized: |
<<"UTF-8">>, <<"JIS">>, <<"EUCJP">>, <<"SJIS">>, <<"KOI8-R">>, <<"KOI8-U">>, |
<<"GEORGIAN-PS">>, <<"PT154">>, <<"TIS-620">>, <<"ISO-8859-x">> with |
1 <= x <= 16, or <<"CPxxx">> with xxx in [437, 720, 737, 775, 850, 852, 855, |
857, 858, 862, 866, 874, 932, 1125, 1250, 1251, 1252, 1253, 1254, 1255, 1256, |
1257, 1258]. |
Charsets are case insensitive. For instance, <<"EUCJP">> and <<"eucJP">> |
are equivalent. Charset names with dashes can also be written without |
dashes, as in <<"UTF8">>, <<"iso88591">> or <<"koi8r">>. <<"EUCJP">> and |
<<"EUCKR">> are also recognized with dash, <<"EUC-JP">> and <<"EUC-KR">>. |
Full support for all of the above charsets requires that newlib has been |
build with multibyte support and support for all ISO and Windows Codepage. |
Otherwise all singlebyte charsets are simply mapped to ASCII. Right now, |
only newlib for Cygwin is built with full charset support by default. |
Under Cygwin, this implementation additionally supports the charsets |
<<"GBK">>, <<"GB2312">>, <<"eucCN">>, <<"eucKR">>, and <<"Big5">>. Cygwin |
does not support <<"JIS">>. |
Cygwin additionally supports locales from the file |
/usr/share/locale/locale.alias. |
(<<"">> is also accepted; if given, the settings are read from the |
corresponding LC_* environment variables and $LANG according to POSIX rules. |
This implementation also supports the modifier <<"cjknarrow">>, which |
affects how the functions <<wcwidth>> and <<wcswidth>> handle characters |
from the "CJK Ambiguous Width" category of characters described at |
http://www.unicode.org/reports/tr11/#Ambiguous. These characters have a width |
of 1 for singlebyte charsets and a width of 2 for multibyte charsets |
other than UTF-8. For UTF-8, their width depends on the language specifier: |
it is 2 for <<"zh">> (Chinese), <<"ja">> (Japanese), and <<"ko">> (Korean), |
and 1 for everything else. Specifying <<"cjknarrow">> forces a width of 1, |
independent of charset and language. |
If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns a |
pointer to the string representing the current locale. The acceptable |
values for <[category]> are defined in `<<locale.h>>' as macros |
beginning with <<"LC_">>. |
<<localeconv>> returns a pointer to a structure (also defined in |
`<<locale.h>>') describing the locale-specific conventions currently |
in effect. |
<<_localeconv_r>> and <<_setlocale_r>> are reentrant versions of |
<<localeconv>> and <<setlocale>> respectively. The extra argument |
<[reent]> is a pointer to a reentrancy structure. |
RETURNS |
A successful call to <<setlocale>> returns a pointer to a string |
associated with the specified category for the new locale. The string |
returned by <<setlocale>> is such that a subsequent call using that |
string will restore that category (or all categories in case of LC_ALL), |
to that state. The application shall not modify the string returned |
which may be overwritten by a subsequent call to <<setlocale>>. |
On error, <<setlocale>> returns <<NULL>>. |
<<localeconv>> returns a pointer to a structure of type <<lconv>>, |
which describes the formatting and collating conventions in effect (in |
this implementation, always those of the C locale). |
PORTABILITY |
ANSI C requires <<setlocale>>, but the only locale required across all |
implementations is the C locale. |
NOTES |
There is no ISO-8859-12 codepage. It's also refused by this implementation. |
No supporting OS subroutines are required. |
*/ |
/* Parts of this code are originally taken from FreeBSD. */ |
/* |
* Copyright (c) 1996 - 2002 FreeBSD Project |
* Copyright (c) 1991, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Paul Borman at Krystal Technologies. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <newlib.h> |
#include <errno.h> |
#include <locale.h> |
#include <string.h> |
#include <limits.h> |
#include <reent.h> |
#include <stdlib.h> |
#include <wchar.h> |
#include "lmessages.h" |
#include "lmonetary.h" |
#include "lnumeric.h" |
#include "lctype.h" |
#include "timelocal.h" |
#include "../stdlib/local.h" |
#define _LC_LAST 7 |
#define ENCODING_LEN 31 |
int __EXPORT __mb_cur_max = 1; |
int __nlocale_changed = 0; |
int __mlocale_changed = 0; |
char *_PathLocale = NULL; |
static |
struct lconv lconv = |
{ |
".", "", "", "", "", "", "", "", "", "", |
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, |
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, |
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, |
CHAR_MAX, CHAR_MAX |
}; |
#ifdef _MB_CAPABLE |
/* |
* Category names for getenv() |
*/ |
static char *categories[_LC_LAST] = { |
"LC_ALL", |
"LC_COLLATE", |
"LC_CTYPE", |
"LC_MONETARY", |
"LC_NUMERIC", |
"LC_TIME", |
"LC_MESSAGES", |
}; |
/* |
* Default locale per POSIX. Can be overridden on a per-target base. |
*/ |
#ifndef DEFAULT_LOCALE |
#define DEFAULT_LOCALE "C" |
#endif |
/* |
* This variable can be changed by any outside mechanism. This allows, |
* for instance, to load the default locale from a file. |
*/ |
char __default_locale[ENCODING_LEN + 1] = DEFAULT_LOCALE; |
/* |
* Current locales for each category |
*/ |
static char current_categories[_LC_LAST][ENCODING_LEN + 1] = { |
"C", |
"C", |
#ifdef __CYGWIN__ /* Cygwin starts with LC_CTYPE set to "C.UTF-8". */ |
"C.UTF-8", |
#else |
"C", |
#endif |
"C", |
"C", |
"C", |
"C", |
}; |
/* |
* The locales we are going to try and load |
*/ |
static char new_categories[_LC_LAST][ENCODING_LEN + 1]; |
static char saved_categories[_LC_LAST][ENCODING_LEN + 1]; |
static char current_locale_string[_LC_LAST * (ENCODING_LEN + 1/*"/"*/ + 1)]; |
static char *currentlocale(void); |
static char *loadlocale(struct _reent *, int); |
static const char *__get_locale_env(struct _reent *, int); |
#endif /* _MB_CAPABLE */ |
#ifdef __CYGWIN__ |
static char lc_ctype_charset[ENCODING_LEN + 1] = "UTF-8"; |
#else |
static char lc_ctype_charset[ENCODING_LEN + 1] = "ASCII"; |
#endif |
static char lc_message_charset[ENCODING_LEN + 1] = "ASCII"; |
static int lc_ctype_cjk_lang = 0; |
char * |
_DEFUN(_setlocale_r, (p, category, locale), |
struct _reent *p _AND |
int category _AND |
_CONST char *locale) |
{ |
#ifndef _MB_CAPABLE |
if (locale) |
{ |
if (strcmp (locale, "POSIX") && strcmp (locale, "C") |
&& strcmp (locale, "")) |
return NULL; |
} |
return "C"; |
#else /* !_MB_CAPABLE */ |
int i, j, len, saverr; |
const char *env, *r; |
if (category < LC_ALL || category >= _LC_LAST) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
if (locale == NULL) |
return category != LC_ALL ? current_categories[category] : currentlocale(); |
/* |
* Default to the current locale for everything. |
*/ |
for (i = 1; i < _LC_LAST; ++i) |
strcpy (new_categories[i], current_categories[i]); |
/* |
* Now go fill up new_categories from the locale argument |
*/ |
if (!*locale) |
{ |
if (category == LC_ALL) |
{ |
for (i = 1; i < _LC_LAST; ++i) |
{ |
env = __get_locale_env (p, i); |
if (strlen (env) > ENCODING_LEN) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
strcpy (new_categories[i], env); |
} |
} |
else |
{ |
env = __get_locale_env (p, category); |
if (strlen (env) > ENCODING_LEN) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
strcpy (new_categories[category], env); |
} |
} |
else if (category != LC_ALL) |
{ |
if (strlen (locale) > ENCODING_LEN) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
strcpy (new_categories[category], locale); |
} |
else |
{ |
if ((r = strchr (locale, '/')) == NULL) |
{ |
if (strlen (locale) > ENCODING_LEN) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
for (i = 1; i < _LC_LAST; ++i) |
strcpy (new_categories[i], locale); |
} |
else |
{ |
for (i = 1; r[1] == '/'; ++r) |
; |
if (!r[1]) |
{ |
p->_errno = EINVAL; |
return NULL; /* Hmm, just slashes... */ |
} |
do |
{ |
if (i == _LC_LAST) |
break; /* Too many slashes... */ |
if ((len = r - locale) > ENCODING_LEN) |
{ |
p->_errno = EINVAL; |
return NULL; |
} |
strlcpy (new_categories[i], locale, len + 1); |
i++; |
while (*r == '/') |
r++; |
locale = r; |
while (*r && *r != '/') |
r++; |
} |
while (*locale); |
while (i < _LC_LAST) |
{ |
strcpy (new_categories[i], new_categories[i-1]); |
i++; |
} |
} |
} |
if (category != LC_ALL) |
return loadlocale (p, category); |
for (i = 1; i < _LC_LAST; ++i) |
{ |
strcpy (saved_categories[i], current_categories[i]); |
if (loadlocale (p, i) == NULL) |
{ |
saverr = p->_errno; |
for (j = 1; j < i; j++) |
{ |
strcpy (new_categories[j], saved_categories[j]); |
if (loadlocale (p, j) == NULL) |
{ |
strcpy (new_categories[j], "C"); |
loadlocale (p, j); |
} |
} |
p->_errno = saverr; |
return NULL; |
} |
} |
return currentlocale (); |
#endif /* !_MB_CAPABLE */ |
} |
#ifdef _MB_CAPABLE |
static char * |
currentlocale() |
{ |
int i; |
(void)strcpy(current_locale_string, current_categories[1]); |
for (i = 2; i < _LC_LAST; ++i) |
if (strcmp(current_categories[1], current_categories[i])) { |
for (i = 2; i < _LC_LAST; ++i) { |
(void)strcat(current_locale_string, "/"); |
(void)strcat(current_locale_string, |
current_categories[i]); |
} |
break; |
} |
return (current_locale_string); |
} |
#endif /* _MB_CAPABLE */ |
#ifdef _MB_CAPABLE |
#ifdef __CYGWIN__ |
extern void __set_charset_from_locale (const char *locale, char *charset); |
extern char *__set_locale_from_locale_alias (const char *, char *); |
extern int __collate_load_locale (const char *, void *, const char *); |
#endif /* __CYGWIN__ */ |
extern void __set_ctype (const char *charset); |
static char * |
loadlocale(struct _reent *p, int category) |
{ |
/* At this point a full-featured system would just load the locale |
specific data from the locale files. |
What we do here for now is to check the incoming string for correctness. |
The string must be in one of the allowed locale strings, either |
one in POSIX-style, or one in the old newlib style to maintain |
backward compatibility. If the local string is correct, the charset |
is extracted and stored in lc_ctype_charset or lc_message_charset |
dependent on the cateogry. */ |
char *locale = NULL; |
char charset[ENCODING_LEN + 1]; |
unsigned long val; |
char *end, *c = NULL; |
int mbc_max; |
int (*l_wctomb) (struct _reent *, char *, wchar_t, const char *, mbstate_t *); |
int (*l_mbtowc) (struct _reent *, wchar_t *, const char *, size_t, |
const char *, mbstate_t *); |
int cjknarrow = 0; |
/* Avoid doing everything twice if nothing has changed. */ |
if (!strcmp (new_categories[category], current_categories[category])) |
return current_categories[category]; |
#ifdef __CYGWIN__ |
/* This additional code handles the case that the incoming locale string |
is not valid. If so, it calls the function __set_locale_from_locale_alias, |
which is only available on Cygwin right now. The function reads the |
file /usr/share/locale/locale.alias. The file contains locale aliases |
and their replacement locale. For instance, the alias "french" is |
translated to "fr_FR.ISO-8859-1", the alias "thai" is translated to |
"th_TH.TIS-620". If successful, the function returns with a pointer |
to the second argument, which is a buffer in which the replacement locale |
gets stored. Otherwise the function returns NULL. */ |
char tmp_locale[ENCODING_LEN + 1]; |
int ret = 0; |
restart: |
if (!locale) |
locale = new_categories[category]; |
else if (locale != tmp_locale) |
{ |
locale = __set_locale_from_locale_alias (locale, tmp_locale); |
if (!locale) |
return NULL; |
} |
# define FAIL goto restart |
#else |
locale = new_categories[category]; |
# define FAIL return NULL |
#endif |
/* "POSIX" is translated to "C", as on Linux. */ |
if (!strcmp (locale, "POSIX")) |
strcpy (locale, "C"); |
if (!strcmp (locale, "C")) /* Default "C" locale */ |
strcpy (charset, "ASCII"); |
else if (locale[0] == 'C' |
&& (locale[1] == '-' /* Old newlib style */ |
|| locale[1] == '.')) /* Extension for the C locale to allow |
specifying different charsets while |
sticking to the C locale in terms |
of sort order, etc. Proposed in |
the Debian project. */ |
{ |
char *chp; |
c = locale + 2; |
strcpy (charset, c); |
if ((chp = strchr (charset, '@'))) |
/* Strip off modifier */ |
*chp = '\0'; |
c += strlen (charset); |
} |
else /* POSIX style */ |
{ |
c = locale; |
/* Don't use ctype macros here, they might be localized. */ |
/* Language */ |
if (c[0] < 'a' || c[0] > 'z' |
|| c[1] < 'a' || c[1] > 'z') |
FAIL; |
c += 2; |
/* Allow three character Language per ISO 639-3 */ |
if (c[0] >= 'a' && c[0] <= 'z') |
++c; |
if (c[0] == '_') |
{ |
/* Territory */ |
++c; |
if (c[0] < 'A' || c[0] > 'Z' |
|| c[1] < 'A' || c[1] > 'Z') |
FAIL; |
c += 2; |
} |
if (c[0] == '.') |
{ |
/* Charset */ |
char *chp; |
++c; |
strcpy (charset, c); |
if ((chp = strchr (charset, '@'))) |
/* Strip off modifier */ |
*chp = '\0'; |
c += strlen (charset); |
} |
else if (c[0] == '\0' || c[0] == '@') |
/* End of string or just a modifier */ |
#ifdef __CYGWIN__ |
/* The Cygwin-only function __set_charset_from_locale checks |
for the default charset which is connected to the given locale. |
The function uses Windows functions in turn so it can't be easily |
adapted to other targets. However, if any other target provides |
equivalent functionality, preferrably using the same function name |
it would be sufficient to change the guarding #ifdef. */ |
__set_charset_from_locale (locale, charset); |
#else |
strcpy (charset, "ISO-8859-1"); |
#endif |
else |
/* Invalid string */ |
FAIL; |
} |
if (c && c[0] == '@') |
{ |
/* Modifier */ |
/* Only one modifier is recognized right now. "cjknarrow" is used |
to modify the behaviour of wcwidth() for East Asian languages. |
For details see the comment at the end of this function. */ |
if (!strcmp (c + 1, "cjknarrow")) |
cjknarrow = 1; |
} |
/* We only support this subset of charsets. */ |
switch (charset[0]) |
{ |
case 'U': |
case 'u': |
if (strcasecmp (charset, "UTF-8") && strcasecmp (charset, "UTF8")) |
FAIL; |
strcpy (charset, "UTF-8"); |
mbc_max = 6; |
l_wctomb = __utf8_wctomb; |
l_mbtowc = __utf8_mbtowc; |
break; |
#ifndef __CYGWIN__ |
/* Cygwin does not support JIS at all. */ |
case 'J': |
case 'j': |
if (strcasecmp (charset, "JIS")) |
FAIL; |
strcpy (charset, "JIS"); |
mbc_max = 8; |
l_wctomb = __jis_wctomb; |
l_mbtowc = __jis_mbtowc; |
break; |
#endif /* !__CYGWIN__ */ |
case 'E': |
case 'e': |
if (strncasecmp (charset, "EUC", 3)) |
FAIL; |
c = charset + 3; |
if (*c == '-') |
++c; |
if (!strcasecmp (c, "JP")) |
{ |
strcpy (charset, "EUCJP"); |
mbc_max = 3; |
l_wctomb = __eucjp_wctomb; |
l_mbtowc = __eucjp_mbtowc; |
} |
#ifdef __CYGWIN__ |
/* Newlib does neither provide EUC-KR nor EUC-CN, and Cygwin's |
implementation requires Windows support. */ |
else if (!strcasecmp (c, "KR")) |
{ |
strcpy (charset, "EUCKR"); |
mbc_max = 2; |
l_wctomb = __kr_wctomb; |
l_mbtowc = __kr_mbtowc; |
} |
else if (!strcasecmp (c, "CN")) |
{ |
strcpy (charset, "EUCCN"); |
mbc_max = 2; |
l_wctomb = __gbk_wctomb; |
l_mbtowc = __gbk_mbtowc; |
} |
#endif /* __CYGWIN__ */ |
else |
FAIL; |
break; |
case 'S': |
case 's': |
if (strcasecmp (charset, "SJIS")) |
FAIL; |
strcpy (charset, "SJIS"); |
mbc_max = 2; |
l_wctomb = __sjis_wctomb; |
l_mbtowc = __sjis_mbtowc; |
break; |
case 'I': |
case 'i': |
/* Must be exactly one of ISO-8859-1, [...] ISO-8859-16, except for |
ISO-8859-12. This code also recognizes the aliases without dashes. */ |
if (strncasecmp (charset, "ISO", 3)) |
FAIL; |
c = charset + 3; |
if (*c == '-') |
++c; |
if (strncasecmp (c, "8859", 4)) |
FAIL; |
c += 4; |
if (*c == '-') |
++c; |
val = _strtol_r (p, c, &end, 10); |
if (val < 1 || val > 16 || val == 12 || *end) |
FAIL; |
strcpy (charset, "ISO-8859-"); |
c = charset + 9; |
if (val > 10) |
*c++ = '1'; |
*c++ = val % 10 + '0'; |
*c = '\0'; |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_ISO |
l_wctomb = __iso_wctomb; |
l_mbtowc = __iso_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_ISO */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_ISO */ |
break; |
case 'C': |
case 'c': |
if (charset[1] != 'P' && charset[1] != 'p') |
FAIL; |
strncpy (charset, "CP", 2); |
val = _strtol_r (p, charset + 2, &end, 10); |
if (*end) |
FAIL; |
switch (val) |
{ |
case 437: |
case 720: |
case 737: |
case 775: |
case 850: |
case 852: |
case 855: |
case 857: |
case 858: |
case 862: |
case 866: |
case 874: |
case 1125: |
case 1250: |
case 1251: |
case 1252: |
case 1253: |
case 1254: |
case 1255: |
case 1256: |
case 1257: |
case 1258: |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
l_wctomb = __cp_wctomb; |
l_mbtowc = __cp_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
break; |
case 932: |
mbc_max = 2; |
l_wctomb = __sjis_wctomb; |
l_mbtowc = __sjis_mbtowc; |
break; |
default: |
FAIL; |
} |
break; |
case 'K': |
case 'k': |
/* KOI8-R, KOI8-U and the aliases without dash */ |
if (strncasecmp (charset, "KOI8", 4)) |
FAIL; |
c = charset + 4; |
if (*c == '-') |
++c; |
if (*c == 'R' || *c == 'r') |
strcpy (charset, "CP20866"); |
else if (*c == 'U' || *c == 'u') |
strcpy (charset, "CP21866"); |
else |
FAIL; |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
l_wctomb = __cp_wctomb; |
l_mbtowc = __cp_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
break; |
case 'A': |
case 'a': |
if (strcasecmp (charset, "ASCII")) |
FAIL; |
strcpy (charset, "ASCII"); |
mbc_max = 1; |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
break; |
case 'G': |
case 'g': |
#ifdef __CYGWIN__ |
/* Newlib does not provide GBK/GB2312 and Cygwin's implementation |
requires Windows support. */ |
if (!strcasecmp (charset, "GBK") |
|| !strcasecmp (charset, "GB2312")) |
{ |
strcpy (charset, charset[2] == '2' ? "GB2312" : "GBK"); |
mbc_max = 2; |
l_wctomb = __gbk_wctomb; |
l_mbtowc = __gbk_mbtowc; |
} |
else |
#endif /* __CYGWIN__ */ |
/* GEORGIAN-PS and the alias without dash */ |
if (!strncasecmp (charset, "GEORGIAN", 8)) |
{ |
c = charset + 8; |
if (*c == '-') |
++c; |
if (strcasecmp (c, "PS")) |
FAIL; |
strcpy (charset, "CP101"); |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
l_wctomb = __cp_wctomb; |
l_mbtowc = __cp_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
} |
else |
FAIL; |
break; |
case 'P': |
case 'p': |
/* PT154 */ |
if (strcasecmp (charset, "PT154")) |
FAIL; |
strcpy (charset, "CP102"); |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
l_wctomb = __cp_wctomb; |
l_mbtowc = __cp_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
break; |
case 'T': |
case 't': |
if (strncasecmp (charset, "TIS", 3)) |
FAIL; |
c = charset + 3; |
if (*c == '-') |
++c; |
if (strcasecmp (c, "620")) |
FAIL; |
strcpy (charset, "CP874"); |
mbc_max = 1; |
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS |
l_wctomb = __cp_wctomb; |
l_mbtowc = __cp_mbtowc; |
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */ |
l_wctomb = __ascii_wctomb; |
l_mbtowc = __ascii_mbtowc; |
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */ |
break; |
#ifdef __CYGWIN__ |
/* Newlib does not provide Big5 and Cygwin's implementation |
requires Windows support. */ |
case 'B': |
case 'b': |
if (strcasecmp (charset, "BIG5")) |
FAIL; |
strcpy (charset, "BIG5"); |
mbc_max = 2; |
l_wctomb = __big5_wctomb; |
l_mbtowc = __big5_mbtowc; |
break; |
#endif /* __CYGWIN__ */ |
default: |
FAIL; |
} |
switch (category) |
{ |
case LC_CTYPE: |
strcpy (lc_ctype_charset, charset); |
__mb_cur_max = mbc_max; |
__wctomb = l_wctomb; |
__mbtowc = l_mbtowc; |
__set_ctype (charset); |
/* Determine the width for the "CJK Ambiguous Width" category of |
characters. This is used in wcwidth(). Assume single width for |
single-byte charsets, and double width for multi-byte charsets |
other than UTF-8. For UTF-8, use double width for the East Asian |
languages ("ja", "ko", "zh"), and single width for everything else. |
Single width can also be forced with the "@cjknarrow" modifier. */ |
lc_ctype_cjk_lang = !cjknarrow |
&& mbc_max > 1 |
&& (charset[0] != 'U' |
|| strncmp (locale, "ja", 2) == 0 |
|| strncmp (locale, "ko", 2) == 0 |
|| strncmp (locale, "zh", 2) == 0); |
#ifdef __HAVE_LOCALE_INFO__ |
ret = __ctype_load_locale (locale, (void *) l_wctomb, charset, mbc_max); |
#endif /* __HAVE_LOCALE_INFO__ */ |
break; |
case LC_MESSAGES: |
strcpy (lc_message_charset, charset); |
#ifdef __HAVE_LOCALE_INFO__ |
ret = __messages_load_locale (locale, (void *) l_wctomb, charset); |
if (!ret) |
#endif /* __HAVE_LOCALE_INFO__ */ |
break; |
#ifdef __HAVE_LOCALE_INFO__ |
#ifdef __CYGWIN__ |
/* Right now only Cygwin supports a __collate_load_locale function at all. */ |
case LC_COLLATE: |
ret = __collate_load_locale (locale, (void *) l_mbtowc, charset); |
break; |
#endif |
case LC_MONETARY: |
ret = __monetary_load_locale (locale, (void *) l_wctomb, charset); |
break; |
case LC_NUMERIC: |
ret = __numeric_load_locale (locale, (void *) l_wctomb, charset); |
break; |
case LC_TIME: |
ret = __time_load_locale (locale, (void *) l_wctomb, charset); |
break; |
#endif /* __HAVE_LOCALE_INFO__ */ |
default: |
break; |
} |
#ifdef __HAVE_LOCALE_INFO__ |
if (ret) |
FAIL; |
#endif /* __HAVE_LOCALE_INFO__ */ |
return strcpy(current_categories[category], new_categories[category]); |
} |
static const char * |
__get_locale_env(struct _reent *p, int category) |
{ |
const char *env; |
/* 1. check LC_ALL. */ |
env = _getenv_r (p, categories[0]); |
/* 2. check LC_* */ |
if (env == NULL || !*env) |
env = _getenv_r (p, categories[category]); |
/* 3. check LANG */ |
if (env == NULL || !*env) |
env = _getenv_r (p, "LANG"); |
/* 4. if none is set, fall to default locale */ |
if (env == NULL || !*env) |
env = __default_locale; |
return env; |
} |
#endif /* _MB_CAPABLE */ |
char * |
_DEFUN_VOID(__locale_charset) |
{ |
#if 0//def __HAVE_LOCALE_INFO__ |
return __get_current_ctype_locale ()->codeset; |
#else |
return lc_ctype_charset; |
#endif |
} |
int |
_DEFUN_VOID(__locale_mb_cur_max) |
{ |
#if 0//def __HAVE_LOCALE_INFO__ |
return __get_current_ctype_locale ()->mb_cur_max[0]; |
#else |
return __mb_cur_max; |
#endif |
} |
char * |
_DEFUN_VOID(__locale_msgcharset) |
{ |
#ifdef __HAVE_LOCALE_INFO__ |
return (char *) __get_current_messages_locale ()->codeset; |
#else |
return lc_message_charset; |
#endif |
} |
int |
_DEFUN_VOID(__locale_cjk_lang) |
{ |
return lc_ctype_cjk_lang; |
} |
struct lconv * |
_DEFUN(_localeconv_r, (data), |
struct _reent *data) |
{ |
#ifdef __HAVE_LOCALE_INFO__ |
if (__nlocale_changed) |
{ |
struct lc_numeric_T *n = __get_current_numeric_locale (); |
lconv.decimal_point = (char *) n->decimal_point; |
lconv.thousands_sep = (char *) n->thousands_sep; |
lconv.grouping = (char *) n->grouping; |
__nlocale_changed = 0; |
} |
if (__mlocale_changed) |
{ |
struct lc_monetary_T *m = __get_current_monetary_locale (); |
lconv.int_curr_symbol = (char *) m->int_curr_symbol; |
lconv.currency_symbol = (char *) m->currency_symbol; |
lconv.mon_decimal_point = (char *) m->mon_decimal_point; |
lconv.mon_thousands_sep = (char *) m->mon_thousands_sep; |
lconv.mon_grouping = (char *) m->mon_grouping; |
lconv.positive_sign = (char *) m->positive_sign; |
lconv.negative_sign = (char *) m->negative_sign; |
lconv.int_frac_digits = m->int_frac_digits[0]; |
lconv.frac_digits = m->frac_digits[0]; |
lconv.p_cs_precedes = m->p_cs_precedes[0]; |
lconv.p_sep_by_space = m->p_sep_by_space[0]; |
lconv.n_cs_precedes = m->n_cs_precedes[0]; |
lconv.n_sep_by_space = m->n_sep_by_space[0]; |
lconv.p_sign_posn = m->p_sign_posn[0]; |
lconv.n_sign_posn = m->n_sign_posn[0]; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
lconv.int_p_cs_precedes = m->int_p_cs_precedes[0]; |
lconv.int_p_sep_by_space = m->int_p_sep_by_space[0]; |
lconv.int_n_cs_precedes = m->int_n_cs_precedes[0]; |
lconv.int_n_sep_by_space = m->int_n_sep_by_space[0]; |
lconv.int_n_sign_posn = m->int_n_sign_posn[0]; |
lconv.int_p_sign_posn = m->int_p_sign_posn[0]; |
#else /* !__HAVE_LOCALE_INFO_EXTENDED__ */ |
lconv.int_p_cs_precedes = m->p_cs_precedes[0]; |
lconv.int_p_sep_by_space = m->p_sep_by_space[0]; |
lconv.int_n_cs_precedes = m->n_cs_precedes[0]; |
lconv.int_n_sep_by_space = m->n_sep_by_space[0]; |
lconv.int_n_sign_posn = m->n_sign_posn[0]; |
lconv.int_p_sign_posn = m->p_sign_posn[0]; |
#endif /* !__HAVE_LOCALE_INFO_EXTENDED__ */ |
__mlocale_changed = 0; |
} |
#endif /* __HAVE_LOCALE_INFO__ */ |
return (struct lconv *) &lconv; |
} |
#ifndef _REENT_ONLY |
#ifndef __CYGWIN__ |
/* Cygwin provides its own version of setlocale to perform some more |
initialization work. It calls _setlocale_r, though. */ |
char * |
_DEFUN(setlocale, (category, locale), |
int category _AND |
_CONST char *locale) |
{ |
return _setlocale_r (_REENT, category, locale); |
} |
#endif /* __CYGWIN__ */ |
struct lconv * |
_DEFUN_VOID(localeconv) |
{ |
return _localeconv_r (_REENT); |
} |
#endif |
/contrib/sdk/sources/libc/locale/setlocale.h |
---|
0,0 → 1,37 |
/*- |
* Copyright (C) 1997 by Andrey A. Chernov, Moscow, Russia. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/locale/setlocale.h,v 1.4 2001/12/20 18:28:52 phantom Exp $ |
*/ |
#ifndef _SETLOCALE_H_ |
#define _SETLOCALE_H_ |
#define ENCODING_LEN 31 |
#define CATEGORY_LEN 11 |
extern char *_PathLocale; |
#endif /* !_SETLOCALE_H_ */ |
/contrib/sdk/sources/libc/locale/timelocal.h |
---|
0,0 → 1,85 |
/*- |
* Copyright (c) 1997-2002 FreeBSD Project. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
* |
* $FreeBSD: src/lib/libc/stdtime/timelocal.h,v 1.11 2002/01/24 15:07:44 phantom Exp $ |
*/ |
#ifndef _TIMELOCAL_H_ |
#define _TIMELOCAL_H_ |
#include <_ansi.h> |
#include <sys/cdefs.h> |
#include <wchar.h> |
__BEGIN_DECLS |
/* |
* Private header file for the strftime and strptime localization |
* stuff. |
*/ |
struct lc_time_T { |
const char *mon[12]; |
const char *month[12]; |
const char *wday[7]; |
const char *weekday[7]; |
const char *X_fmt; |
const char *x_fmt; |
const char *c_fmt; |
const char *am_pm[2]; |
const char *date_fmt; |
const char *alt_month[12]; /* unused */ |
const char *md_order; |
const char *ampm_fmt; |
const char *era; |
const char *era_d_fmt; |
const char *era_d_t_fmt; |
const char *era_t_fmt; |
const char *alt_digits; |
#ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
const char *codeset; /* codeset for mbtowc conversion */ |
const wchar_t *wmon[12]; |
const wchar_t *wmonth[12]; |
const wchar_t *wwday[7]; |
const wchar_t *wweekday[7]; |
const wchar_t *wX_fmt; |
const wchar_t *wx_fmt; |
const wchar_t *wc_fmt; |
const wchar_t *wam_pm[2]; |
const wchar_t *wdate_fmt; |
const wchar_t *wampm_fmt; |
const wchar_t *wera; |
const wchar_t *wera_d_fmt; |
const wchar_t *wera_d_t_fmt; |
const wchar_t *wera_t_fmt; |
const wchar_t *walt_digits; |
#endif |
}; |
struct lc_time_T *__get_current_time_locale(void); |
int __time_load_locale(const char *, void *, const char *); |
__END_DECLS |
#endif /* !_TIMELOCAL_H_ */ |
/contrib/sdk/sources/libc/math/e_acos.c |
---|
0,0 → 1,111 |
/* @(#)e_acos.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_acos(x) |
* Method : |
* acos(x) = pi/2 - asin(x) |
* acos(-x) = pi/2 + asin(x) |
* For |x|<=0.5 |
* acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see asin.c) |
* For x>0.5 |
* acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2))) |
* = 2asin(sqrt((1-x)/2)) |
* = 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z) |
* = 2f + (2c + 2s*z*R(z)) |
* where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term |
* for f so that f+c ~ sqrt(z). |
* For x<-0.5 |
* acos(x) = pi - 2asin(sqrt((1-|x|)/2)) |
* = pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z) |
* |
* Special cases: |
* if x is NaN, return x itself; |
* if |x|>1, return NaN with invalid signal. |
* |
* Function needed: sqrt |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
one= 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */ |
pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ |
pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ |
pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ |
pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ |
pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ |
pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ |
pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ |
pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ |
qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ |
qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ |
qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ |
qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ |
#ifdef __STDC__ |
double __ieee754_acos(double x) |
#else |
double __ieee754_acos(x) |
double x; |
#endif |
{ |
double z,p,q,r,w,s,c,df; |
__int32_t hx,ix; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix>=0x3ff00000) { /* |x| >= 1 */ |
__uint32_t lx; |
GET_LOW_WORD(lx,x); |
if(((ix-0x3ff00000)|lx)==0) { /* |x|==1 */ |
if(hx>0) return 0.0; /* acos(1) = 0 */ |
else return pi+2.0*pio2_lo; /* acos(-1)= pi */ |
} |
return (x-x)/(x-x); /* acos(|x|>1) is NaN */ |
} |
if(ix<0x3fe00000) { /* |x| < 0.5 */ |
if(ix<=0x3c600000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/ |
z = x*x; |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); |
r = p/q; |
return pio2_hi - (x - (pio2_lo-x*r)); |
} else if (hx<0) { /* x < -0.5 */ |
z = (one+x)*0.5; |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); |
s = __ieee754_sqrt(z); |
r = p/q; |
w = r*s-pio2_lo; |
return pi - 2.0*(s+w); |
} else { /* x > 0.5 */ |
z = (one-x)*0.5; |
s = __ieee754_sqrt(z); |
df = s; |
SET_LOW_WORD(df,0); |
c = (z-df*df)/(s+df); |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); |
r = p/q; |
w = r*s+c; |
return 2.0*(df+w); |
} |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_acosh.c |
---|
0,0 → 1,70 |
/* @(#)e_acosh.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* __ieee754_acosh(x) |
* Method : |
* Based on |
* acosh(x) = log [ x + sqrt(x*x-1) ] |
* we have |
* acosh(x) := log(x)+ln2, if x is large; else |
* acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else |
* acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1. |
* |
* Special cases: |
* acosh(x) is NaN with signal if x<1. |
* acosh(NaN) is NaN without signal. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
one = 1.0, |
ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */ |
#ifdef __STDC__ |
double __ieee754_acosh(double x) |
#else |
double __ieee754_acosh(x) |
double x; |
#endif |
{ |
double t; |
__int32_t hx; |
__uint32_t lx; |
EXTRACT_WORDS(hx,lx,x); |
if(hx<0x3ff00000) { /* x < 1 */ |
return (x-x)/(x-x); |
} else if(hx >=0x41b00000) { /* x > 2**28 */ |
if(hx >=0x7ff00000) { /* x is inf of NaN */ |
return x+x; |
} else |
return __ieee754_log(x)+ln2; /* acosh(huge)=log(2x) */ |
} else if(((hx-0x3ff00000)|lx)==0) { |
return 0.0; /* acosh(1) = 0 */ |
} else if (hx > 0x40000000) { /* 2**28 > x > 2 */ |
t=x*x; |
return __ieee754_log(2.0*x-one/(x+__ieee754_sqrt(t-one))); |
} else { /* 1<x<2 */ |
t = x-one; |
return log1p(t+__ieee754_sqrt(2.0*t+t*t)); |
} |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_asin.c |
---|
0,0 → 1,121 |
/* @(#)e_asin.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_asin(x) |
* Method : |
* Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ... |
* we approximate asin(x) on [0,0.5] by |
* asin(x) = x + x*x^2*R(x^2) |
* where |
* R(x^2) is a rational approximation of (asin(x)-x)/x^3 |
* and its remez error is bounded by |
* |(asin(x)-x)/x^3 - R(x^2)| < 2^(-58.75) |
* |
* For x in [0.5,1] |
* asin(x) = pi/2-2*asin(sqrt((1-x)/2)) |
* Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2; |
* then for x>0.98 |
* asin(x) = pi/2 - 2*(s+s*z*R(z)) |
* = pio2_hi - (2*(s+s*z*R(z)) - pio2_lo) |
* For x<=0.98, let pio4_hi = pio2_hi/2, then |
* f = hi part of s; |
* c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z) |
* and |
* asin(x) = pi/2 - 2*(s+s*z*R(z)) |
* = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo) |
* = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c)) |
* |
* Special cases: |
* if x is NaN, return x itself; |
* if |x|>1, return NaN with invalid signal. |
* |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
huge = 1.000e+300, |
pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ |
pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */ |
pio4_hi = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */ |
/* coefficient for R(x^2) */ |
pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */ |
pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */ |
pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */ |
pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */ |
pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */ |
pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */ |
qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */ |
qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ |
qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ |
qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ |
#ifdef __STDC__ |
double __ieee754_asin(double x) |
#else |
double __ieee754_asin(x) |
double x; |
#endif |
{ |
double t,w,p,q,c,r,s; |
__int32_t hx,ix; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix>= 0x3ff00000) { /* |x|>= 1 */ |
__uint32_t lx; |
GET_LOW_WORD(lx,x); |
if(((ix-0x3ff00000)|lx)==0) |
/* asin(1)=+-pi/2 with inexact */ |
return x*pio2_hi+x*pio2_lo; |
return (x-x)/(x-x); /* asin(|x|>1) is NaN */ |
} else if (ix<0x3fe00000) { /* |x|<0.5 */ |
if(ix<0x3e400000) { /* if |x| < 2**-27 */ |
if(huge+x>one) return x;/* return x with inexact if x!=0*/ |
} else { |
t = x*x; |
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); |
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); |
w = p/q; |
return x+x*w; |
} |
} |
/* 1> |x|>= 0.5 */ |
w = one-fabs(x); |
t = w*0.5; |
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); |
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); |
s = __ieee754_sqrt(t); |
if(ix>=0x3FEF3333) { /* if |x| > 0.975 */ |
w = p/q; |
t = pio2_hi-(2.0*(s+s*w)-pio2_lo); |
} else { |
w = s; |
SET_LOW_WORD(w,0); |
c = (t-w*w)/(s+w); |
r = p/q; |
p = 2.0*s*r-(pio2_lo-2.0*c); |
q = pio4_hi-2.0*w; |
t = pio4_hi-(p-q); |
} |
if(hx>0) return t; else return -t; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_atan2.c |
---|
0,0 → 1,131 |
/* @(#)e_atan2.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* __ieee754_atan2(y,x) |
* Method : |
* 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). |
* 2. Reduce x to positive by (if x and y are unexceptional): |
* ARG (x+iy) = arctan(y/x) ... if x > 0, |
* ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, |
* |
* Special cases: |
* |
* ATAN2((anything), NaN ) is NaN; |
* ATAN2(NAN , (anything) ) is NaN; |
* ATAN2(+-0, +(anything but NaN)) is +-0 ; |
* ATAN2(+-0, -(anything but NaN)) is +-pi ; |
* ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2; |
* ATAN2(+-(anything but INF and NaN), +INF) is +-0 ; |
* ATAN2(+-(anything but INF and NaN), -INF) is +-pi; |
* ATAN2(+-INF,+INF ) is +-pi/4 ; |
* ATAN2(+-INF,-INF ) is +-3pi/4; |
* ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2; |
* |
* Constants: |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
tiny = 1.0e-300, |
zero = 0.0, |
pi_o_4 = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */ |
pi_o_2 = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */ |
pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */ |
pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */ |
#ifdef __STDC__ |
double __ieee754_atan2(double y, double x) |
#else |
double __ieee754_atan2(y,x) |
double y,x; |
#endif |
{ |
double z; |
__int32_t k,m,hx,hy,ix,iy; |
__uint32_t lx,ly; |
EXTRACT_WORDS(hx,lx,x); |
ix = hx&0x7fffffff; |
EXTRACT_WORDS(hy,ly,y); |
iy = hy&0x7fffffff; |
if(((ix|((lx|-lx)>>31))>0x7ff00000)|| |
((iy|((ly|-ly)>>31))>0x7ff00000)) /* x or y is NaN */ |
return x+y; |
if(((hx-0x3ff00000)|lx)==0) return atan(y); /* x=1.0 */ |
m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */ |
/* when y = 0 */ |
if((iy|ly)==0) { |
switch(m) { |
case 0: |
case 1: return y; /* atan(+-0,+anything)=+-0 */ |
case 2: return pi+tiny;/* atan(+0,-anything) = pi */ |
case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */ |
} |
} |
/* when x = 0 */ |
if((ix|lx)==0) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; |
/* when x is INF */ |
if(ix==0x7ff00000) { |
if(iy==0x7ff00000) { |
switch(m) { |
case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */ |
case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */ |
case 2: return 3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/ |
case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/ |
} |
} else { |
switch(m) { |
case 0: return zero ; /* atan(+...,+INF) */ |
case 1: return -zero ; /* atan(-...,+INF) */ |
case 2: return pi+tiny ; /* atan(+...,-INF) */ |
case 3: return -pi-tiny ; /* atan(-...,-INF) */ |
} |
} |
} |
/* when y is INF */ |
if(iy==0x7ff00000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; |
/* compute y/x */ |
k = (iy-ix)>>20; |
if(k > 60) z=pi_o_2+0.5*pi_lo; /* |y/x| > 2**60 */ |
else if(hx<0&&k<-60) z=0.0; /* |y|/x < -2**60 */ |
else z=atan(fabs(y/x)); /* safe to do y/x */ |
switch (m) { |
case 0: return z ; /* atan(+,+) */ |
case 1: { |
__uint32_t zh; |
GET_HIGH_WORD(zh,z); |
SET_HIGH_WORD(z,zh ^ 0x80000000); |
} |
return z ; /* atan(-,+) */ |
case 2: return pi-(z-pi_lo);/* atan(+,-) */ |
default: /* case 3 */ |
return (z-pi_lo)-pi;/* atan(-,-) */ |
} |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_atanh.c |
---|
0,0 → 1,75 |
/* @(#)e_atanh.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* __ieee754_atanh(x) |
* Method : |
* 1.Reduced x to positive by atanh(-x) = -atanh(x) |
* 2.For x>=0.5 |
* 1 2x x |
* atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) |
* 2 1 - x 1 - x |
* |
* For x<0.5 |
* atanh(x) = 0.5*log1p(2x+2x*x/(1-x)) |
* |
* Special cases: |
* atanh(x) is NaN if |x| > 1 with signal; |
* atanh(NaN) is that NaN with no signal; |
* atanh(+-1) is +-INF with signal. |
* |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double one = 1.0, huge = 1e300; |
#else |
static double one = 1.0, huge = 1e300; |
#endif |
#ifdef __STDC__ |
static const double zero = 0.0; |
#else |
static double zero = 0.0; |
#endif |
#ifdef __STDC__ |
double __ieee754_atanh(double x) |
#else |
double __ieee754_atanh(x) |
double x; |
#endif |
{ |
double t; |
__int32_t hx,ix; |
__uint32_t lx; |
EXTRACT_WORDS(hx,lx,x); |
ix = hx&0x7fffffff; |
if ((ix|((lx|(-lx))>>31))>0x3ff00000) /* |x|>1 */ |
return (x-x)/(x-x); |
if(ix==0x3ff00000) |
return x/zero; |
if(ix<0x3e300000&&(huge+x)>zero) return x; /* x<2**-28 */ |
SET_HIGH_WORD(x,ix); |
if(ix<0x3fe00000) { /* x < 0.5 */ |
t = x+x; |
t = 0.5*log1p(t+t*x/(one-x)); |
} else |
t = 0.5*log1p((x+x)/(one-x)); |
if(hx>=0) return t; else return -t; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_cosh.c |
---|
0,0 → 1,93 |
/* @(#)e_cosh.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_cosh(x) |
* Method : |
* mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2 |
* 1. Replace x by |x| (cosh(x) = cosh(-x)). |
* 2. |
* [ exp(x) - 1 ]^2 |
* 0 <= x <= ln2/2 : cosh(x) := 1 + ------------------- |
* 2*exp(x) |
* |
* exp(x) + 1/exp(x) |
* ln2/2 <= x <= 22 : cosh(x) := ------------------- |
* 2 |
* 22 <= x <= lnovft : cosh(x) := exp(x)/2 |
* lnovft <= x <= ln2ovft: cosh(x) := exp(x/2)/2 * exp(x/2) |
* ln2ovft < x : cosh(x) := huge*huge (overflow) |
* |
* Special cases: |
* cosh(x) is |x| if x is +INF, -INF, or NaN. |
* only cosh(0)=1 is exact for finite x. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double one = 1.0, half=0.5, huge = 1.0e300; |
#else |
static double one = 1.0, half=0.5, huge = 1.0e300; |
#endif |
#ifdef __STDC__ |
double __ieee754_cosh(double x) |
#else |
double __ieee754_cosh(x) |
double x; |
#endif |
{ |
double t,w; |
__int32_t ix; |
__uint32_t lx; |
/* High word of |x|. */ |
GET_HIGH_WORD(ix,x); |
ix &= 0x7fffffff; |
/* x is INF or NaN */ |
if(ix>=0x7ff00000) return x*x; |
/* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */ |
if(ix<0x3fd62e43) { |
t = expm1(fabs(x)); |
w = one+t; |
if (ix<0x3c800000) return w; /* cosh(tiny) = 1 */ |
return one+(t*t)/(w+w); |
} |
/* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */ |
if (ix < 0x40360000) { |
t = __ieee754_exp(fabs(x)); |
return half*t+half/t; |
} |
/* |x| in [22, log(maxdouble)] return half*exp(|x|) */ |
if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x)); |
/* |x| in [log(maxdouble), overflowthresold] */ |
GET_LOW_WORD(lx,x); |
if (ix<0x408633CE || |
(ix==0x408633ce && lx<=(__uint32_t)0x8fb9f87d)) { |
w = __ieee754_exp(half*fabs(x)); |
t = half*w; |
return t*w; |
} |
/* |x| > overflowthresold, cosh(x) overflow */ |
return huge*huge; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_exp.c |
---|
0,0 → 1,166 |
/* @(#)e_exp.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_exp(x) |
* Returns the exponential of x. |
* |
* Method |
* 1. Argument reduction: |
* Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658. |
* Given x, find r and integer k such that |
* |
* x = k*ln2 + r, |r| <= 0.5*ln2. |
* |
* Here r will be represented as r = hi-lo for better |
* accuracy. |
* |
* 2. Approximation of exp(r) by a special rational function on |
* the interval [0,0.34658]: |
* Write |
* R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ... |
* We use a special Reme algorithm on [0,0.34658] to generate |
* a polynomial of degree 5 to approximate R. The maximum error |
* of this polynomial approximation is bounded by 2**-59. In |
* other words, |
* R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5 |
* (where z=r*r, and the values of P1 to P5 are listed below) |
* and |
* | 5 | -59 |
* | 2.0+P1*z+...+P5*z - R(z) | <= 2 |
* | | |
* The computation of exp(r) thus becomes |
* 2*r |
* exp(r) = 1 + ------- |
* R - r |
* r*R1(r) |
* = 1 + r + ----------- (for better accuracy) |
* 2 - R1(r) |
* where |
* 2 4 10 |
* R1(r) = r - (P1*r + P2*r + ... + P5*r ). |
* |
* 3. Scale back to obtain exp(x): |
* From step 1, we have |
* exp(x) = 2^k * exp(r) |
* |
* Special cases: |
* exp(INF) is INF, exp(NaN) is NaN; |
* exp(-INF) is 0, and |
* for finite argument, only exp(0)=1 is exact. |
* |
* Accuracy: |
* according to an error analysis, the error is always less than |
* 1 ulp (unit in the last place). |
* |
* Misc. info. |
* For IEEE double |
* if x > 7.09782712893383973096e+02 then exp(x) overflow |
* if x < -7.45133219101941108420e+02 then exp(x) underflow |
* |
* Constants: |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
one = 1.0, |
halF[2] = {0.5,-0.5,}, |
huge = 1.0e+300, |
twom1000= 9.33263618503218878990e-302, /* 2**-1000=0x01700000,0*/ |
o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ |
u_threshold= -7.45133219101941108420e+02, /* 0xc0874910, 0xD52D3051 */ |
ln2HI[2] ={ 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */ |
-6.93147180369123816490e-01,},/* 0xbfe62e42, 0xfee00000 */ |
ln2LO[2] ={ 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */ |
-1.90821492927058770002e-10,},/* 0xbdea39ef, 0x35793c76 */ |
invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */ |
P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ |
P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ |
P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ |
P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ |
P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ |
#ifdef __STDC__ |
double __ieee754_exp(double x) /* default IEEE double exp */ |
#else |
double __ieee754_exp(x) /* default IEEE double exp */ |
double x; |
#endif |
{ |
double y,hi,lo,c,t; |
__int32_t k = 0,xsb; |
__uint32_t hx; |
GET_HIGH_WORD(hx,x); |
xsb = (hx>>31)&1; /* sign bit of x */ |
hx &= 0x7fffffff; /* high word of |x| */ |
/* filter out non-finite argument */ |
if(hx >= 0x40862E42) { /* if |x|>=709.78... */ |
if(hx>=0x7ff00000) { |
__uint32_t lx; |
GET_LOW_WORD(lx,x); |
if(((hx&0xfffff)|lx)!=0) |
return x+x; /* NaN */ |
else return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */ |
} |
if(x > o_threshold) return huge*huge; /* overflow */ |
if(x < u_threshold) return twom1000*twom1000; /* underflow */ |
} |
/* argument reduction */ |
if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ |
if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ |
hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb; |
} else { |
k = invln2*x+halF[xsb]; |
t = k; |
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */ |
lo = t*ln2LO[0]; |
} |
x = hi - lo; |
} |
else if(hx < 0x3e300000) { /* when |x|<2**-28 */ |
if(huge+x>one) return one+x;/* trigger inexact */ |
} |
/* x is now in primary range */ |
t = x*x; |
c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); |
if(k==0) return one-((x*c)/(c-2.0)-x); |
else y = one-((lo-(x*c)/(2.0-c))-hi); |
if(k >= -1021) { |
__uint32_t hy; |
GET_HIGH_WORD(hy,y); |
SET_HIGH_WORD(y,hy+(k<<20)); /* add k to y's exponent */ |
return y; |
} else { |
__uint32_t hy; |
GET_HIGH_WORD(hy,y); |
SET_HIGH_WORD(y,hy+((k+1000)<<20)); /* add k to y's exponent */ |
return y*twom1000; |
} |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_fmod.c |
---|
0,0 → 1,140 |
/* @(#)e_fmod.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* __ieee754_fmod(x,y) |
* Return x mod y in exact arithmetic |
* Method: shift and subtract |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double one = 1.0, Zero[] = {0.0, -0.0,}; |
#else |
static double one = 1.0, Zero[] = {0.0, -0.0,}; |
#endif |
#ifdef __STDC__ |
double __ieee754_fmod(double x, double y) |
#else |
double __ieee754_fmod(x,y) |
double x,y ; |
#endif |
{ |
__int32_t n,hx,hy,hz,ix,iy,sx,i; |
__uint32_t lx,ly,lz; |
EXTRACT_WORDS(hx,lx,x); |
EXTRACT_WORDS(hy,ly,y); |
sx = hx&0x80000000; /* sign of x */ |
hx ^=sx; /* |x| */ |
hy &= 0x7fffffff; /* |y| */ |
/* purge off exception values */ |
if((hy|ly)==0||(hx>=0x7ff00000)|| /* y=0,or x not finite */ |
((hy|((ly|-ly)>>31))>0x7ff00000)) /* or y is NaN */ |
return (x*y)/(x*y); |
if(hx<=hy) { |
if((hx<hy)||(lx<ly)) return x; /* |x|<|y| return x */ |
if(lx==ly) |
return Zero[(__uint32_t)sx>>31]; /* |x|=|y| return x*0*/ |
} |
/* determine ix = ilogb(x) */ |
if(hx<0x00100000) { /* subnormal x */ |
if(hx==0) { |
for (ix = -1043, i=lx; i>0; i<<=1) ix -=1; |
} else { |
for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1; |
} |
} else ix = (hx>>20)-1023; |
/* determine iy = ilogb(y) */ |
if(hy<0x00100000) { /* subnormal y */ |
if(hy==0) { |
for (iy = -1043, i=ly; i>0; i<<=1) iy -=1; |
} else { |
for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1; |
} |
} else iy = (hy>>20)-1023; |
/* set up {hx,lx}, {hy,ly} and align y to x */ |
if(ix >= -1022) |
hx = 0x00100000|(0x000fffff&hx); |
else { /* subnormal x, shift x to normal */ |
n = -1022-ix; |
if(n<=31) { |
hx = (hx<<n)|(lx>>(32-n)); |
lx <<= n; |
} else { |
hx = lx<<(n-32); |
lx = 0; |
} |
} |
if(iy >= -1022) |
hy = 0x00100000|(0x000fffff&hy); |
else { /* subnormal y, shift y to normal */ |
n = -1022-iy; |
if(n<=31) { |
hy = (hy<<n)|(ly>>(32-n)); |
ly <<= n; |
} else { |
hy = ly<<(n-32); |
ly = 0; |
} |
} |
/* fix point fmod */ |
n = ix - iy; |
while(n--) { |
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1; |
if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;} |
else { |
if((hz|lz)==0) /* return sign(x)*0 */ |
return Zero[(__uint32_t)sx>>31]; |
hx = hz+hz+(lz>>31); lx = lz+lz; |
} |
} |
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1; |
if(hz>=0) {hx=hz;lx=lz;} |
/* convert back to floating value and restore the sign */ |
if((hx|lx)==0) /* return sign(x)*0 */ |
return Zero[(__uint32_t)sx>>31]; |
while(hx<0x00100000) { /* normalize x */ |
hx = hx+hx+(lx>>31); lx = lx+lx; |
iy -= 1; |
} |
if(iy>= -1022) { /* normalize output */ |
hx = ((hx-0x00100000)|((iy+1023)<<20)); |
INSERT_WORDS(x,hx|sx,lx); |
} else { /* subnormal output */ |
n = -1022 - iy; |
if(n<=20) { |
lx = (lx>>n)|((__uint32_t)hx<<(32-n)); |
hx >>= n; |
} else if (n<=31) { |
lx = (hx<<(32-n))|(lx>>n); hx = sx; |
} else { |
lx = hx>>(n-32); hx = sx; |
} |
INSERT_WORDS(x,hx|sx,lx); |
x *= one; /* create necessary signal */ |
} |
return x; /* exact output */ |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_hypot.c |
---|
0,0 → 1,128 |
/* @(#)e_hypot.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_hypot(x,y) |
* |
* Method : |
* If (assume round-to-nearest) z=x*x+y*y |
* has error less than sqrt(2)/2 ulp, than |
* sqrt(z) has error less than 1 ulp (exercise). |
* |
* So, compute sqrt(x*x+y*y) with some care as |
* follows to get the error below 1 ulp: |
* |
* Assume x>y>0; |
* (if possible, set rounding to round-to-nearest) |
* 1. if x > 2y use |
* x1*x1+(y*y+(x2*(x+x1))) for x*x+y*y |
* where x1 = x with lower 32 bits cleared, x2 = x-x1; else |
* 2. if x <= 2y use |
* t1*y1+((x-y)*(x-y)+(t1*y2+t2*y)) |
* where t1 = 2x with lower 32 bits cleared, t2 = 2x-t1, |
* y1= y with lower 32 bits chopped, y2 = y-y1. |
* |
* NOTE: scaling may be necessary if some argument is too |
* large or too tiny |
* |
* Special cases: |
* hypot(x,y) is INF if x or y is +INF or -INF; else |
* hypot(x,y) is NAN if x or y is NAN. |
* |
* Accuracy: |
* hypot(x,y) returns sqrt(x^2+y^2) with error less |
* than 1 ulps (units in the last place) |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double __ieee754_hypot(double x, double y) |
#else |
double __ieee754_hypot(x,y) |
double x, y; |
#endif |
{ |
double a=x,b=y,t1,t2,y1,y2,w; |
__int32_t j,k,ha,hb; |
GET_HIGH_WORD(ha,x); |
ha &= 0x7fffffff; |
GET_HIGH_WORD(hb,y); |
hb &= 0x7fffffff; |
if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;} |
SET_HIGH_WORD(a,ha); /* a <- |a| */ |
SET_HIGH_WORD(b,hb); /* b <- |b| */ |
if((ha-hb)>0x3c00000) {return a+b;} /* x/y > 2**60 */ |
k=0; |
if(ha > 0x5f300000) { /* a>2**500 */ |
if(ha >= 0x7ff00000) { /* Inf or NaN */ |
__uint32_t low; |
w = a+b; /* for sNaN */ |
GET_LOW_WORD(low,a); |
if(((ha&0xfffff)|low)==0) w = a; |
GET_LOW_WORD(low,b); |
if(((hb^0x7ff00000)|low)==0) w = b; |
return w; |
} |
/* scale a and b by 2**-600 */ |
ha -= 0x25800000; hb -= 0x25800000; k += 600; |
SET_HIGH_WORD(a,ha); |
SET_HIGH_WORD(b,hb); |
} |
if(hb < 0x20b00000) { /* b < 2**-500 */ |
if(hb <= 0x000fffff) { /* subnormal b or 0 */ |
__uint32_t low; |
GET_LOW_WORD(low,b); |
if((hb|low)==0) return a; |
t1=0; |
SET_HIGH_WORD(t1,0x7fd00000); /* t1=2^1022 */ |
b *= t1; |
a *= t1; |
k -= 1022; |
} else { /* scale a and b by 2^600 */ |
ha += 0x25800000; /* a *= 2^600 */ |
hb += 0x25800000; /* b *= 2^600 */ |
k -= 600; |
SET_HIGH_WORD(a,ha); |
SET_HIGH_WORD(b,hb); |
} |
} |
/* medium size a and b */ |
w = a-b; |
if (w>b) { |
t1 = 0; |
SET_HIGH_WORD(t1,ha); |
t2 = a-t1; |
w = __ieee754_sqrt(t1*t1-(b*(-b)-t2*(a+t1))); |
} else { |
a = a+a; |
y1 = 0; |
SET_HIGH_WORD(y1,hb); |
y2 = b - y1; |
t1 = 0; |
SET_HIGH_WORD(t1,ha+0x00100000); |
t2 = a - t1; |
w = __ieee754_sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b))); |
} |
if(k!=0) { |
__uint32_t high; |
t1 = 1.0; |
GET_HIGH_WORD(high,t1); |
SET_HIGH_WORD(t1,high+(k<<20)); |
return t1*w; |
} else return w; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_j0.c |
---|
0,0 → 1,487 |
/* @(#)e_j0.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_j0(x), __ieee754_y0(x) |
* Bessel function of the first and second kinds of order zero. |
* Method -- j0(x): |
* 1. For tiny x, we use j0(x) = 1 - x^2/4 + x^4/64 - ... |
* 2. Reduce x to |x| since j0(x)=j0(-x), and |
* for x in (0,2) |
* j0(x) = 1-z/4+ z^2*R0/S0, where z = x*x; |
* (precision: |j0-1+z/4-z^2R0/S0 |<2**-63.67 ) |
* for x in (2,inf) |
* j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0)) |
* where x0 = x-pi/4. It is better to compute sin(x0),cos(x0) |
* as follow: |
* cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) |
* = 1/sqrt(2) * (cos(x) + sin(x)) |
* sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4) |
* = 1/sqrt(2) * (sin(x) - cos(x)) |
* (To avoid cancellation, use |
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) |
* to compute the worse one.) |
* |
* 3 Special cases |
* j0(nan)= nan |
* j0(0) = 1 |
* j0(inf) = 0 |
* |
* Method -- y0(x): |
* 1. For x<2. |
* Since |
* y0(x) = 2/pi*(j0(x)*(ln(x/2)+Euler) + x^2/4 - ...) |
* therefore y0(x)-2/pi*j0(x)*ln(x) is an even function. |
* We use the following function to approximate y0, |
* y0(x) = U(z)/V(z) + (2/pi)*(j0(x)*ln(x)), z= x^2 |
* where |
* U(z) = u00 + u01*z + ... + u06*z^6 |
* V(z) = 1 + v01*z + ... + v04*z^4 |
* with absolute approximation error bounded by 2**-72. |
* Note: For tiny x, U/V = u0 and j0(x)~1, hence |
* y0(tiny) = u0 + (2/pi)*ln(tiny), (choose tiny<2**-27) |
* 2. For x>=2. |
* y0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)+q0(x)*sin(x0)) |
* where x0 = x-pi/4. It is better to compute sin(x0),cos(x0) |
* by the method mentioned above. |
* 3. Special cases: y0(0)=-inf, y0(x<0)=NaN, y0(inf)=0. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static double pzero(double), qzero(double); |
#else |
static double pzero(), qzero(); |
#endif |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
huge = 1e300, |
one = 1.0, |
invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */ |
tpi = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */ |
/* R0/S0 on [0, 2.00] */ |
R02 = 1.56249999999999947958e-02, /* 0x3F8FFFFF, 0xFFFFFFFD */ |
R03 = -1.89979294238854721751e-04, /* 0xBF28E6A5, 0xB61AC6E9 */ |
R04 = 1.82954049532700665670e-06, /* 0x3EBEB1D1, 0x0C503919 */ |
R05 = -4.61832688532103189199e-09, /* 0xBE33D5E7, 0x73D63FCE */ |
S01 = 1.56191029464890010492e-02, /* 0x3F8FFCE8, 0x82C8C2A4 */ |
S02 = 1.16926784663337450260e-04, /* 0x3F1EA6D2, 0xDD57DBF4 */ |
S03 = 5.13546550207318111446e-07, /* 0x3EA13B54, 0xCE84D5A9 */ |
S04 = 1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */ |
#ifdef __STDC__ |
static const double zero = 0.0; |
#else |
static double zero = 0.0; |
#endif |
#ifdef __STDC__ |
double __ieee754_j0(double x) |
#else |
double __ieee754_j0(x) |
double x; |
#endif |
{ |
double z, s,c,ss,cc,r,u,v; |
__int32_t hx,ix; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix>=0x7ff00000) return one/(x*x); |
x = fabs(x); |
if(ix >= 0x40000000) { /* |x| >= 2.0 */ |
s = sin(x); |
c = cos(x); |
ss = s-c; |
cc = s+c; |
if(ix<0x7fe00000) { /* make sure x+x not overflow */ |
z = -cos(x+x); |
if ((s*c)<zero) cc = z/ss; |
else ss = z/cc; |
} |
/* |
* j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) |
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) |
*/ |
if(ix>0x48000000) z = (invsqrtpi*cc)/__ieee754_sqrt(x); |
else { |
u = pzero(x); v = qzero(x); |
z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrt(x); |
} |
return z; |
} |
if(ix<0x3f200000) { /* |x| < 2**-13 */ |
if(huge+x>one) { /* raise inexact if x != 0 */ |
if(ix<0x3e400000) return one; /* |x|<2**-27 */ |
else return one - 0.25*x*x; |
} |
} |
z = x*x; |
r = z*(R02+z*(R03+z*(R04+z*R05))); |
s = one+z*(S01+z*(S02+z*(S03+z*S04))); |
if(ix < 0x3FF00000) { /* |x| < 1.00 */ |
return one + z*(-0.25+(r/s)); |
} else { |
u = 0.5*x; |
return((one+u)*(one-u)+z*(r/s)); |
} |
} |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
u00 = -7.38042951086872317523e-02, /* 0xBFB2E4D6, 0x99CBD01F */ |
u01 = 1.76666452509181115538e-01, /* 0x3FC69D01, 0x9DE9E3FC */ |
u02 = -1.38185671945596898896e-02, /* 0xBF8C4CE8, 0xB16CFA97 */ |
u03 = 3.47453432093683650238e-04, /* 0x3F36C54D, 0x20B29B6B */ |
u04 = -3.81407053724364161125e-06, /* 0xBECFFEA7, 0x73D25CAD */ |
u05 = 1.95590137035022920206e-08, /* 0x3E550057, 0x3B4EABD4 */ |
u06 = -3.98205194132103398453e-11, /* 0xBDC5E43D, 0x693FB3C8 */ |
v01 = 1.27304834834123699328e-02, /* 0x3F8A1270, 0x91C9C71A */ |
v02 = 7.60068627350353253702e-05, /* 0x3F13ECBB, 0xF578C6C1 */ |
v03 = 2.59150851840457805467e-07, /* 0x3E91642D, 0x7FF202FD */ |
v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */ |
#ifdef __STDC__ |
double __ieee754_y0(double x) |
#else |
double __ieee754_y0(x) |
double x; |
#endif |
{ |
double z, s,c,ss,cc,u,v; |
__int32_t hx,ix,lx; |
EXTRACT_WORDS(hx,lx,x); |
ix = 0x7fffffff&hx; |
/* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */ |
if(ix>=0x7ff00000) return one/(x+x*x); |
if((ix|lx)==0) return -one/zero; |
if(hx<0) return zero/zero; |
if(ix >= 0x40000000) { /* |x| >= 2.0 */ |
/* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0)) |
* where x0 = x-pi/4 |
* Better formula: |
* cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) |
* = 1/sqrt(2) * (sin(x) + cos(x)) |
* sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) |
* = 1/sqrt(2) * (sin(x) - cos(x)) |
* To avoid cancellation, use |
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) |
* to compute the worse one. |
*/ |
s = sin(x); |
c = cos(x); |
ss = s-c; |
cc = s+c; |
/* |
* j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) |
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) |
*/ |
if(ix<0x7fe00000) { /* make sure x+x not overflow */ |
z = -cos(x+x); |
if ((s*c)<zero) cc = z/ss; |
else ss = z/cc; |
} |
if(ix>0x48000000) z = (invsqrtpi*ss)/__ieee754_sqrt(x); |
else { |
u = pzero(x); v = qzero(x); |
z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrt(x); |
} |
return z; |
} |
if(ix<=0x3e400000) { /* x < 2**-27 */ |
return(u00 + tpi*__ieee754_log(x)); |
} |
z = x*x; |
u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06))))); |
v = one+z*(v01+z*(v02+z*(v03+z*v04))); |
return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x))); |
} |
/* The asymptotic expansions of pzero is |
* 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. |
* For x >= 2, We approximate pzero by |
* pzero(x) = 1 + (R/S) |
* where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10 |
* S = 1 + pS0*s^2 + ... + pS4*s^10 |
* and |
* | pzero(x)-1-R/S | <= 2 ** ( -60.26) |
*/ |
#ifdef __STDC__ |
static const double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#else |
static double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#endif |
0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ |
-7.03124999999900357484e-02, /* 0xBFB1FFFF, 0xFFFFFD32 */ |
-8.08167041275349795626e+00, /* 0xC02029D0, 0xB44FA779 */ |
-2.57063105679704847262e+02, /* 0xC0701102, 0x7B19E863 */ |
-2.48521641009428822144e+03, /* 0xC0A36A6E, 0xCD4DCAFC */ |
-5.25304380490729545272e+03, /* 0xC0B4850B, 0x36CC643D */ |
}; |
#ifdef __STDC__ |
static const double pS8[5] = { |
#else |
static double pS8[5] = { |
#endif |
1.16534364619668181717e+02, /* 0x405D2233, 0x07A96751 */ |
3.83374475364121826715e+03, /* 0x40ADF37D, 0x50596938 */ |
4.05978572648472545552e+04, /* 0x40E3D2BB, 0x6EB6B05F */ |
1.16752972564375915681e+05, /* 0x40FC810F, 0x8F9FA9BD */ |
4.76277284146730962675e+04, /* 0x40E74177, 0x4F2C49DC */ |
}; |
#ifdef __STDC__ |
static const double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#else |
static double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#endif |
-1.14125464691894502584e-11, /* 0xBDA918B1, 0x47E495CC */ |
-7.03124940873599280078e-02, /* 0xBFB1FFFF, 0xE69AFBC6 */ |
-4.15961064470587782438e+00, /* 0xC010A370, 0xF90C6BBF */ |
-6.76747652265167261021e+01, /* 0xC050EB2F, 0x5A7D1783 */ |
-3.31231299649172967747e+02, /* 0xC074B3B3, 0x6742CC63 */ |
-3.46433388365604912451e+02, /* 0xC075A6EF, 0x28A38BD7 */ |
}; |
#ifdef __STDC__ |
static const double pS5[5] = { |
#else |
static double pS5[5] = { |
#endif |
6.07539382692300335975e+01, /* 0x404E6081, 0x0C98C5DE */ |
1.05125230595704579173e+03, /* 0x40906D02, 0x5C7E2864 */ |
5.97897094333855784498e+03, /* 0x40B75AF8, 0x8FBE1D60 */ |
9.62544514357774460223e+03, /* 0x40C2CCB8, 0xFA76FA38 */ |
2.40605815922939109441e+03, /* 0x40A2CC1D, 0xC70BE864 */ |
}; |
#ifdef __STDC__ |
static const double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#else |
static double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#endif |
-2.54704601771951915620e-09, /* 0xBE25E103, 0x6FE1AA86 */ |
-7.03119616381481654654e-02, /* 0xBFB1FFF6, 0xF7C0E24B */ |
-2.40903221549529611423e+00, /* 0xC00345B2, 0xAEA48074 */ |
-2.19659774734883086467e+01, /* 0xC035F74A, 0x4CB94E14 */ |
-5.80791704701737572236e+01, /* 0xC04D0A22, 0x420A1A45 */ |
-3.14479470594888503854e+01, /* 0xC03F72AC, 0xA892D80F */ |
}; |
#ifdef __STDC__ |
static const double pS3[5] = { |
#else |
static double pS3[5] = { |
#endif |
3.58560338055209726349e+01, /* 0x4041ED92, 0x84077DD3 */ |
3.61513983050303863820e+02, /* 0x40769839, 0x464A7C0E */ |
1.19360783792111533330e+03, /* 0x4092A66E, 0x6D1061D6 */ |
1.12799679856907414432e+03, /* 0x40919FFC, 0xB8C39B7E */ |
1.73580930813335754692e+02, /* 0x4065B296, 0xFC379081 */ |
}; |
#ifdef __STDC__ |
static const double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#else |
static double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#endif |
-8.87534333032526411254e-08, /* 0xBE77D316, 0xE927026D */ |
-7.03030995483624743247e-02, /* 0xBFB1FF62, 0x495E1E42 */ |
-1.45073846780952986357e+00, /* 0xBFF73639, 0x8A24A843 */ |
-7.63569613823527770791e+00, /* 0xC01E8AF3, 0xEDAFA7F3 */ |
-1.11931668860356747786e+01, /* 0xC02662E6, 0xC5246303 */ |
-3.23364579351335335033e+00, /* 0xC009DE81, 0xAF8FE70F */ |
}; |
#ifdef __STDC__ |
static const double pS2[5] = { |
#else |
static double pS2[5] = { |
#endif |
2.22202997532088808441e+01, /* 0x40363865, 0x908B5959 */ |
1.36206794218215208048e+02, /* 0x4061069E, 0x0EE8878F */ |
2.70470278658083486789e+02, /* 0x4070E786, 0x42EA079B */ |
1.53875394208320329881e+02, /* 0x40633C03, 0x3AB6FAFF */ |
1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */ |
}; |
#ifdef __STDC__ |
static double pzero(double x) |
#else |
static double pzero(x) |
double x; |
#endif |
{ |
#ifdef __STDC__ |
const double *p,*q; |
#else |
double *p,*q; |
#endif |
double z,r,s; |
__int32_t ix; |
GET_HIGH_WORD(ix,x); |
ix &= 0x7fffffff; |
if(ix>=0x40200000) {p = pR8; q= pS8;} |
else if(ix>=0x40122E8B){p = pR5; q= pS5;} |
else if(ix>=0x4006DB6D){p = pR3; q= pS3;} |
else {p = pR2; q= pS2;} |
z = one/(x*x); |
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); |
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); |
return one+ r/s; |
} |
/* For x >= 8, the asymptotic expansions of qzero is |
* -1/8 s + 75/1024 s^3 - ..., where s = 1/x. |
* We approximate qzero by |
* qzero(x) = s*(-1.25 + (R/S)) |
* where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10 |
* S = 1 + qS0*s^2 + ... + qS5*s^12 |
* and |
* | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) |
*/ |
#ifdef __STDC__ |
static const double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#else |
static double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#endif |
0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ |
7.32421874999935051953e-02, /* 0x3FB2BFFF, 0xFFFFFE2C */ |
1.17682064682252693899e+01, /* 0x40278952, 0x5BB334D6 */ |
5.57673380256401856059e+02, /* 0x40816D63, 0x15301825 */ |
8.85919720756468632317e+03, /* 0x40C14D99, 0x3E18F46D */ |
3.70146267776887834771e+04, /* 0x40E212D4, 0x0E901566 */ |
}; |
#ifdef __STDC__ |
static const double qS8[6] = { |
#else |
static double qS8[6] = { |
#endif |
1.63776026895689824414e+02, /* 0x406478D5, 0x365B39BC */ |
8.09834494656449805916e+03, /* 0x40BFA258, 0x4E6B0563 */ |
1.42538291419120476348e+05, /* 0x41016652, 0x54D38C3F */ |
8.03309257119514397345e+05, /* 0x412883DA, 0x83A52B43 */ |
8.40501579819060512818e+05, /* 0x4129A66B, 0x28DE0B3D */ |
-3.43899293537866615225e+05, /* 0xC114FD6D, 0x2C9530C5 */ |
}; |
#ifdef __STDC__ |
static const double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#else |
static double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#endif |
1.84085963594515531381e-11, /* 0x3DB43D8F, 0x29CC8CD9 */ |
7.32421766612684765896e-02, /* 0x3FB2BFFF, 0xD172B04C */ |
5.83563508962056953777e+00, /* 0x401757B0, 0xB9953DD3 */ |
1.35111577286449829671e+02, /* 0x4060E392, 0x0A8788E9 */ |
1.02724376596164097464e+03, /* 0x40900CF9, 0x9DC8C481 */ |
1.98997785864605384631e+03, /* 0x409F17E9, 0x53C6E3A6 */ |
}; |
#ifdef __STDC__ |
static const double qS5[6] = { |
#else |
static double qS5[6] = { |
#endif |
8.27766102236537761883e+01, /* 0x4054B1B3, 0xFB5E1543 */ |
2.07781416421392987104e+03, /* 0x40A03BA0, 0xDA21C0CE */ |
1.88472887785718085070e+04, /* 0x40D267D2, 0x7B591E6D */ |
5.67511122894947329769e+04, /* 0x40EBB5E3, 0x97E02372 */ |
3.59767538425114471465e+04, /* 0x40E19118, 0x1F7A54A0 */ |
-5.35434275601944773371e+03, /* 0xC0B4EA57, 0xBEDBC609 */ |
}; |
#ifdef __STDC__ |
static const double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#else |
static double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#endif |
4.37741014089738620906e-09, /* 0x3E32CD03, 0x6ADECB82 */ |
7.32411180042911447163e-02, /* 0x3FB2BFEE, 0x0E8D0842 */ |
3.34423137516170720929e+00, /* 0x400AC0FC, 0x61149CF5 */ |
4.26218440745412650017e+01, /* 0x40454F98, 0x962DAEDD */ |
1.70808091340565596283e+02, /* 0x406559DB, 0xE25EFD1F */ |
1.66733948696651168575e+02, /* 0x4064D77C, 0x81FA21E0 */ |
}; |
#ifdef __STDC__ |
static const double qS3[6] = { |
#else |
static double qS3[6] = { |
#endif |
4.87588729724587182091e+01, /* 0x40486122, 0xBFE343A6 */ |
7.09689221056606015736e+02, /* 0x40862D83, 0x86544EB3 */ |
3.70414822620111362994e+03, /* 0x40ACF04B, 0xE44DFC63 */ |
6.46042516752568917582e+03, /* 0x40B93C6C, 0xD7C76A28 */ |
2.51633368920368957333e+03, /* 0x40A3A8AA, 0xD94FB1C0 */ |
-1.49247451836156386662e+02, /* 0xC062A7EB, 0x201CF40F */ |
}; |
#ifdef __STDC__ |
static const double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#else |
static double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#endif |
1.50444444886983272379e-07, /* 0x3E84313B, 0x54F76BDB */ |
7.32234265963079278272e-02, /* 0x3FB2BEC5, 0x3E883E34 */ |
1.99819174093815998816e+00, /* 0x3FFFF897, 0xE727779C */ |
1.44956029347885735348e+01, /* 0x402CFDBF, 0xAAF96FE5 */ |
3.16662317504781540833e+01, /* 0x403FAA8E, 0x29FBDC4A */ |
1.62527075710929267416e+01, /* 0x403040B1, 0x71814BB4 */ |
}; |
#ifdef __STDC__ |
static const double qS2[6] = { |
#else |
static double qS2[6] = { |
#endif |
3.03655848355219184498e+01, /* 0x403E5D96, 0xF7C07AED */ |
2.69348118608049844624e+02, /* 0x4070D591, 0xE4D14B40 */ |
8.44783757595320139444e+02, /* 0x408A6645, 0x22B3BF22 */ |
8.82935845112488550512e+02, /* 0x408B977C, 0x9C5CC214 */ |
2.12666388511798828631e+02, /* 0x406A9553, 0x0E001365 */ |
-5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */ |
}; |
#ifdef __STDC__ |
static double qzero(double x) |
#else |
static double qzero(x) |
double x; |
#endif |
{ |
#ifdef __STDC__ |
const double *p,*q; |
#else |
double *p,*q; |
#endif |
double s,r,z; |
__int32_t ix; |
GET_HIGH_WORD(ix,x); |
ix &= 0x7fffffff; |
if(ix>=0x40200000) {p = qR8; q= qS8;} |
else if(ix>=0x40122E8B){p = qR5; q= qS5;} |
else if(ix>=0x4006DB6D){p = qR3; q= qS3;} |
else {p = qR2; q= qS2;} |
z = one/(x*x); |
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); |
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); |
return (-.125 + r/s)/x; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_j1.c |
---|
0,0 → 1,486 |
/* @(#)e_j1.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_j1(x), __ieee754_y1(x) |
* Bessel function of the first and second kinds of order zero. |
* Method -- j1(x): |
* 1. For tiny x, we use j1(x) = x/2 - x^3/16 + x^5/384 - ... |
* 2. Reduce x to |x| since j1(x)=-j1(-x), and |
* for x in (0,2) |
* j1(x) = x/2 + x*z*R0/S0, where z = x*x; |
* (precision: |j1/x - 1/2 - R0/S0 |<2**-61.51 ) |
* for x in (2,inf) |
* j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1)) |
* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1)) |
* where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1) |
* as follow: |
* cos(x1) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) |
* = 1/sqrt(2) * (sin(x) - cos(x)) |
* sin(x1) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) |
* = -1/sqrt(2) * (sin(x) + cos(x)) |
* (To avoid cancellation, use |
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) |
* to compute the worse one.) |
* |
* 3 Special cases |
* j1(nan)= nan |
* j1(0) = 0 |
* j1(inf) = 0 |
* |
* Method -- y1(x): |
* 1. screen out x<=0 cases: y1(0)=-inf, y1(x<0)=NaN |
* 2. For x<2. |
* Since |
* y1(x) = 2/pi*(j1(x)*(ln(x/2)+Euler)-1/x-x/2+5/64*x^3-...) |
* therefore y1(x)-2/pi*j1(x)*ln(x)-1/x is an odd function. |
* We use the following function to approximate y1, |
* y1(x) = x*U(z)/V(z) + (2/pi)*(j1(x)*ln(x)-1/x), z= x^2 |
* where for x in [0,2] (abs err less than 2**-65.89) |
* U(z) = U0[0] + U0[1]*z + ... + U0[4]*z^4 |
* V(z) = 1 + v0[0]*z + ... + v0[4]*z^5 |
* Note: For tiny x, 1/x dominate y1 and hence |
* y1(tiny) = -2/pi/tiny, (choose tiny<2**-54) |
* 3. For x>=2. |
* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1)) |
* where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1) |
* by method mentioned above. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static double pone(double), qone(double); |
#else |
static double pone(), qone(); |
#endif |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
huge = 1e300, |
one = 1.0, |
invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */ |
tpi = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */ |
/* R0/S0 on [0,2] */ |
r00 = -6.25000000000000000000e-02, /* 0xBFB00000, 0x00000000 */ |
r01 = 1.40705666955189706048e-03, /* 0x3F570D9F, 0x98472C61 */ |
r02 = -1.59955631084035597520e-05, /* 0xBEF0C5C6, 0xBA169668 */ |
r03 = 4.96727999609584448412e-08, /* 0x3E6AAAFA, 0x46CA0BD9 */ |
s01 = 1.91537599538363460805e-02, /* 0x3F939D0B, 0x12637E53 */ |
s02 = 1.85946785588630915560e-04, /* 0x3F285F56, 0xB9CDF664 */ |
s03 = 1.17718464042623683263e-06, /* 0x3EB3BFF8, 0x333F8498 */ |
s04 = 5.04636257076217042715e-09, /* 0x3E35AC88, 0xC97DFF2C */ |
s05 = 1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */ |
#ifdef __STDC__ |
static const double zero = 0.0; |
#else |
static double zero = 0.0; |
#endif |
#ifdef __STDC__ |
double __ieee754_j1(double x) |
#else |
double __ieee754_j1(x) |
double x; |
#endif |
{ |
double z, s,c,ss,cc,r,u,v,y; |
__int32_t hx,ix; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix>=0x7ff00000) return one/x; |
y = fabs(x); |
if(ix >= 0x40000000) { /* |x| >= 2.0 */ |
s = sin(y); |
c = cos(y); |
ss = -s-c; |
cc = s-c; |
if(ix<0x7fe00000) { /* make sure y+y not overflow */ |
z = cos(y+y); |
if ((s*c)>zero) cc = z/ss; |
else ss = z/cc; |
} |
/* |
* j1(x) = 1/__ieee754_sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / __ieee754_sqrt(x) |
* y1(x) = 1/__ieee754_sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / __ieee754_sqrt(x) |
*/ |
if(ix>0x48000000) z = (invsqrtpi*cc)/__ieee754_sqrt(y); |
else { |
u = pone(y); v = qone(y); |
z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrt(y); |
} |
if(hx<0) return -z; |
else return z; |
} |
if(ix<0x3e400000) { /* |x|<2**-27 */ |
if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */ |
} |
z = x*x; |
r = z*(r00+z*(r01+z*(r02+z*r03))); |
s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05)))); |
r *= x; |
return(x*0.5+r/s); |
} |
#ifdef __STDC__ |
static const double U0[5] = { |
#else |
static double U0[5] = { |
#endif |
-1.96057090646238940668e-01, /* 0xBFC91866, 0x143CBC8A */ |
5.04438716639811282616e-02, /* 0x3FA9D3C7, 0x76292CD1 */ |
-1.91256895875763547298e-03, /* 0xBF5F55E5, 0x4844F50F */ |
2.35252600561610495928e-05, /* 0x3EF8AB03, 0x8FA6B88E */ |
-9.19099158039878874504e-08, /* 0xBE78AC00, 0x569105B8 */ |
}; |
#ifdef __STDC__ |
static const double V0[5] = { |
#else |
static double V0[5] = { |
#endif |
1.99167318236649903973e-02, /* 0x3F94650D, 0x3F4DA9F0 */ |
2.02552581025135171496e-04, /* 0x3F2A8C89, 0x6C257764 */ |
1.35608801097516229404e-06, /* 0x3EB6C05A, 0x894E8CA6 */ |
6.22741452364621501295e-09, /* 0x3E3ABF1D, 0x5BA69A86 */ |
1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */ |
}; |
#ifdef __STDC__ |
double __ieee754_y1(double x) |
#else |
double __ieee754_y1(x) |
double x; |
#endif |
{ |
double z, s,c,ss,cc,u,v; |
__int32_t hx,ix,lx; |
EXTRACT_WORDS(hx,lx,x); |
ix = 0x7fffffff&hx; |
/* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ |
if(ix>=0x7ff00000) return one/(x+x*x); |
if((ix|lx)==0) return -one/zero; |
if(hx<0) return zero/zero; |
if(ix >= 0x40000000) { /* |x| >= 2.0 */ |
s = sin(x); |
c = cos(x); |
ss = -s-c; |
cc = s-c; |
if(ix<0x7fe00000) { /* make sure x+x not overflow */ |
z = cos(x+x); |
if ((s*c)>zero) cc = z/ss; |
else ss = z/cc; |
} |
/* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) |
* where x0 = x-3pi/4 |
* Better formula: |
* cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) |
* = 1/sqrt(2) * (sin(x) - cos(x)) |
* sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) |
* = -1/sqrt(2) * (cos(x) + sin(x)) |
* To avoid cancellation, use |
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) |
* to compute the worse one. |
*/ |
if(ix>0x48000000) z = (invsqrtpi*ss)/__ieee754_sqrt(x); |
else { |
u = pone(x); v = qone(x); |
z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrt(x); |
} |
return z; |
} |
if(ix<=0x3c900000) { /* x < 2**-54 */ |
return(-tpi/x); |
} |
z = x*x; |
u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4]))); |
v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4])))); |
return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x)); |
} |
/* For x >= 8, the asymptotic expansions of pone is |
* 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. |
* We approximate pone by |
* pone(x) = 1 + (R/S) |
* where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 |
* S = 1 + ps0*s^2 + ... + ps4*s^10 |
* and |
* | pone(x)-1-R/S | <= 2 ** ( -60.06) |
*/ |
#ifdef __STDC__ |
static const double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#else |
static double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#endif |
0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ |
1.17187499999988647970e-01, /* 0x3FBDFFFF, 0xFFFFFCCE */ |
1.32394806593073575129e+01, /* 0x402A7A9D, 0x357F7FCE */ |
4.12051854307378562225e+02, /* 0x4079C0D4, 0x652EA590 */ |
3.87474538913960532227e+03, /* 0x40AE457D, 0xA3A532CC */ |
7.91447954031891731574e+03, /* 0x40BEEA7A, 0xC32782DD */ |
}; |
#ifdef __STDC__ |
static const double ps8[5] = { |
#else |
static double ps8[5] = { |
#endif |
1.14207370375678408436e+02, /* 0x405C8D45, 0x8E656CAC */ |
3.65093083420853463394e+03, /* 0x40AC85DC, 0x964D274F */ |
3.69562060269033463555e+04, /* 0x40E20B86, 0x97C5BB7F */ |
9.76027935934950801311e+04, /* 0x40F7D42C, 0xB28F17BB */ |
3.08042720627888811578e+04, /* 0x40DE1511, 0x697A0B2D */ |
}; |
#ifdef __STDC__ |
static const double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#else |
static double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#endif |
1.31990519556243522749e-11, /* 0x3DAD0667, 0xDAE1CA7D */ |
1.17187493190614097638e-01, /* 0x3FBDFFFF, 0xE2C10043 */ |
6.80275127868432871736e+00, /* 0x401B3604, 0x6E6315E3 */ |
1.08308182990189109773e+02, /* 0x405B13B9, 0x452602ED */ |
5.17636139533199752805e+02, /* 0x40802D16, 0xD052D649 */ |
5.28715201363337541807e+02, /* 0x408085B8, 0xBB7E0CB7 */ |
}; |
#ifdef __STDC__ |
static const double ps5[5] = { |
#else |
static double ps5[5] = { |
#endif |
5.92805987221131331921e+01, /* 0x404DA3EA, 0xA8AF633D */ |
9.91401418733614377743e+02, /* 0x408EFB36, 0x1B066701 */ |
5.35326695291487976647e+03, /* 0x40B4E944, 0x5706B6FB */ |
7.84469031749551231769e+03, /* 0x40BEA4B0, 0xB8A5BB15 */ |
1.50404688810361062679e+03, /* 0x40978030, 0x036F5E51 */ |
}; |
#ifdef __STDC__ |
static const double pr3[6] = { |
#else |
static double pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#endif |
3.02503916137373618024e-09, /* 0x3E29FC21, 0xA7AD9EDD */ |
1.17186865567253592491e-01, /* 0x3FBDFFF5, 0x5B21D17B */ |
3.93297750033315640650e+00, /* 0x400F76BC, 0xE85EAD8A */ |
3.51194035591636932736e+01, /* 0x40418F48, 0x9DA6D129 */ |
9.10550110750781271918e+01, /* 0x4056C385, 0x4D2C1837 */ |
4.85590685197364919645e+01, /* 0x4048478F, 0x8EA83EE5 */ |
}; |
#ifdef __STDC__ |
static const double ps3[5] = { |
#else |
static double ps3[5] = { |
#endif |
3.47913095001251519989e+01, /* 0x40416549, 0xA134069C */ |
3.36762458747825746741e+02, /* 0x40750C33, 0x07F1A75F */ |
1.04687139975775130551e+03, /* 0x40905B7C, 0x5037D523 */ |
8.90811346398256432622e+02, /* 0x408BD67D, 0xA32E31E9 */ |
1.03787932439639277504e+02, /* 0x4059F26D, 0x7C2EED53 */ |
}; |
#ifdef __STDC__ |
static const double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#else |
static double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#endif |
1.07710830106873743082e-07, /* 0x3E7CE9D4, 0xF65544F4 */ |
1.17176219462683348094e-01, /* 0x3FBDFF42, 0xBE760D83 */ |
2.36851496667608785174e+00, /* 0x4002F2B7, 0xF98FAEC0 */ |
1.22426109148261232917e+01, /* 0x40287C37, 0x7F71A964 */ |
1.76939711271687727390e+01, /* 0x4031B1A8, 0x177F8EE2 */ |
5.07352312588818499250e+00, /* 0x40144B49, 0xA574C1FE */ |
}; |
#ifdef __STDC__ |
static const double ps2[5] = { |
#else |
static double ps2[5] = { |
#endif |
2.14364859363821409488e+01, /* 0x40356FBD, 0x8AD5ECDC */ |
1.25290227168402751090e+02, /* 0x405F5293, 0x14F92CD5 */ |
2.32276469057162813669e+02, /* 0x406D08D8, 0xD5A2DBD9 */ |
1.17679373287147100768e+02, /* 0x405D6B7A, 0xDA1884A9 */ |
8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */ |
}; |
#ifdef __STDC__ |
static double pone(double x) |
#else |
static double pone(x) |
double x; |
#endif |
{ |
#ifdef __STDC__ |
const double *p,*q; |
#else |
double *p,*q; |
#endif |
double z,r,s; |
__int32_t ix; |
GET_HIGH_WORD(ix,x); |
ix &= 0x7fffffff; |
if(ix>=0x40200000) {p = pr8; q= ps8;} |
else if(ix>=0x40122E8B){p = pr5; q= ps5;} |
else if(ix>=0x4006DB6D){p = pr3; q= ps3;} |
else {p = pr2; q= ps2;} |
z = one/(x*x); |
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); |
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); |
return one+ r/s; |
} |
/* For x >= 8, the asymptotic expansions of qone is |
* 3/8 s - 105/1024 s^3 - ..., where s = 1/x. |
* We approximate qone by |
* qone(x) = s*(0.375 + (R/S)) |
* where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10 |
* S = 1 + qs1*s^2 + ... + qs6*s^12 |
* and |
* | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) |
*/ |
#ifdef __STDC__ |
static const double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#else |
static double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#endif |
0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ |
-1.02539062499992714161e-01, /* 0xBFBA3FFF, 0xFFFFFDF3 */ |
-1.62717534544589987888e+01, /* 0xC0304591, 0xA26779F7 */ |
-7.59601722513950107896e+02, /* 0xC087BCD0, 0x53E4B576 */ |
-1.18498066702429587167e+04, /* 0xC0C724E7, 0x40F87415 */ |
-4.84385124285750353010e+04, /* 0xC0E7A6D0, 0x65D09C6A */ |
}; |
#ifdef __STDC__ |
static const double qs8[6] = { |
#else |
static double qs8[6] = { |
#endif |
1.61395369700722909556e+02, /* 0x40642CA6, 0xDE5BCDE5 */ |
7.82538599923348465381e+03, /* 0x40BE9162, 0xD0D88419 */ |
1.33875336287249578163e+05, /* 0x4100579A, 0xB0B75E98 */ |
7.19657723683240939863e+05, /* 0x4125F653, 0x72869C19 */ |
6.66601232617776375264e+05, /* 0x412457D2, 0x7719AD5C */ |
-2.94490264303834643215e+05, /* 0xC111F969, 0x0EA5AA18 */ |
}; |
#ifdef __STDC__ |
static const double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#else |
static double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#endif |
-2.08979931141764104297e-11, /* 0xBDB6FA43, 0x1AA1A098 */ |
-1.02539050241375426231e-01, /* 0xBFBA3FFF, 0xCB597FEF */ |
-8.05644828123936029840e+00, /* 0xC0201CE6, 0xCA03AD4B */ |
-1.83669607474888380239e+02, /* 0xC066F56D, 0x6CA7B9B0 */ |
-1.37319376065508163265e+03, /* 0xC09574C6, 0x6931734F */ |
-2.61244440453215656817e+03, /* 0xC0A468E3, 0x88FDA79D */ |
}; |
#ifdef __STDC__ |
static const double qs5[6] = { |
#else |
static double qs5[6] = { |
#endif |
8.12765501384335777857e+01, /* 0x405451B2, 0xFF5A11B2 */ |
1.99179873460485964642e+03, /* 0x409F1F31, 0xE77BF839 */ |
1.74684851924908907677e+04, /* 0x40D10F1F, 0x0D64CE29 */ |
4.98514270910352279316e+04, /* 0x40E8576D, 0xAABAD197 */ |
2.79480751638918118260e+04, /* 0x40DB4B04, 0xCF7C364B */ |
-4.71918354795128470869e+03, /* 0xC0B26F2E, 0xFCFFA004 */ |
}; |
#ifdef __STDC__ |
static const double qr3[6] = { |
#else |
static double qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#endif |
-5.07831226461766561369e-09, /* 0xBE35CFA9, 0xD38FC84F */ |
-1.02537829820837089745e-01, /* 0xBFBA3FEB, 0x51AEED54 */ |
-4.61011581139473403113e+00, /* 0xC01270C2, 0x3302D9FF */ |
-5.78472216562783643212e+01, /* 0xC04CEC71, 0xC25D16DA */ |
-2.28244540737631695038e+02, /* 0xC06C87D3, 0x4718D55F */ |
-2.19210128478909325622e+02, /* 0xC06B66B9, 0x5F5C1BF6 */ |
}; |
#ifdef __STDC__ |
static const double qs3[6] = { |
#else |
static double qs3[6] = { |
#endif |
4.76651550323729509273e+01, /* 0x4047D523, 0xCCD367E4 */ |
6.73865112676699709482e+02, /* 0x40850EEB, 0xC031EE3E */ |
3.38015286679526343505e+03, /* 0x40AA684E, 0x448E7C9A */ |
5.54772909720722782367e+03, /* 0x40B5ABBA, 0xA61D54A6 */ |
1.90311919338810798763e+03, /* 0x409DBC7A, 0x0DD4DF4B */ |
-1.35201191444307340817e+02, /* 0xC060E670, 0x290A311F */ |
}; |
#ifdef __STDC__ |
static const double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#else |
static double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#endif |
-1.78381727510958865572e-07, /* 0xBE87F126, 0x44C626D2 */ |
-1.02517042607985553460e-01, /* 0xBFBA3E8E, 0x9148B010 */ |
-2.75220568278187460720e+00, /* 0xC0060484, 0x69BB4EDA */ |
-1.96636162643703720221e+01, /* 0xC033A9E2, 0xC168907F */ |
-4.23253133372830490089e+01, /* 0xC04529A3, 0xDE104AAA */ |
-2.13719211703704061733e+01, /* 0xC0355F36, 0x39CF6E52 */ |
}; |
#ifdef __STDC__ |
static const double qs2[6] = { |
#else |
static double qs2[6] = { |
#endif |
2.95333629060523854548e+01, /* 0x403D888A, 0x78AE64FF */ |
2.52981549982190529136e+02, /* 0x406F9F68, 0xDB821CBA */ |
7.57502834868645436472e+02, /* 0x4087AC05, 0xCE49A0F7 */ |
7.39393205320467245656e+02, /* 0x40871B25, 0x48D4C029 */ |
1.55949003336666123687e+02, /* 0x40637E5E, 0x3C3ED8D4 */ |
-4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */ |
}; |
#ifdef __STDC__ |
static double qone(double x) |
#else |
static double qone(x) |
double x; |
#endif |
{ |
#ifdef __STDC__ |
const double *p,*q; |
#else |
double *p,*q; |
#endif |
double s,r,z; |
__int32_t ix; |
GET_HIGH_WORD(ix,x); |
ix &= 0x7fffffff; |
if(ix>=0x40200000) {p = qr8; q= qs8;} |
else if(ix>=0x40122E8B){p = qr5; q= qs5;} |
else if(ix>=0x4006DB6D){p = qr3; q= qs3;} |
else {p = qr2; q= qs2;} |
z = one/(x*x); |
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); |
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); |
return (.375 + r/s)/x; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_jn.c |
---|
0,0 → 1,281 |
/* @(#)e_jn.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* __ieee754_jn(n, x), __ieee754_yn(n, x) |
* floating point Bessel's function of the 1st and 2nd kind |
* of order n |
* |
* Special cases: |
* y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; |
* y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. |
* Note 2. About jn(n,x), yn(n,x) |
* For n=0, j0(x) is called, |
* for n=1, j1(x) is called, |
* for n<x, forward recursion us used starting |
* from values of j0(x) and j1(x). |
* for n>x, a continued fraction approximation to |
* j(n,x)/j(n-1,x) is evaluated and then backward |
* recursion is used starting from a supposed value |
* for j(n,x). The resulting value of j(0,x) is |
* compared with the actual value to correct the |
* supposed value of j(n,x). |
* |
* yn(n,x) is similar in all respects, except |
* that forward recursion is used for all |
* values of n>1. |
* |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */ |
two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */ |
one = 1.00000000000000000000e+00; /* 0x3FF00000, 0x00000000 */ |
#ifdef __STDC__ |
static const double zero = 0.00000000000000000000e+00; |
#else |
static double zero = 0.00000000000000000000e+00; |
#endif |
#ifdef __STDC__ |
double __ieee754_jn(int n, double x) |
#else |
double __ieee754_jn(n,x) |
int n; double x; |
#endif |
{ |
__int32_t i,hx,ix,lx, sgn; |
double a, b, temp, di; |
double z, w; |
/* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) |
* Thus, J(-n,x) = J(n,-x) |
*/ |
EXTRACT_WORDS(hx,lx,x); |
ix = 0x7fffffff&hx; |
/* if J(n,NaN) is NaN */ |
if((ix|((__uint32_t)(lx|-lx))>>31)>0x7ff00000) return x+x; |
if(n<0){ |
n = -n; |
x = -x; |
hx ^= 0x80000000; |
} |
if(n==0) return(__ieee754_j0(x)); |
if(n==1) return(__ieee754_j1(x)); |
sgn = (n&1)&(hx>>31); /* even n -- 0, odd n -- sign(x) */ |
x = fabs(x); |
if((ix|lx)==0||ix>=0x7ff00000) /* if x is 0 or inf */ |
b = zero; |
else if((double)n<=x) { |
/* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ |
if(ix>=0x52D00000) { /* x > 2**302 */ |
/* (x >> n**2) |
* Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) |
* Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) |
* Let s=sin(x), c=cos(x), |
* xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then |
* |
* n sin(xn)*sqt2 cos(xn)*sqt2 |
* ---------------------------------- |
* 0 s-c c+s |
* 1 -s-c -c+s |
* 2 -s+c -c-s |
* 3 s+c c-s |
*/ |
switch(n&3) { |
case 0: temp = cos(x)+sin(x); break; |
case 1: temp = -cos(x)+sin(x); break; |
case 2: temp = -cos(x)-sin(x); break; |
case 3: temp = cos(x)-sin(x); break; |
} |
b = invsqrtpi*temp/__ieee754_sqrt(x); |
} else { |
a = __ieee754_j0(x); |
b = __ieee754_j1(x); |
for(i=1;i<n;i++){ |
temp = b; |
b = b*((double)(i+i)/x) - a; /* avoid underflow */ |
a = temp; |
} |
} |
} else { |
if(ix<0x3e100000) { /* x < 2**-29 */ |
/* x is tiny, return the first Taylor expansion of J(n,x) |
* J(n,x) = 1/n!*(x/2)^n - ... |
*/ |
if(n>33) /* underflow */ |
b = zero; |
else { |
temp = x*0.5; b = temp; |
for (a=one,i=2;i<=n;i++) { |
a *= (double)i; /* a = n! */ |
b *= temp; /* b = (x/2)^n */ |
} |
b = b/a; |
} |
} else { |
/* use backward recurrence */ |
/* x x^2 x^2 |
* J(n,x)/J(n-1,x) = ---- ------ ------ ..... |
* 2n - 2(n+1) - 2(n+2) |
* |
* 1 1 1 |
* (for large x) = ---- ------ ------ ..... |
* 2n 2(n+1) 2(n+2) |
* -- - ------ - ------ - |
* x x x |
* |
* Let w = 2n/x and h=2/x, then the above quotient |
* is equal to the continued fraction: |
* 1 |
* = ----------------------- |
* 1 |
* w - ----------------- |
* 1 |
* w+h - --------- |
* w+2h - ... |
* |
* To determine how many terms needed, let |
* Q(0) = w, Q(1) = w(w+h) - 1, |
* Q(k) = (w+k*h)*Q(k-1) - Q(k-2), |
* When Q(k) > 1e4 good for single |
* When Q(k) > 1e9 good for double |
* When Q(k) > 1e17 good for quadruple |
*/ |
/* determine k */ |
double t,v; |
double q0,q1,h,tmp; __int32_t k,m; |
w = (n+n)/(double)x; h = 2.0/(double)x; |
q0 = w; z = w+h; q1 = w*z - 1.0; k=1; |
while(q1<1.0e9) { |
k += 1; z += h; |
tmp = z*q1 - q0; |
q0 = q1; |
q1 = tmp; |
} |
m = n+n; |
for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t); |
a = t; |
b = one; |
/* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) |
* Hence, if n*(log(2n/x)) > ... |
* single 8.8722839355e+01 |
* double 7.09782712893383973096e+02 |
* long double 1.1356523406294143949491931077970765006170e+04 |
* then recurrent value may overflow and the result is |
* likely underflow to zero |
*/ |
tmp = n; |
v = two/x; |
tmp = tmp*__ieee754_log(fabs(v*tmp)); |
if(tmp<7.09782712893383973096e+02) { |
for(i=n-1,di=(double)(i+i);i>0;i--){ |
temp = b; |
b *= di; |
b = b/x - a; |
a = temp; |
di -= two; |
} |
} else { |
for(i=n-1,di=(double)(i+i);i>0;i--){ |
temp = b; |
b *= di; |
b = b/x - a; |
a = temp; |
di -= two; |
/* scale b to avoid spurious overflow */ |
if(b>1e100) { |
a /= b; |
t /= b; |
b = one; |
} |
} |
} |
b = (t*__ieee754_j0(x)/b); |
} |
} |
if(sgn==1) return -b; else return b; |
} |
#ifdef __STDC__ |
double __ieee754_yn(int n, double x) |
#else |
double __ieee754_yn(n,x) |
int n; double x; |
#endif |
{ |
__int32_t i,hx,ix,lx; |
__int32_t sign; |
double a, b, temp; |
EXTRACT_WORDS(hx,lx,x); |
ix = 0x7fffffff&hx; |
/* if Y(n,NaN) is NaN */ |
if((ix|((__uint32_t)(lx|-lx))>>31)>0x7ff00000) return x+x; |
if((ix|lx)==0) return -one/zero; |
if(hx<0) return zero/zero; |
sign = 1; |
if(n<0){ |
n = -n; |
sign = 1 - ((n&1)<<1); |
} |
if(n==0) return(__ieee754_y0(x)); |
if(n==1) return(sign*__ieee754_y1(x)); |
if(ix==0x7ff00000) return zero; |
if(ix>=0x52D00000) { /* x > 2**302 */ |
/* (x >> n**2) |
* Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) |
* Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) |
* Let s=sin(x), c=cos(x), |
* xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then |
* |
* n sin(xn)*sqt2 cos(xn)*sqt2 |
* ---------------------------------- |
* 0 s-c c+s |
* 1 -s-c -c+s |
* 2 -s+c -c-s |
* 3 s+c c-s |
*/ |
switch(n&3) { |
case 0: temp = sin(x)-cos(x); break; |
case 1: temp = -sin(x)-cos(x); break; |
case 2: temp = -sin(x)+cos(x); break; |
case 3: temp = sin(x)+cos(x); break; |
} |
b = invsqrtpi*temp/__ieee754_sqrt(x); |
} else { |
__uint32_t high; |
a = __ieee754_y0(x); |
b = __ieee754_y1(x); |
/* quit if b is -inf */ |
GET_HIGH_WORD(high,b); |
for(i=1;i<n&&high!=0xfff00000;i++){ |
temp = b; |
b = ((double)(i+i)/x)*b - a; |
GET_HIGH_WORD(high,b); |
a = temp; |
} |
} |
if(sign>0) return b; else return -b; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_log.c |
---|
0,0 → 1,146 |
/* @(#)e_log.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_log(x) |
* Return the logrithm of x |
* |
* Method : |
* 1. Argument Reduction: find k and f such that |
* x = 2^k * (1+f), |
* where sqrt(2)/2 < 1+f < sqrt(2) . |
* |
* 2. Approximation of log(1+f). |
* Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) |
* = 2s + 2/3 s**3 + 2/5 s**5 + ....., |
* = 2s + s*R |
* We use a special Reme algorithm on [0,0.1716] to generate |
* a polynomial of degree 14 to approximate R The maximum error |
* of this polynomial approximation is bounded by 2**-58.45. In |
* other words, |
* 2 4 6 8 10 12 14 |
* R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s |
* (the values of Lg1 to Lg7 are listed in the program) |
* and |
* | 2 14 | -58.45 |
* | Lg1*s +...+Lg7*s - R(z) | <= 2 |
* | | |
* Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. |
* In order to guarantee error in log below 1ulp, we compute log |
* by |
* log(1+f) = f - s*(f - R) (if f is not too large) |
* log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy) |
* |
* 3. Finally, log(x) = k*ln2 + log(1+f). |
* = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo))) |
* Here ln2 is split into two floating point number: |
* ln2_hi + ln2_lo, |
* where n*ln2_hi is always exact for |n| < 2000. |
* |
* Special cases: |
* log(x) is NaN with signal if x < 0 (including -INF) ; |
* log(+INF) is +INF; log(0) is -INF with signal; |
* log(NaN) is that NaN with no signal. |
* |
* Accuracy: |
* according to an error analysis, the error is always less than |
* 1 ulp (unit in the last place). |
* |
* Constants: |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ |
ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ |
two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ |
Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ |
Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ |
Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ |
Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ |
Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ |
Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ |
Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ |
#ifdef __STDC__ |
static const double zero = 0.0; |
#else |
static double zero = 0.0; |
#endif |
#ifdef __STDC__ |
double __ieee754_log(double x) |
#else |
double __ieee754_log(x) |
double x; |
#endif |
{ |
double hfsq,f,s,z,R,w,t1,t2,dk; |
__int32_t k,hx,i,j; |
__uint32_t lx; |
EXTRACT_WORDS(hx,lx,x); |
k=0; |
if (hx < 0x00100000) { /* x < 2**-1022 */ |
if (((hx&0x7fffffff)|lx)==0) |
return -two54/zero; /* log(+-0)=-inf */ |
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */ |
k -= 54; x *= two54; /* subnormal number, scale up x */ |
GET_HIGH_WORD(hx,x); |
} |
if (hx >= 0x7ff00000) return x+x; |
k += (hx>>20)-1023; |
hx &= 0x000fffff; |
i = (hx+0x95f64)&0x100000; |
SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */ |
k += (i>>20); |
f = x-1.0; |
if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */ |
if(f==zero) { if(k==0) return zero; else {dk=(double)k; |
return dk*ln2_hi+dk*ln2_lo;}} |
R = f*f*(0.5-0.33333333333333333*f); |
if(k==0) return f-R; else {dk=(double)k; |
return dk*ln2_hi-((R-dk*ln2_lo)-f);} |
} |
s = f/(2.0+f); |
dk = (double)k; |
z = s*s; |
i = hx-0x6147a; |
w = z*z; |
j = 0x6b851-hx; |
t1= w*(Lg2+w*(Lg4+w*Lg6)); |
t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); |
i |= j; |
R = t2+t1; |
if(i>0) { |
hfsq=0.5*f*f; |
if(k==0) return f-(hfsq-s*(hfsq+R)); else |
return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f); |
} else { |
if(k==0) return f-s*(f-R); else |
return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f); |
} |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_log10.c |
---|
0,0 → 1,98 |
/* @(#)e_log10.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_log10(x) |
* Return the base 10 logarithm of x |
* |
* Method : |
* Let log10_2hi = leading 40 bits of log10(2) and |
* log10_2lo = log10(2) - log10_2hi, |
* ivln10 = 1/log(10) rounded. |
* Then |
* n = ilogb(x), |
* if(n<0) n = n+1; |
* x = scalbn(x,-n); |
* log10(x) := n*log10_2hi + (n*log10_2lo + ivln10*log(x)) |
* |
* Note 1: |
* To guarantee log10(10**n)=n, where 10**n is normal, the rounding |
* mode must set to Round-to-Nearest. |
* Note 2: |
* [1/log(10)] rounded to 53 bits has error .198 ulps; |
* log10 is monotonic at all binary break points. |
* |
* Special cases: |
* log10(x) is NaN with signal if x < 0; |
* log10(+INF) is +INF with no signal; log10(0) is -INF with signal; |
* log10(NaN) is that NaN with no signal; |
* log10(10**N) = N for N=0,1,...,22. |
* |
* Constants: |
* The hexadecimal values are the intended ones for the following constants. |
* The decimal values may be used, provided that the compiler will convert |
* from decimal to binary accurately enough to produce the hexadecimal values |
* shown. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ |
ivln10 = 4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */ |
log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */ |
log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */ |
#ifdef __STDC__ |
static const double zero = 0.0; |
#else |
static double zero = 0.0; |
#endif |
#ifdef __STDC__ |
double __ieee754_log10(double x) |
#else |
double __ieee754_log10(x) |
double x; |
#endif |
{ |
double y,z; |
__int32_t i,k,hx; |
__uint32_t lx; |
EXTRACT_WORDS(hx,lx,x); |
k=0; |
if (hx < 0x00100000) { /* x < 2**-1022 */ |
if (((hx&0x7fffffff)|lx)==0) |
return -two54/zero; /* log(+-0)=-inf */ |
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */ |
k -= 54; x *= two54; /* subnormal number, scale up x */ |
GET_HIGH_WORD(hx,x); |
} |
if (hx >= 0x7ff00000) return x+x; |
k += (hx>>20)-1023; |
i = ((__uint32_t)k&0x80000000)>>31; |
hx = (hx&0x000fffff)|((0x3ff-i)<<20); |
y = (double)(k+i); |
SET_HIGH_WORD(x,hx); |
z = y*log10_2lo + ivln10*__ieee754_log(x); |
return z+y*log10_2hi; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_pow.c |
---|
0,0 → 1,315 |
/* @(#)e_pow.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_pow(x,y) return x**y |
* |
* n |
* Method: Let x = 2 * (1+f) |
* 1. Compute and return log2(x) in two pieces: |
* log2(x) = w1 + w2, |
* where w1 has 53-24 = 29 bit trailing zeros. |
* 2. Perform y*log2(x) = n+y' by simulating multi-precision |
* arithmetic, where |y'|<=0.5. |
* 3. Return x**y = 2**n*exp(y'*log2) |
* |
* Special cases: |
* 1. (anything) ** 0 is 1 |
* 2. (anything) ** 1 is itself |
* 3a. (anything) ** NAN is NAN except |
* 3b. +1 ** NAN is 1 |
* 4. NAN ** (anything except 0) is NAN |
* 5. +-(|x| > 1) ** +INF is +INF |
* 6. +-(|x| > 1) ** -INF is +0 |
* 7. +-(|x| < 1) ** +INF is +0 |
* 8. +-(|x| < 1) ** -INF is +INF |
* 9. +-1 ** +-INF is 1 |
* 10. +0 ** (+anything except 0, NAN) is +0 |
* 11. -0 ** (+anything except 0, NAN, odd integer) is +0 |
* 12. +0 ** (-anything except 0, NAN) is +INF |
* 13. -0 ** (-anything except 0, NAN, odd integer) is +INF |
* 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) |
* 15. +INF ** (+anything except 0,NAN) is +INF |
* 16. +INF ** (-anything except 0,NAN) is +0 |
* 17. -INF ** (anything) = -0 ** (-anything) |
* 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) |
* 19. (-anything except 0 and inf) ** (non-integer) is NAN |
* |
* Accuracy: |
* pow(x,y) returns x**y nearly rounded. In particular |
* pow(integer,integer) |
* always returns the correct integer provided it is |
* representable. |
* |
* Constants : |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
bp[] = {1.0, 1.5,}, |
dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ |
dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ |
zero = 0.0, |
one = 1.0, |
two = 2.0, |
two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ |
huge = 1.0e300, |
tiny = 1.0e-300, |
/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ |
L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */ |
L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */ |
L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */ |
L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */ |
L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */ |
L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */ |
P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ |
P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ |
P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ |
P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ |
P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */ |
lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ |
lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */ |
lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */ |
ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */ |
cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ |
cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */ |
cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ |
ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */ |
ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ |
ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ |
#ifdef __STDC__ |
double __ieee754_pow(double x, double y) |
#else |
double __ieee754_pow(x,y) |
double x, y; |
#endif |
{ |
double z,ax,z_h,z_l,p_h,p_l; |
double y1,t1,t2,r,s,t,u,v,w; |
__int32_t i,j,k,yisint,n; |
__int32_t hx,hy,ix,iy; |
__uint32_t lx,ly; |
EXTRACT_WORDS(hx,lx,x); |
EXTRACT_WORDS(hy,ly,y); |
ix = hx&0x7fffffff; iy = hy&0x7fffffff; |
/* y==zero: x**0 = 1 */ |
if((iy|ly)==0) return one; |
/* x|y==NaN return NaN unless x==1 then return 1 */ |
if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || |
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) { |
if(((ix-0x3ff00000)|lx)==0) return one; |
else return nan(""); |
} |
/* determine if y is an odd int when x < 0 |
* yisint = 0 ... y is not an integer |
* yisint = 1 ... y is an odd int |
* yisint = 2 ... y is an even int |
*/ |
yisint = 0; |
if(hx<0) { |
if(iy>=0x43400000) yisint = 2; /* even integer y */ |
else if(iy>=0x3ff00000) { |
k = (iy>>20)-0x3ff; /* exponent */ |
if(k>20) { |
j = ly>>(52-k); |
if((j<<(52-k))==ly) yisint = 2-(j&1); |
} else if(ly==0) { |
j = iy>>(20-k); |
if((j<<(20-k))==iy) yisint = 2-(j&1); |
} |
} |
} |
/* special value of y */ |
if(ly==0) { |
if (iy==0x7ff00000) { /* y is +-inf */ |
if(((ix-0x3ff00000)|lx)==0) |
return one; /* +-1**+-inf = 1 */ |
else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ |
return (hy>=0)? y: zero; |
else /* (|x|<1)**-,+inf = inf,0 */ |
return (hy<0)?-y: zero; |
} |
if(iy==0x3ff00000) { /* y is +-1 */ |
if(hy<0) return one/x; else return x; |
} |
if(hy==0x40000000) return x*x; /* y is 2 */ |
if(hy==0x3fe00000) { /* y is 0.5 */ |
if(hx>=0) /* x >= +0 */ |
return __ieee754_sqrt(x); |
} |
} |
ax = fabs(x); |
/* special value of x */ |
if(lx==0) { |
if(ix==0x7ff00000||ix==0||ix==0x3ff00000){ |
z = ax; /*x is +-0,+-inf,+-1*/ |
if(hy<0) z = one/z; /* z = (1/|x|) */ |
if(hx<0) { |
if(((ix-0x3ff00000)|yisint)==0) { |
z = (z-z)/(z-z); /* (-1)**non-int is NaN */ |
} else if(yisint==1) |
z = -z; /* (x<0)**odd = -(|x|**odd) */ |
} |
return z; |
} |
} |
/* (x<0)**(non-int) is NaN */ |
/* REDHAT LOCAL: This used to be |
if((((hx>>31)+1)|yisint)==0) return (x-x)/(x-x); |
but ANSI C says a right shift of a signed negative quantity is |
implementation defined. */ |
if(((((__uint32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); |
/* |y| is huge */ |
if(iy>0x41e00000) { /* if |y| > 2**31 */ |
if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */ |
if(ix<=0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; |
if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; |
} |
/* over/underflow if x is not close to one */ |
if(ix<0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; |
if(ix>0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; |
/* now |1-x| is tiny <= 2**-20, suffice to compute |
log(x) by x-x^2/2+x^3/3-x^4/4 */ |
t = ax-1; /* t has 20 trailing zeros */ |
w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25)); |
u = ivln2_h*t; /* ivln2_h has 21 sig. bits */ |
v = t*ivln2_l-w*ivln2; |
t1 = u+v; |
SET_LOW_WORD(t1,0); |
t2 = v-(t1-u); |
} else { |
double s2,s_h,s_l,t_h,t_l; |
n = 0; |
/* take care subnormal number */ |
if(ix<0x00100000) |
{ax *= two53; n -= 53; GET_HIGH_WORD(ix,ax); } |
n += ((ix)>>20)-0x3ff; |
j = ix&0x000fffff; |
/* determine interval */ |
ix = j|0x3ff00000; /* normalize ix */ |
if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */ |
else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */ |
else {k=0;n+=1;ix -= 0x00100000;} |
SET_HIGH_WORD(ax,ix); |
/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ |
u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ |
v = one/(ax+bp[k]); |
s = u*v; |
s_h = s; |
SET_LOW_WORD(s_h,0); |
/* t_h=ax+bp[k] High */ |
t_h = zero; |
SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18)); |
t_l = ax - (t_h-bp[k]); |
s_l = v*((u-s_h*t_h)-s_h*t_l); |
/* compute log(ax) */ |
s2 = s*s; |
r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); |
r += s_l*(s_h+s); |
s2 = s_h*s_h; |
t_h = 3.0+s2+r; |
SET_LOW_WORD(t_h,0); |
t_l = r-((t_h-3.0)-s2); |
/* u+v = s*(1+...) */ |
u = s_h*t_h; |
v = s_l*t_h+t_l*s; |
/* 2/(3log2)*(s+...) */ |
p_h = u+v; |
SET_LOW_WORD(p_h,0); |
p_l = v-(p_h-u); |
z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ |
z_l = cp_l*p_h+p_l*cp+dp_l[k]; |
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ |
t = (double)n; |
t1 = (((z_h+z_l)+dp_h[k])+t); |
SET_LOW_WORD(t1,0); |
t2 = z_l-(((t1-t)-dp_h[k])-z_h); |
} |
s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ |
if(((((__uint32_t)hx>>31)-1)|(yisint-1))==0) |
s = -one;/* (-ve)**(odd int) */ |
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ |
y1 = y; |
SET_LOW_WORD(y1,0); |
p_l = (y-y1)*t1+y*t2; |
p_h = y1*t1; |
z = p_l+p_h; |
EXTRACT_WORDS(j,i,z); |
if (j>=0x40900000) { /* z >= 1024 */ |
if(((j-0x40900000)|i)!=0) /* if z > 1024 */ |
return s*huge*huge; /* overflow */ |
else { |
if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */ |
} |
} else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */ |
if(((j-0xc090cc00)|i)!=0) /* z < -1075 */ |
return s*tiny*tiny; /* underflow */ |
else { |
if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */ |
} |
} |
/* |
* compute 2**(p_h+p_l) |
*/ |
i = j&0x7fffffff; |
k = (i>>20)-0x3ff; |
n = 0; |
if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */ |
n = j+(0x00100000>>(k+1)); |
k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */ |
t = zero; |
SET_HIGH_WORD(t,n&~(0x000fffff>>k)); |
n = ((n&0x000fffff)|0x00100000)>>(20-k); |
if(j<0) n = -n; |
p_h -= t; |
} |
t = p_l+p_h; |
SET_LOW_WORD(t,0); |
u = t*lg2_h; |
v = (p_l-(t-p_h))*lg2+t*lg2_l; |
z = u+v; |
w = v-(z-u); |
t = z*z; |
t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); |
r = (z*t1)/(t1-two)-(w+z*w); |
z = one-(r-z); |
GET_HIGH_WORD(j,z); |
j += (n<<20); |
if((j>>20)<=0) z = scalbn(z,(int)n); /* subnormal output */ |
else SET_HIGH_WORD(z,j); |
return s*z; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_rem_pio2.c |
---|
0,0 → 1,185 |
/* @(#)e_rem_pio2.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* __ieee754_rem_pio2(x,y) |
* |
* return the remainder of x rem pi/2 in y[0]+y[1] |
* use __kernel_rem_pio2() |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
/* |
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi |
*/ |
#ifdef __STDC__ |
static const __int32_t two_over_pi[] = { |
#else |
static __int32_t two_over_pi[] = { |
#endif |
0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, |
0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, |
0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, |
0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, |
0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, |
0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, |
0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, |
0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, |
0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, |
0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, |
0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, |
}; |
#ifdef __STDC__ |
static const __int32_t npio2_hw[] = { |
#else |
static __int32_t npio2_hw[] = { |
#endif |
0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C, |
0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C, |
0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A, |
0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C, |
0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB, |
0x404858EB, 0x404921FB, |
}; |
/* |
* invpio2: 53 bits of 2/pi |
* pio2_1: first 33 bit of pi/2 |
* pio2_1t: pi/2 - pio2_1 |
* pio2_2: second 33 bit of pi/2 |
* pio2_2t: pi/2 - (pio2_1+pio2_2) |
* pio2_3: third 33 bit of pi/2 |
* pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) |
*/ |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ |
half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ |
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ |
invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */ |
pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */ |
pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */ |
pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */ |
pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */ |
pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */ |
pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ |
#ifdef __STDC__ |
__int32_t __ieee754_rem_pio2(double x, double *y) |
#else |
__int32_t __ieee754_rem_pio2(x,y) |
double x,y[]; |
#endif |
{ |
double z = 0.0,w,t,r,fn; |
double tx[3]; |
__int32_t i,j,n,ix,hx; |
int e0,nx; |
__uint32_t low; |
GET_HIGH_WORD(hx,x); /* high word of x */ |
ix = hx&0x7fffffff; |
if(ix<=0x3fe921fb) /* |x| ~<= pi/4 , no need for reduction */ |
{y[0] = x; y[1] = 0; return 0;} |
if(ix<0x4002d97c) { /* |x| < 3pi/4, special case with n=+-1 */ |
if(hx>0) { |
z = x - pio2_1; |
if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */ |
y[0] = z - pio2_1t; |
y[1] = (z-y[0])-pio2_1t; |
} else { /* near pi/2, use 33+33+53 bit pi */ |
z -= pio2_2; |
y[0] = z - pio2_2t; |
y[1] = (z-y[0])-pio2_2t; |
} |
return 1; |
} else { /* negative x */ |
z = x + pio2_1; |
if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */ |
y[0] = z + pio2_1t; |
y[1] = (z-y[0])+pio2_1t; |
} else { /* near pi/2, use 33+33+53 bit pi */ |
z += pio2_2; |
y[0] = z + pio2_2t; |
y[1] = (z-y[0])+pio2_2t; |
} |
return -1; |
} |
} |
if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */ |
t = fabs(x); |
n = (__int32_t) (t*invpio2+half); |
fn = (double)n; |
r = t-fn*pio2_1; |
w = fn*pio2_1t; /* 1st round good to 85 bit */ |
if(n<32&&ix!=npio2_hw[n-1]) { |
y[0] = r-w; /* quick check no cancellation */ |
} else { |
__uint32_t high; |
j = ix>>20; |
y[0] = r-w; |
GET_HIGH_WORD(high,y[0]); |
i = j-((high>>20)&0x7ff); |
if(i>16) { /* 2nd iteration needed, good to 118 */ |
t = r; |
w = fn*pio2_2; |
r = t-w; |
w = fn*pio2_2t-((t-r)-w); |
y[0] = r-w; |
GET_HIGH_WORD(high,y[0]); |
i = j-((high>>20)&0x7ff); |
if(i>49) { /* 3rd iteration need, 151 bits acc */ |
t = r; /* will cover all possible cases */ |
w = fn*pio2_3; |
r = t-w; |
w = fn*pio2_3t-((t-r)-w); |
y[0] = r-w; |
} |
} |
} |
y[1] = (r-y[0])-w; |
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} |
else return n; |
} |
/* |
* all other (large) arguments |
*/ |
if(ix>=0x7ff00000) { /* x is inf or NaN */ |
y[0]=y[1]=x-x; return 0; |
} |
/* set z = scalbn(|x|,ilogb(x)-23) */ |
GET_LOW_WORD(low,x); |
SET_LOW_WORD(z,low); |
e0 = (int)((ix>>20)-1046); /* e0 = ilogb(z)-23; */ |
SET_HIGH_WORD(z, ix - ((__int32_t)e0<<20)); |
for(i=0;i<2;i++) { |
tx[i] = (double)((__int32_t)(z)); |
z = (z-tx[i])*two24; |
} |
tx[2] = z; |
nx = 3; |
while(tx[nx-1]==zero) nx--; /* skip zero term */ |
n = __kernel_rem_pio2(tx,y,e0,nx,2,two_over_pi); |
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} |
return n; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_remainder.c |
---|
0,0 → 1,80 |
/* @(#)e_remainder.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_remainder(x,p) |
* Return : |
* returns x REM p = x - [x/p]*p as if in infinite |
* precise arithmetic, where [x/p] is the (infinite bit) |
* integer nearest x/p (in half way case choose the even one). |
* Method : |
* Based on fmod() return x-[x/p]chopped*p exactlp. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double zero = 0.0; |
#else |
static double zero = 0.0; |
#endif |
#ifdef __STDC__ |
double __ieee754_remainder(double x, double p) |
#else |
double __ieee754_remainder(x,p) |
double x,p; |
#endif |
{ |
__int32_t hx,hp; |
__uint32_t sx,lx,lp; |
double p_half; |
EXTRACT_WORDS(hx,lx,x); |
EXTRACT_WORDS(hp,lp,p); |
sx = hx&0x80000000; |
hp &= 0x7fffffff; |
hx &= 0x7fffffff; |
/* purge off exception values */ |
if((hp|lp)==0) return (x*p)/(x*p); /* p = 0 */ |
if((hx>=0x7ff00000)|| /* x not finite */ |
((hp>=0x7ff00000)&& /* p is NaN */ |
(((hp-0x7ff00000)|lp)!=0))) |
return (x*p)/(x*p); |
if (hp<=0x7fdfffff) x = __ieee754_fmod(x,p+p); /* now x < 2p */ |
if (((hx-hp)|(lx-lp))==0) return zero*x; |
x = fabs(x); |
p = fabs(p); |
if (hp<0x00200000) { |
if(x+x>p) { |
x-=p; |
if(x+x>=p) x -= p; |
} |
} else { |
p_half = 0.5*p; |
if(x>p_half) { |
x-=p; |
if(x>=p_half) x -= p; |
} |
} |
GET_HIGH_WORD(hx,x); |
SET_HIGH_WORD(x,hx^sx); |
return x; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_scalb.c |
---|
0,0 → 1,55 |
/* @(#)e_scalb.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* __ieee754_scalb(x, fn) is provide for |
* passing various standard test suite. One |
* should use scalbn() instead. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef _SCALB_INT |
#ifdef __STDC__ |
double __ieee754_scalb(double x, int fn) |
#else |
double __ieee754_scalb(x,fn) |
double x; int fn; |
#endif |
#else |
#ifdef __STDC__ |
double __ieee754_scalb(double x, double fn) |
#else |
double __ieee754_scalb(x,fn) |
double x, fn; |
#endif |
#endif |
{ |
#ifdef _SCALB_INT |
return scalbn(x,fn); |
#else |
if (isnan(x)||isnan(fn)) return x*fn; |
if (!finite(fn)) { |
if(fn>0.0) return x*fn; |
else return x/(-fn); |
} |
if (rint(fn)!=fn) return (fn-fn)/(fn-fn); |
if ( fn > 65000.0) return scalbn(x, 65000); |
if (-fn > 65000.0) return scalbn(x,-65000); |
return scalbn(x,(int)fn); |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_sinh.c |
---|
0,0 → 1,86 |
/* @(#)e_sinh.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_sinh(x) |
* Method : |
* mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2 |
* 1. Replace x by |x| (sinh(-x) = -sinh(x)). |
* 2. |
* E + E/(E+1) |
* 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x) |
* 2 |
* |
* 22 <= x <= lnovft : sinh(x) := exp(x)/2 |
* lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2) |
* ln2ovft < x : sinh(x) := x*shuge (overflow) |
* |
* Special cases: |
* sinh(x) is |x| if x is +INF, -INF, or NaN. |
* only sinh(0)=0 is exact for finite x. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double one = 1.0, shuge = 1.0e307; |
#else |
static double one = 1.0, shuge = 1.0e307; |
#endif |
#ifdef __STDC__ |
double __ieee754_sinh(double x) |
#else |
double __ieee754_sinh(x) |
double x; |
#endif |
{ |
double t,w,h; |
__int32_t ix,jx; |
__uint32_t lx; |
/* High word of |x|. */ |
GET_HIGH_WORD(jx,x); |
ix = jx&0x7fffffff; |
/* x is INF or NaN */ |
if(ix>=0x7ff00000) return x+x; |
h = 0.5; |
if (jx<0) h = -h; |
/* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */ |
if (ix < 0x40360000) { /* |x|<22 */ |
if (ix<0x3e300000) /* |x|<2**-28 */ |
if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */ |
t = expm1(fabs(x)); |
if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one)); |
return h*(t+t/(t+one)); |
} |
/* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */ |
if (ix < 0x40862E42) return h*__ieee754_exp(fabs(x)); |
/* |x| in [log(maxdouble), overflowthresold] */ |
GET_LOW_WORD(lx,x); |
if (ix<0x408633CE || (ix==0x408633ce && lx<=(__uint32_t)0x8fb9f87d)) { |
w = __ieee754_exp(0.5*fabs(x)); |
t = h*w; |
return t*w; |
} |
/* |x| > overflowthresold, sinh(x) overflow */ |
return x*shuge; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/e_sqrt.c |
---|
0,0 → 1,452 |
/* @(#)e_sqrt.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __ieee754_sqrt(x) |
* Return correctly rounded sqrt. |
* ------------------------------------------ |
* | Use the hardware sqrt if you have one | |
* ------------------------------------------ |
* Method: |
* Bit by bit method using integer arithmetic. (Slow, but portable) |
* 1. Normalization |
* Scale x to y in [1,4) with even powers of 2: |
* find an integer k such that 1 <= (y=x*2^(2k)) < 4, then |
* sqrt(x) = 2^k * sqrt(y) |
* 2. Bit by bit computation |
* Let q = sqrt(y) truncated to i bit after binary point (q = 1), |
* i 0 |
* i+1 2 |
* s = 2*q , and y = 2 * ( y - q ). (1) |
* i i i i |
* |
* To compute q from q , one checks whether |
* i+1 i |
* |
* -(i+1) 2 |
* (q + 2 ) <= y. (2) |
* i |
* -(i+1) |
* If (2) is false, then q = q ; otherwise q = q + 2 . |
* i+1 i i+1 i |
* |
* With some algebric manipulation, it is not difficult to see |
* that (2) is equivalent to |
* -(i+1) |
* s + 2 <= y (3) |
* i i |
* |
* The advantage of (3) is that s and y can be computed by |
* i i |
* the following recurrence formula: |
* if (3) is false |
* |
* s = s , y = y ; (4) |
* i+1 i i+1 i |
* |
* otherwise, |
* -i -(i+1) |
* s = s + 2 , y = y - s - 2 (5) |
* i+1 i i+1 i i |
* |
* One may easily use induction to prove (4) and (5). |
* Note. Since the left hand side of (3) contain only i+2 bits, |
* it does not necessary to do a full (53-bit) comparison |
* in (3). |
* 3. Final rounding |
* After generating the 53 bits result, we compute one more bit. |
* Together with the remainder, we can decide whether the |
* result is exact, bigger than 1/2ulp, or less than 1/2ulp |
* (it will never equal to 1/2ulp). |
* The rounding mode can be detected by checking whether |
* huge + tiny is equal to huge, and whether huge - tiny is |
* equal to huge for some floating point number "huge" and "tiny". |
* |
* Special cases: |
* sqrt(+-0) = +-0 ... exact |
* sqrt(inf) = inf |
* sqrt(-ve) = NaN ... with invalid signal |
* sqrt(NaN) = NaN ... with invalid signal for signaling NaN |
* |
* Other methods : see the appended file at the end of the program below. |
*--------------- |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double one = 1.0, tiny=1.0e-300; |
#else |
static double one = 1.0, tiny=1.0e-300; |
#endif |
#ifdef __STDC__ |
double __ieee754_sqrt(double x) |
#else |
double __ieee754_sqrt(x) |
double x; |
#endif |
{ |
double z; |
__int32_t sign = (int)0x80000000; |
__uint32_t r,t1,s1,ix1,q1; |
__int32_t ix0,s0,q,m,t,i; |
EXTRACT_WORDS(ix0,ix1,x); |
/* take care of Inf and NaN */ |
if((ix0&0x7ff00000)==0x7ff00000) { |
return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf |
sqrt(-inf)=sNaN */ |
} |
/* take care of zero */ |
if(ix0<=0) { |
if(((ix0&(~sign))|ix1)==0) return x;/* sqrt(+-0) = +-0 */ |
else if(ix0<0) |
return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ |
} |
/* normalize x */ |
m = (ix0>>20); |
if(m==0) { /* subnormal x */ |
while(ix0==0) { |
m -= 21; |
ix0 |= (ix1>>11); ix1 <<= 21; |
} |
for(i=0;(ix0&0x00100000)==0;i++) ix0<<=1; |
m -= i-1; |
ix0 |= (ix1>>(32-i)); |
ix1 <<= i; |
} |
m -= 1023; /* unbias exponent */ |
ix0 = (ix0&0x000fffff)|0x00100000; |
if(m&1){ /* odd m, double x to make it even */ |
ix0 += ix0 + ((ix1&sign)>>31); |
ix1 += ix1; |
} |
m >>= 1; /* m = [m/2] */ |
/* generate sqrt(x) bit by bit */ |
ix0 += ix0 + ((ix1&sign)>>31); |
ix1 += ix1; |
q = q1 = s0 = s1 = 0; /* [q,q1] = sqrt(x) */ |
r = 0x00200000; /* r = moving bit from right to left */ |
while(r!=0) { |
t = s0+r; |
if(t<=ix0) { |
s0 = t+r; |
ix0 -= t; |
q += r; |
} |
ix0 += ix0 + ((ix1&sign)>>31); |
ix1 += ix1; |
r>>=1; |
} |
r = sign; |
while(r!=0) { |
t1 = s1+r; |
t = s0; |
if((t<ix0)||((t==ix0)&&(t1<=ix1))) { |
s1 = t1+r; |
if(((t1&sign)==sign)&&(s1&sign)==0) s0 += 1; |
ix0 -= t; |
if (ix1 < t1) ix0 -= 1; |
ix1 -= t1; |
q1 += r; |
} |
ix0 += ix0 + ((ix1&sign)>>31); |
ix1 += ix1; |
r>>=1; |
} |
/* use floating add to find out rounding direction */ |
if((ix0|ix1)!=0) { |
z = one-tiny; /* trigger inexact flag */ |
if (z>=one) { |
z = one+tiny; |
if (q1==(__uint32_t)0xffffffff) { q1=0; q += 1;} |
else if (z>one) { |
if (q1==(__uint32_t)0xfffffffe) q+=1; |
q1+=2; |
} else |
q1 += (q1&1); |
} |
} |
ix0 = (q>>1)+0x3fe00000; |
ix1 = q1>>1; |
if ((q&1)==1) ix1 |= sign; |
ix0 += (m <<20); |
INSERT_WORDS(z,ix0,ix1); |
return z; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/* |
Other methods (use floating-point arithmetic) |
------------- |
(This is a copy of a drafted paper by Prof W. Kahan |
and K.C. Ng, written in May, 1986) |
Two algorithms are given here to implement sqrt(x) |
(IEEE double precision arithmetic) in software. |
Both supply sqrt(x) correctly rounded. The first algorithm (in |
Section A) uses newton iterations and involves four divisions. |
The second one uses reciproot iterations to avoid division, but |
requires more multiplications. Both algorithms need the ability |
to chop results of arithmetic operations instead of round them, |
and the INEXACT flag to indicate when an arithmetic operation |
is executed exactly with no roundoff error, all part of the |
standard (IEEE 754-1985). The ability to perform shift, add, |
subtract and logical AND operations upon 32-bit words is needed |
too, though not part of the standard. |
A. sqrt(x) by Newton Iteration |
(1) Initial approximation |
Let x0 and x1 be the leading and the trailing 32-bit words of |
a floating point number x (in IEEE double format) respectively |
1 11 52 ...widths |
------------------------------------------------------ |
x: |s| e | f | |
------------------------------------------------------ |
msb lsb msb lsb ...order |
------------------------ ------------------------ |
x0: |s| e | f1 | x1: | f2 | |
------------------------ ------------------------ |
By performing shifts and subtracts on x0 and x1 (both regarded |
as integers), we obtain an 8-bit approximation of sqrt(x) as |
follows. |
k := (x0>>1) + 0x1ff80000; |
y0 := k - T1[31&(k>>15)]. ... y ~ sqrt(x) to 8 bits |
Here k is a 32-bit integer and T1[] is an integer array containing |
correction terms. Now magically the floating value of y (y's |
leading 32-bit word is y0, the value of its trailing word is 0) |
approximates sqrt(x) to almost 8-bit. |
Value of T1: |
static int T1[32]= { |
0, 1024, 3062, 5746, 9193, 13348, 18162, 23592, |
29598, 36145, 43202, 50740, 58733, 67158, 75992, 85215, |
83599, 71378, 60428, 50647, 41945, 34246, 27478, 21581, |
16499, 12183, 8588, 5674, 3403, 1742, 661, 130,}; |
(2) Iterative refinement |
Apply Heron's rule three times to y, we have y approximates |
sqrt(x) to within 1 ulp (Unit in the Last Place): |
y := (y+x/y)/2 ... almost 17 sig. bits |
y := (y+x/y)/2 ... almost 35 sig. bits |
y := y-(y-x/y)/2 ... within 1 ulp |
Remark 1. |
Another way to improve y to within 1 ulp is: |
y := (y+x/y) ... almost 17 sig. bits to 2*sqrt(x) |
y := y - 0x00100006 ... almost 18 sig. bits to sqrt(x) |
2 |
(x-y )*y |
y := y + 2* ---------- ...within 1 ulp |
2 |
3y + x |
This formula has one division fewer than the one above; however, |
it requires more multiplications and additions. Also x must be |
scaled in advance to avoid spurious overflow in evaluating the |
expression 3y*y+x. Hence it is not recommended uless division |
is slow. If division is very slow, then one should use the |
reciproot algorithm given in section B. |
(3) Final adjustment |
By twiddling y's last bit it is possible to force y to be |
correctly rounded according to the prevailing rounding mode |
as follows. Let r and i be copies of the rounding mode and |
inexact flag before entering the square root program. Also we |
use the expression y+-ulp for the next representable floating |
numbers (up and down) of y. Note that y+-ulp = either fixed |
point y+-1, or multiply y by nextafter(1,+-inf) in chopped |
mode. |
I := FALSE; ... reset INEXACT flag I |
R := RZ; ... set rounding mode to round-toward-zero |
z := x/y; ... chopped quotient, possibly inexact |
If(not I) then { ... if the quotient is exact |
if(z=y) { |
I := i; ... restore inexact flag |
R := r; ... restore rounded mode |
return sqrt(x):=y. |
} else { |
z := z - ulp; ... special rounding |
} |
} |
i := TRUE; ... sqrt(x) is inexact |
If (r=RN) then z=z+ulp ... rounded-to-nearest |
If (r=RP) then { ... round-toward-+inf |
y = y+ulp; z=z+ulp; |
} |
y := y+z; ... chopped sum |
y0:=y0-0x00100000; ... y := y/2 is correctly rounded. |
I := i; ... restore inexact flag |
R := r; ... restore rounded mode |
return sqrt(x):=y. |
(4) Special cases |
Square root of +inf, +-0, or NaN is itself; |
Square root of a negative number is NaN with invalid signal. |
B. sqrt(x) by Reciproot Iteration |
(1) Initial approximation |
Let x0 and x1 be the leading and the trailing 32-bit words of |
a floating point number x (in IEEE double format) respectively |
(see section A). By performing shifs and subtracts on x0 and y0, |
we obtain a 7.8-bit approximation of 1/sqrt(x) as follows. |
k := 0x5fe80000 - (x0>>1); |
y0:= k - T2[63&(k>>14)]. ... y ~ 1/sqrt(x) to 7.8 bits |
Here k is a 32-bit integer and T2[] is an integer array |
containing correction terms. Now magically the floating |
value of y (y's leading 32-bit word is y0, the value of |
its trailing word y1 is set to zero) approximates 1/sqrt(x) |
to almost 7.8-bit. |
Value of T2: |
static int T2[64]= { |
0x1500, 0x2ef8, 0x4d67, 0x6b02, 0x87be, 0xa395, 0xbe7a, 0xd866, |
0xf14a, 0x1091b,0x11fcd,0x13552,0x14999,0x15c98,0x16e34,0x17e5f, |
0x18d03,0x19a01,0x1a545,0x1ae8a,0x1b5c4,0x1bb01,0x1bfde,0x1c28d, |
0x1c2de,0x1c0db,0x1ba73,0x1b11c,0x1a4b5,0x1953d,0x18266,0x16be0, |
0x1683e,0x179d8,0x18a4d,0x19992,0x1a789,0x1b445,0x1bf61,0x1c989, |
0x1d16d,0x1d77b,0x1dddf,0x1e2ad,0x1e5bf,0x1e6e8,0x1e654,0x1e3cd, |
0x1df2a,0x1d635,0x1cb16,0x1be2c,0x1ae4e,0x19bde,0x1868e,0x16e2e, |
0x1527f,0x1334a,0x11051,0xe951, 0xbe01, 0x8e0d, 0x5924, 0x1edd,}; |
(2) Iterative refinement |
Apply Reciproot iteration three times to y and multiply the |
result by x to get an approximation z that matches sqrt(x) |
to about 1 ulp. To be exact, we will have |
-1ulp < sqrt(x)-z<1.0625ulp. |
... set rounding mode to Round-to-nearest |
y := y*(1.5-0.5*x*y*y) ... almost 15 sig. bits to 1/sqrt(x) |
y := y*((1.5-2^-30)+0.5*x*y*y)... about 29 sig. bits to 1/sqrt(x) |
... special arrangement for better accuracy |
z := x*y ... 29 bits to sqrt(x), with z*y<1 |
z := z + 0.5*z*(1-z*y) ... about 1 ulp to sqrt(x) |
Remark 2. The constant 1.5-2^-30 is chosen to bias the error so that |
(a) the term z*y in the final iteration is always less than 1; |
(b) the error in the final result is biased upward so that |
-1 ulp < sqrt(x) - z < 1.0625 ulp |
instead of |sqrt(x)-z|<1.03125ulp. |
(3) Final adjustment |
By twiddling y's last bit it is possible to force y to be |
correctly rounded according to the prevailing rounding mode |
as follows. Let r and i be copies of the rounding mode and |
inexact flag before entering the square root program. Also we |
use the expression y+-ulp for the next representable floating |
numbers (up and down) of y. Note that y+-ulp = either fixed |
point y+-1, or multiply y by nextafter(1,+-inf) in chopped |
mode. |
R := RZ; ... set rounding mode to round-toward-zero |
switch(r) { |
case RN: ... round-to-nearest |
if(x<= z*(z-ulp)...chopped) z = z - ulp; else |
if(x<= z*(z+ulp)...chopped) z = z; else z = z+ulp; |
break; |
case RZ:case RM: ... round-to-zero or round-to--inf |
R:=RP; ... reset rounding mod to round-to-+inf |
if(x<z*z ... rounded up) z = z - ulp; else |
if(x>=(z+ulp)*(z+ulp) ...rounded up) z = z+ulp; |
break; |
case RP: ... round-to-+inf |
if(x>(z+ulp)*(z+ulp)...chopped) z = z+2*ulp; else |
if(x>z*z ...chopped) z = z+ulp; |
break; |
} |
Remark 3. The above comparisons can be done in fixed point. For |
example, to compare x and w=z*z chopped, it suffices to compare |
x1 and w1 (the trailing parts of x and w), regarding them as |
two's complement integers. |
...Is z an exact square root? |
To determine whether z is an exact square root of x, let z1 be the |
trailing part of z, and also let x0 and x1 be the leading and |
trailing parts of x. |
If ((z1&0x03ffffff)!=0) ... not exact if trailing 26 bits of z!=0 |
I := 1; ... Raise Inexact flag: z is not exact |
else { |
j := 1 - [(x0>>20)&1] ... j = logb(x) mod 2 |
k := z1 >> 26; ... get z's 25-th and 26-th |
fraction bits |
I := i or (k&j) or ((k&(j+j+1))!=(x1&3)); |
} |
R:= r ... restore rounded mode |
return sqrt(x):=z. |
If multiplication is cheaper then the foregoing red tape, the |
Inexact flag can be evaluated by |
I := i; |
I := (z*z!=x) or I. |
Note that z*z can overwrite I; this value must be sensed if it is |
True. |
Remark 4. If z*z = x exactly, then bit 25 to bit 0 of z1 must be |
zero. |
-------------------- |
z1: | f2 | |
-------------------- |
bit 31 bit 0 |
Further more, bit 27 and 26 of z1, bit 0 and 1 of x1, and the odd |
or even of logb(x) have the following relations: |
------------------------------------------------- |
bit 27,26 of z1 bit 1,0 of x1 logb(x) |
------------------------------------------------- |
00 00 odd and even |
01 01 even |
10 10 odd |
10 00 even |
11 01 even |
------------------------------------------------- |
(4) Special cases (see (4) of Section A). |
*/ |
/contrib/sdk/sources/libc/math/ef_acos.c |
---|
0,0 → 1,84 |
/* ef_acos.c -- float version of e_acos.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0000000000e+00, /* 0x3F800000 */ |
pi = 3.1415925026e+00, /* 0x40490fda */ |
pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */ |
pio2_lo = 7.5497894159e-08, /* 0x33a22168 */ |
pS0 = 1.6666667163e-01, /* 0x3e2aaaab */ |
pS1 = -3.2556581497e-01, /* 0xbea6b090 */ |
pS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */ |
pS3 = -4.0055535734e-02, /* 0xbd241146 */ |
pS4 = 7.9153501429e-04, /* 0x3a4f7f04 */ |
pS5 = 3.4793309169e-05, /* 0x3811ef08 */ |
qS1 = -2.4033949375e+00, /* 0xc019d139 */ |
qS2 = 2.0209457874e+00, /* 0x4001572d */ |
qS3 = -6.8828397989e-01, /* 0xbf303361 */ |
qS4 = 7.7038154006e-02; /* 0x3d9dc62e */ |
#ifdef __STDC__ |
float __ieee754_acosf(float x) |
#else |
float __ieee754_acosf(x) |
float x; |
#endif |
{ |
float z,p,q,r,w,s,c,df; |
__int32_t hx,ix; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix==0x3f800000) { /* |x|==1 */ |
if(hx>0) return 0.0; /* acos(1) = 0 */ |
else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */ |
} else if(ix>0x3f800000) { /* |x| >= 1 */ |
return (x-x)/(x-x); /* acos(|x|>1) is NaN */ |
} |
if(ix<0x3f000000) { /* |x| < 0.5 */ |
if(ix<=0x23000000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/ |
z = x*x; |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); |
r = p/q; |
return pio2_hi - (x - (pio2_lo-x*r)); |
} else if (hx<0) { /* x < -0.5 */ |
z = (one+x)*(float)0.5; |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); |
s = __ieee754_sqrtf(z); |
r = p/q; |
w = r*s-pio2_lo; |
return pi - (float)2.0*(s+w); |
} else { /* x > 0.5 */ |
__int32_t idf; |
z = (one-x)*(float)0.5; |
s = __ieee754_sqrtf(z); |
df = s; |
GET_FLOAT_WORD(idf,df); |
SET_FLOAT_WORD(df,idf&0xfffff000); |
c = (z-df*df)/(s+df); |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); |
r = p/q; |
w = r*s+c; |
return (float)2.0*(df+w); |
} |
} |
/contrib/sdk/sources/libc/math/ef_acosh.c |
---|
0,0 → 1,53 |
/* ef_acosh.c -- float version of e_acosh.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0, |
ln2 = 6.9314718246e-01; /* 0x3f317218 */ |
#ifdef __STDC__ |
float __ieee754_acoshf(float x) |
#else |
float __ieee754_acoshf(x) |
float x; |
#endif |
{ |
float t; |
__int32_t hx; |
GET_FLOAT_WORD(hx,x); |
if(hx<0x3f800000) { /* x < 1 */ |
return (x-x)/(x-x); |
} else if(hx >=0x4d800000) { /* x > 2**28 */ |
if(!FLT_UWORD_IS_FINITE(hx)) { /* x is inf of NaN */ |
return x+x; |
} else |
return __ieee754_logf(x)+ln2; /* acosh(huge)=log(2x) */ |
} else if (hx==0x3f800000) { |
return 0.0; /* acosh(1) = 0 */ |
} else if (hx > 0x40000000) { /* 2**28 > x > 2 */ |
t=x*x; |
return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one))); |
} else { /* 1<x<2 */ |
t = x-one; |
return log1pf(t+__ieee754_sqrtf((float)2.0*t+t*t)); |
} |
} |
/contrib/sdk/sources/libc/math/ef_asin.c |
---|
0,0 → 1,88 |
/* ef_asin.c -- float version of e_asin.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0000000000e+00, /* 0x3F800000 */ |
huge = 1.000e+30, |
pio2_hi = 1.57079637050628662109375f, |
pio2_lo = -4.37113900018624283e-8f, |
pio4_hi = 0.785398185253143310546875f, |
/* coefficient for R(x^2) */ |
pS0 = 1.6666667163e-01, /* 0x3e2aaaab */ |
pS1 = -3.2556581497e-01, /* 0xbea6b090 */ |
pS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */ |
pS3 = -4.0055535734e-02, /* 0xbd241146 */ |
pS4 = 7.9153501429e-04, /* 0x3a4f7f04 */ |
pS5 = 3.4793309169e-05, /* 0x3811ef08 */ |
qS1 = -2.4033949375e+00, /* 0xc019d139 */ |
qS2 = 2.0209457874e+00, /* 0x4001572d */ |
qS3 = -6.8828397989e-01, /* 0xbf303361 */ |
qS4 = 7.7038154006e-02; /* 0x3d9dc62e */ |
#ifdef __STDC__ |
float __ieee754_asinf(float x) |
#else |
float __ieee754_asinf(x) |
float x; |
#endif |
{ |
float t,w,p,q,c,r,s; |
__int32_t hx,ix; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix==0x3f800000) { |
/* asin(1)=+-pi/2 with inexact */ |
return x*pio2_hi+x*pio2_lo; |
} else if(ix> 0x3f800000) { /* |x|>= 1 */ |
return (x-x)/(x-x); /* asin(|x|>1) is NaN */ |
} else if (ix<0x3f000000) { /* |x|<0.5 */ |
if(ix<0x32000000) { /* if |x| < 2**-27 */ |
if(huge+x>one) return x;/* return x with inexact if x!=0*/ |
} else { |
t = x*x; |
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); |
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); |
w = p/q; |
return x+x*w; |
} |
} |
/* 1> |x|>= 0.5 */ |
w = one-fabsf(x); |
t = w*(float)0.5; |
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); |
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); |
s = __ieee754_sqrtf(t); |
if(ix>=0x3F79999A) { /* if |x| > 0.975 */ |
w = p/q; |
t = pio2_hi-((float)2.0*(s+s*w)-pio2_lo); |
} else { |
__int32_t iw; |
w = s; |
GET_FLOAT_WORD(iw,w); |
SET_FLOAT_WORD(w,iw&0xfffff000); |
c = (t-w*w)/(s+w); |
r = p/q; |
p = (float)2.0*s*r-(pio2_lo-(float)2.0*c); |
q = pio4_hi-(float)2.0*w; |
t = pio4_hi-(p-q); |
} |
if(hx>0) return t; else return -t; |
} |
/contrib/sdk/sources/libc/math/ef_atan2.c |
---|
0,0 → 1,101 |
/* ef_atan2.c -- float version of e_atan2.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
tiny = 1.0e-30, |
zero = 0.0, |
pi_o_4 = 7.8539818525e-01, /* 0x3f490fdb */ |
pi_o_2 = 1.5707963705e+00, /* 0x3fc90fdb */ |
pi = 3.1415927410e+00, /* 0x40490fdb */ |
pi_lo = -8.7422776573e-08; /* 0xb3bbbd2e */ |
#ifdef __STDC__ |
float __ieee754_atan2f(float y, float x) |
#else |
float __ieee754_atan2f(y,x) |
float y,x; |
#endif |
{ |
float z; |
__int32_t k,m,hx,hy,ix,iy; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
GET_FLOAT_WORD(hy,y); |
iy = hy&0x7fffffff; |
if(FLT_UWORD_IS_NAN(ix)|| |
FLT_UWORD_IS_NAN(iy)) /* x or y is NaN */ |
return x+y; |
if(hx==0x3f800000) return atanf(y); /* x=1.0 */ |
m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */ |
/* when y = 0 */ |
if(FLT_UWORD_IS_ZERO(iy)) { |
switch(m) { |
case 0: |
case 1: return y; /* atan(+-0,+anything)=+-0 */ |
case 2: return pi+tiny;/* atan(+0,-anything) = pi */ |
case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */ |
} |
} |
/* when x = 0 */ |
if(FLT_UWORD_IS_ZERO(ix)) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; |
/* when x is INF */ |
if(FLT_UWORD_IS_INFINITE(ix)) { |
if(FLT_UWORD_IS_INFINITE(iy)) { |
switch(m) { |
case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */ |
case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */ |
case 2: return (float)3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/ |
case 3: return (float)-3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/ |
} |
} else { |
switch(m) { |
case 0: return zero ; /* atan(+...,+INF) */ |
case 1: return -zero ; /* atan(-...,+INF) */ |
case 2: return pi+tiny ; /* atan(+...,-INF) */ |
case 3: return -pi-tiny ; /* atan(-...,-INF) */ |
} |
} |
} |
/* when y is INF */ |
if(FLT_UWORD_IS_INFINITE(iy)) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; |
/* compute y/x */ |
k = (iy-ix)>>23; |
if(k > 60) z=pi_o_2+(float)0.5*pi_lo; /* |y/x| > 2**60 */ |
else if(hx<0&&k<-60) z=0.0; /* |y|/x < -2**60 */ |
else z=atanf(fabsf(y/x)); /* safe to do y/x */ |
switch (m) { |
case 0: return z ; /* atan(+,+) */ |
case 1: { |
__uint32_t zh; |
GET_FLOAT_WORD(zh,z); |
SET_FLOAT_WORD(z,zh ^ 0x80000000); |
} |
return z ; /* atan(-,+) */ |
case 2: return pi-(z-pi_lo);/* atan(+,-) */ |
default: /* case 3 */ |
return (z-pi_lo)-pi;/* atan(-,-) */ |
} |
} |
/contrib/sdk/sources/libc/math/ef_atanh.c |
---|
0,0 → 1,54 |
/* ef_atanh.c -- float version of e_atanh.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float one = 1.0, huge = 1e30; |
#else |
static float one = 1.0, huge = 1e30; |
#endif |
#ifdef __STDC__ |
static const float zero = 0.0; |
#else |
static float zero = 0.0; |
#endif |
#ifdef __STDC__ |
float __ieee754_atanhf(float x) |
#else |
float __ieee754_atanhf(x) |
float x; |
#endif |
{ |
float t; |
__int32_t hx,ix; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
if (ix>0x3f800000) /* |x|>1 */ |
return (x-x)/(x-x); |
if(ix==0x3f800000) |
return x/zero; |
if(ix<0x31800000&&(huge+x)>zero) return x; /* x<2**-28 */ |
SET_FLOAT_WORD(x,ix); |
if(ix<0x3f000000) { /* x < 0.5 */ |
t = x+x; |
t = (float)0.5*log1pf(t+t*x/(one-x)); |
} else |
t = (float)0.5*log1pf((x+x)/(one-x)); |
if(hx>=0) return t; else return -t; |
} |
/contrib/sdk/sources/libc/math/ef_cosh.c |
---|
0,0 → 1,71 |
/* ef_cosh.c -- float version of e_cosh.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __v810__ |
#define const |
#endif |
#ifdef __STDC__ |
static const float one = 1.0, half=0.5, huge = 1.0e30; |
#else |
static float one = 1.0, half=0.5, huge = 1.0e30; |
#endif |
#ifdef __STDC__ |
float __ieee754_coshf(float x) |
#else |
float __ieee754_coshf(x) |
float x; |
#endif |
{ |
float t,w; |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
/* x is INF or NaN */ |
if(!FLT_UWORD_IS_FINITE(ix)) return x*x; |
/* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */ |
if(ix<0x3eb17218) { |
t = expm1f(fabsf(x)); |
w = one+t; |
if (ix<0x24000000) return w; /* cosh(tiny) = 1 */ |
return one+(t*t)/(w+w); |
} |
/* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */ |
if (ix < 0x41b00000) { |
t = __ieee754_expf(fabsf(x)); |
return half*t+half/t; |
} |
/* |x| in [22, log(maxdouble)] return half*exp(|x|) */ |
if (ix <= FLT_UWORD_LOG_MAX) |
return half*__ieee754_expf(fabsf(x)); |
/* |x| in [log(maxdouble), overflowthresold] */ |
if (ix <= FLT_UWORD_LOG_2MAX) { |
w = __ieee754_expf(half*fabsf(x)); |
t = half*w; |
return t*w; |
} |
/* |x| > overflowthresold, cosh(x) overflow */ |
return huge*huge; |
} |
/contrib/sdk/sources/libc/math/ef_exp.c |
---|
0,0 → 1,99 |
/* ef_exp.c -- float version of e_exp.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __v810__ |
#define const |
#endif |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0, |
halF[2] = {0.5,-0.5,}, |
huge = 1.0e+30, |
twom100 = 7.8886090522e-31, /* 2**-100=0x0d800000 */ |
ln2HI[2] ={ 6.9313812256e-01, /* 0x3f317180 */ |
-6.9313812256e-01,}, /* 0xbf317180 */ |
ln2LO[2] ={ 9.0580006145e-06, /* 0x3717f7d1 */ |
-9.0580006145e-06,}, /* 0xb717f7d1 */ |
invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */ |
P1 = 1.6666667163e-01, /* 0x3e2aaaab */ |
P2 = -2.7777778450e-03, /* 0xbb360b61 */ |
P3 = 6.6137559770e-05, /* 0x388ab355 */ |
P4 = -1.6533901999e-06, /* 0xb5ddea0e */ |
P5 = 4.1381369442e-08; /* 0x3331bb4c */ |
#ifdef __STDC__ |
float __ieee754_expf(float x) /* default IEEE double exp */ |
#else |
float __ieee754_expf(x) /* default IEEE double exp */ |
float x; |
#endif |
{ |
float y,hi,lo,c,t; |
__int32_t k = 0,xsb,sx; |
__uint32_t hx; |
GET_FLOAT_WORD(sx,x); |
xsb = (sx>>31)&1; /* sign bit of x */ |
hx = sx & 0x7fffffff; /* high word of |x| */ |
/* filter out non-finite argument */ |
if(FLT_UWORD_IS_NAN(hx)) |
return x+x; /* NaN */ |
if(FLT_UWORD_IS_INFINITE(hx)) |
return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */ |
if(sx > FLT_UWORD_LOG_MAX) |
return huge*huge; /* overflow */ |
if(sx < 0 && hx > FLT_UWORD_LOG_MIN) |
return twom100*twom100; /* underflow */ |
/* argument reduction */ |
if(hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */ |
if(hx < 0x3F851592) { /* and |x| < 1.5 ln2 */ |
hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb; |
} else { |
k = invln2*x+halF[xsb]; |
t = k; |
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */ |
lo = t*ln2LO[0]; |
} |
x = hi - lo; |
} |
else if(hx < 0x31800000) { /* when |x|<2**-28 */ |
if(huge+x>one) return one+x;/* trigger inexact */ |
} |
/* x is now in primary range */ |
t = x*x; |
c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); |
if(k==0) return one-((x*c)/(c-(float)2.0)-x); |
else y = one-((lo-(x*c)/((float)2.0-c))-hi); |
if(k >= -125) { |
__uint32_t hy; |
GET_FLOAT_WORD(hy,y); |
SET_FLOAT_WORD(y,hy+(k<<23)); /* add k to y's exponent */ |
return y; |
} else { |
__uint32_t hy; |
GET_FLOAT_WORD(hy,y); |
SET_FLOAT_WORD(y,hy+((k+100)<<23)); /* add k to y's exponent */ |
return y*twom100; |
} |
} |
/contrib/sdk/sources/libc/math/ef_fmod.c |
---|
0,0 → 1,113 |
/* ef_fmod.c -- float version of e_fmod.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* __ieee754_fmodf(x,y) |
* Return x mod y in exact arithmetic |
* Method: shift and subtract |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float one = 1.0, Zero[] = {0.0, -0.0,}; |
#else |
static float one = 1.0, Zero[] = {0.0, -0.0,}; |
#endif |
#ifdef __STDC__ |
float __ieee754_fmodf(float x, float y) |
#else |
float __ieee754_fmodf(x,y) |
float x,y ; |
#endif |
{ |
__int32_t n,hx,hy,hz,ix,iy,sx,i; |
GET_FLOAT_WORD(hx,x); |
GET_FLOAT_WORD(hy,y); |
sx = hx&0x80000000; /* sign of x */ |
hx ^=sx; /* |x| */ |
hy &= 0x7fffffff; /* |y| */ |
/* purge off exception values */ |
if(FLT_UWORD_IS_ZERO(hy)|| |
!FLT_UWORD_IS_FINITE(hx)|| |
FLT_UWORD_IS_NAN(hy)) |
return (x*y)/(x*y); |
if(hx<hy) return x; /* |x|<|y| return x */ |
if(hx==hy) |
return Zero[(__uint32_t)sx>>31]; /* |x|=|y| return x*0*/ |
/* Note: y cannot be zero if we reach here. */ |
/* determine ix = ilogb(x) */ |
if(FLT_UWORD_IS_SUBNORMAL(hx)) { /* subnormal x */ |
for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1; |
} else ix = (hx>>23)-127; |
/* determine iy = ilogb(y) */ |
if(FLT_UWORD_IS_SUBNORMAL(hy)) { /* subnormal y */ |
for (iy = -126,i=(hy<<8); i>=0; i<<=1) iy -=1; |
} else iy = (hy>>23)-127; |
/* set up {hx,lx}, {hy,ly} and align y to x */ |
if(ix >= -126) |
hx = 0x00800000|(0x007fffff&hx); |
else { /* subnormal x, shift x to normal */ |
n = -126-ix; |
hx = hx<<n; |
} |
if(iy >= -126) |
hy = 0x00800000|(0x007fffff&hy); |
else { /* subnormal y, shift y to normal */ |
n = -126-iy; |
hy = hy<<n; |
} |
/* fix point fmod */ |
n = ix - iy; |
while(n--) { |
hz=hx-hy; |
if(hz<0){hx = hx+hx;} |
else { |
if(hz==0) /* return sign(x)*0 */ |
return Zero[(__uint32_t)sx>>31]; |
hx = hz+hz; |
} |
} |
hz=hx-hy; |
if(hz>=0) {hx=hz;} |
/* convert back to floating value and restore the sign */ |
if(hx==0) /* return sign(x)*0 */ |
return Zero[(__uint32_t)sx>>31]; |
while(hx<0x00800000) { /* normalize x */ |
hx = hx+hx; |
iy -= 1; |
} |
if(iy>= -126) { /* normalize output */ |
hx = ((hx-0x00800000)|((iy+127)<<23)); |
SET_FLOAT_WORD(x,hx|sx); |
} else { /* subnormal output */ |
/* If denormals are not supported, this code will generate a |
zero representation. */ |
n = -126 - iy; |
hx >>= n; |
SET_FLOAT_WORD(x,hx|sx); |
x *= one; /* create necessary signal */ |
} |
return x; /* exact output */ |
} |
/contrib/sdk/sources/libc/math/ef_hypot.c |
---|
0,0 → 1,83 |
/* ef_hypot.c -- float version of e_hypot.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float __ieee754_hypotf(float x, float y) |
#else |
float __ieee754_hypotf(x,y) |
float x, y; |
#endif |
{ |
float a=x,b=y,t1,t2,y1,y2,w; |
__int32_t j,k,ha,hb; |
GET_FLOAT_WORD(ha,x); |
ha &= 0x7fffffffL; |
GET_FLOAT_WORD(hb,y); |
hb &= 0x7fffffffL; |
if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;} |
SET_FLOAT_WORD(a,ha); /* a <- |a| */ |
SET_FLOAT_WORD(b,hb); /* b <- |b| */ |
if((ha-hb)>0xf000000L) {return a+b;} /* x/y > 2**30 */ |
k=0; |
if(ha > 0x58800000L) { /* a>2**50 */ |
if(!FLT_UWORD_IS_FINITE(ha)) { /* Inf or NaN */ |
w = a+b; /* for sNaN */ |
if(FLT_UWORD_IS_INFINITE(ha)) w = a; |
if(FLT_UWORD_IS_INFINITE(hb)) w = b; |
return w; |
} |
/* scale a and b by 2**-68 */ |
ha -= 0x22000000L; hb -= 0x22000000L; k += 68; |
SET_FLOAT_WORD(a,ha); |
SET_FLOAT_WORD(b,hb); |
} |
if(hb < 0x26800000L) { /* b < 2**-50 */ |
if(FLT_UWORD_IS_ZERO(hb)) { |
return a; |
} else if(FLT_UWORD_IS_SUBNORMAL(hb)) { |
SET_FLOAT_WORD(t1,0x7e800000L); /* t1=2^126 */ |
b *= t1; |
a *= t1; |
k -= 126; |
} else { /* scale a and b by 2^68 */ |
ha += 0x22000000; /* a *= 2^68 */ |
hb += 0x22000000; /* b *= 2^68 */ |
k -= 68; |
SET_FLOAT_WORD(a,ha); |
SET_FLOAT_WORD(b,hb); |
} |
} |
/* medium size a and b */ |
w = a-b; |
if (w>b) { |
SET_FLOAT_WORD(t1,ha&0xfffff000L); |
t2 = a-t1; |
w = __ieee754_sqrtf(t1*t1-(b*(-b)-t2*(a+t1))); |
} else { |
a = a+a; |
SET_FLOAT_WORD(y1,hb&0xfffff000L); |
y2 = b - y1; |
SET_FLOAT_WORD(t1,ha+0x00800000L); |
t2 = a - t1; |
w = __ieee754_sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b))); |
} |
if(k!=0) { |
SET_FLOAT_WORD(t1,0x3f800000L+(k<<23)); |
return t1*w; |
} else return w; |
} |
/contrib/sdk/sources/libc/math/ef_j0.c |
---|
0,0 → 1,439 |
/* ef_j0.c -- float version of e_j0.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static float pzerof(float), qzerof(float); |
#else |
static float pzerof(), qzerof(); |
#endif |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
huge = 1e30, |
one = 1.0, |
invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */ |
tpi = 6.3661974669e-01, /* 0x3f22f983 */ |
/* R0/S0 on [0, 2.00] */ |
R02 = 1.5625000000e-02, /* 0x3c800000 */ |
R03 = -1.8997929874e-04, /* 0xb947352e */ |
R04 = 1.8295404516e-06, /* 0x35f58e88 */ |
R05 = -4.6183270541e-09, /* 0xb19eaf3c */ |
S01 = 1.5619102865e-02, /* 0x3c7fe744 */ |
S02 = 1.1692678527e-04, /* 0x38f53697 */ |
S03 = 5.1354652442e-07, /* 0x3509daa6 */ |
S04 = 1.1661400734e-09; /* 0x30a045e8 */ |
#ifdef __STDC__ |
static const float zero = 0.0; |
#else |
static float zero = 0.0; |
#endif |
#ifdef __STDC__ |
float __ieee754_j0f(float x) |
#else |
float __ieee754_j0f(x) |
float x; |
#endif |
{ |
float z, s,c,ss,cc,r,u,v; |
__int32_t hx,ix; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(!FLT_UWORD_IS_FINITE(ix)) return one/(x*x); |
x = fabsf(x); |
if(ix >= 0x40000000) { /* |x| >= 2.0 */ |
s = sinf(x); |
c = cosf(x); |
ss = s-c; |
cc = s+c; |
if(ix<=FLT_UWORD_HALF_MAX) { /* make sure x+x not overflow */ |
z = -cosf(x+x); |
if ((s*c)<zero) cc = z/ss; |
else ss = z/cc; |
} |
/* |
* j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) |
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) |
*/ |
if(ix>0x80000000) z = (invsqrtpi*cc)/__ieee754_sqrtf(x); |
else { |
u = pzerof(x); v = qzerof(x); |
z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrtf(x); |
} |
return z; |
} |
if(ix<0x39000000) { /* |x| < 2**-13 */ |
if(huge+x>one) { /* raise inexact if x != 0 */ |
if(ix<0x32000000) return one; /* |x|<2**-27 */ |
else return one - (float)0.25*x*x; |
} |
} |
z = x*x; |
r = z*(R02+z*(R03+z*(R04+z*R05))); |
s = one+z*(S01+z*(S02+z*(S03+z*S04))); |
if(ix < 0x3F800000) { /* |x| < 1.00 */ |
return one + z*((float)-0.25+(r/s)); |
} else { |
u = (float)0.5*x; |
return((one+u)*(one-u)+z*(r/s)); |
} |
} |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
u00 = -7.3804296553e-02, /* 0xbd9726b5 */ |
u01 = 1.7666645348e-01, /* 0x3e34e80d */ |
u02 = -1.3818567619e-02, /* 0xbc626746 */ |
u03 = 3.4745343146e-04, /* 0x39b62a69 */ |
u04 = -3.8140706238e-06, /* 0xb67ff53c */ |
u05 = 1.9559013964e-08, /* 0x32a802ba */ |
u06 = -3.9820518410e-11, /* 0xae2f21eb */ |
v01 = 1.2730483897e-02, /* 0x3c509385 */ |
v02 = 7.6006865129e-05, /* 0x389f65e0 */ |
v03 = 2.5915085189e-07, /* 0x348b216c */ |
v04 = 4.4111031494e-10; /* 0x2ff280c2 */ |
#ifdef __STDC__ |
float __ieee754_y0f(float x) |
#else |
float __ieee754_y0f(x) |
float x; |
#endif |
{ |
float z, s,c,ss,cc,u,v; |
__int32_t hx,ix; |
GET_FLOAT_WORD(hx,x); |
ix = 0x7fffffff&hx; |
/* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */ |
if(!FLT_UWORD_IS_FINITE(ix)) return one/(x+x*x); |
if(FLT_UWORD_IS_ZERO(ix)) return -one/zero; |
if(hx<0) return zero/zero; |
if(ix >= 0x40000000) { /* |x| >= 2.0 */ |
/* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0)) |
* where x0 = x-pi/4 |
* Better formula: |
* cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) |
* = 1/sqrt(2) * (sin(x) + cos(x)) |
* sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) |
* = 1/sqrt(2) * (sin(x) - cos(x)) |
* To avoid cancellation, use |
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) |
* to compute the worse one. |
*/ |
s = sinf(x); |
c = cosf(x); |
ss = s-c; |
cc = s+c; |
/* |
* j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) |
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) |
*/ |
if(ix<=FLT_UWORD_HALF_MAX) { /* make sure x+x not overflow */ |
z = -cosf(x+x); |
if ((s*c)<zero) cc = z/ss; |
else ss = z/cc; |
} |
if(ix>0x80000000) z = (invsqrtpi*ss)/__ieee754_sqrtf(x); |
else { |
u = pzerof(x); v = qzerof(x); |
z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrtf(x); |
} |
return z; |
} |
if(ix<=0x32000000) { /* x < 2**-27 */ |
return(u00 + tpi*__ieee754_logf(x)); |
} |
z = x*x; |
u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06))))); |
v = one+z*(v01+z*(v02+z*(v03+z*v04))); |
return(u/v + tpi*(__ieee754_j0f(x)*__ieee754_logf(x))); |
} |
/* The asymptotic expansions of pzero is |
* 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. |
* For x >= 2, We approximate pzero by |
* pzero(x) = 1 + (R/S) |
* where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10 |
* S = 1 + pS0*s^2 + ... + pS4*s^10 |
* and |
* | pzero(x)-1-R/S | <= 2 ** ( -60.26) |
*/ |
#ifdef __STDC__ |
static const float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#else |
static float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#endif |
0.0000000000e+00, /* 0x00000000 */ |
-7.0312500000e-02, /* 0xbd900000 */ |
-8.0816707611e+00, /* 0xc1014e86 */ |
-2.5706311035e+02, /* 0xc3808814 */ |
-2.4852163086e+03, /* 0xc51b5376 */ |
-5.2530439453e+03, /* 0xc5a4285a */ |
}; |
#ifdef __STDC__ |
static const float pS8[5] = { |
#else |
static float pS8[5] = { |
#endif |
1.1653436279e+02, /* 0x42e91198 */ |
3.8337448730e+03, /* 0x456f9beb */ |
4.0597855469e+04, /* 0x471e95db */ |
1.1675296875e+05, /* 0x47e4087c */ |
4.7627726562e+04, /* 0x473a0bba */ |
}; |
#ifdef __STDC__ |
static const float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#else |
static float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#endif |
-1.1412546255e-11, /* 0xad48c58a */ |
-7.0312492549e-02, /* 0xbd8fffff */ |
-4.1596107483e+00, /* 0xc0851b88 */ |
-6.7674766541e+01, /* 0xc287597b */ |
-3.3123129272e+02, /* 0xc3a59d9b */ |
-3.4643338013e+02, /* 0xc3ad3779 */ |
}; |
#ifdef __STDC__ |
static const float pS5[5] = { |
#else |
static float pS5[5] = { |
#endif |
6.0753936768e+01, /* 0x42730408 */ |
1.0512523193e+03, /* 0x44836813 */ |
5.9789707031e+03, /* 0x45bad7c4 */ |
9.6254453125e+03, /* 0x461665c8 */ |
2.4060581055e+03, /* 0x451660ee */ |
}; |
#ifdef __STDC__ |
static const float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#else |
static float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#endif |
-2.5470459075e-09, /* 0xb12f081b */ |
-7.0311963558e-02, /* 0xbd8fffb8 */ |
-2.4090321064e+00, /* 0xc01a2d95 */ |
-2.1965976715e+01, /* 0xc1afba52 */ |
-5.8079170227e+01, /* 0xc2685112 */ |
-3.1447946548e+01, /* 0xc1fb9565 */ |
}; |
#ifdef __STDC__ |
static const float pS3[5] = { |
#else |
static float pS3[5] = { |
#endif |
3.5856033325e+01, /* 0x420f6c94 */ |
3.6151397705e+02, /* 0x43b4c1ca */ |
1.1936077881e+03, /* 0x44953373 */ |
1.1279968262e+03, /* 0x448cffe6 */ |
1.7358093262e+02, /* 0x432d94b8 */ |
}; |
#ifdef __STDC__ |
static const float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#else |
static float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#endif |
-8.8753431271e-08, /* 0xb3be98b7 */ |
-7.0303097367e-02, /* 0xbd8ffb12 */ |
-1.4507384300e+00, /* 0xbfb9b1cc */ |
-7.6356959343e+00, /* 0xc0f4579f */ |
-1.1193166733e+01, /* 0xc1331736 */ |
-3.2336456776e+00, /* 0xc04ef40d */ |
}; |
#ifdef __STDC__ |
static const float pS2[5] = { |
#else |
static float pS2[5] = { |
#endif |
2.2220300674e+01, /* 0x41b1c32d */ |
1.3620678711e+02, /* 0x430834f0 */ |
2.7047027588e+02, /* 0x43873c32 */ |
1.5387539673e+02, /* 0x4319e01a */ |
1.4657617569e+01, /* 0x416a859a */ |
}; |
#ifdef __STDC__ |
static float pzerof(float x) |
#else |
static float pzerof(x) |
float x; |
#endif |
{ |
#ifdef __STDC__ |
const float *p,*q; |
#else |
float *p,*q; |
#endif |
float z,r,s; |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
if(ix>=0x41000000) {p = pR8; q= pS8;} |
else if(ix>=0x40f71c58){p = pR5; q= pS5;} |
else if(ix>=0x4036db68){p = pR3; q= pS3;} |
else {p = pR2; q= pS2;} |
z = one/(x*x); |
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); |
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); |
return one+ r/s; |
} |
/* For x >= 8, the asymptotic expansions of qzero is |
* -1/8 s + 75/1024 s^3 - ..., where s = 1/x. |
* We approximate qzero by |
* qzero(x) = s*(-1.25 + (R/S)) |
* where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10 |
* S = 1 + qS0*s^2 + ... + qS5*s^12 |
* and |
* | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) |
*/ |
#ifdef __STDC__ |
static const float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#else |
static float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#endif |
0.0000000000e+00, /* 0x00000000 */ |
7.3242187500e-02, /* 0x3d960000 */ |
1.1768206596e+01, /* 0x413c4a93 */ |
5.5767340088e+02, /* 0x440b6b19 */ |
8.8591972656e+03, /* 0x460a6cca */ |
3.7014625000e+04, /* 0x471096a0 */ |
}; |
#ifdef __STDC__ |
static const float qS8[6] = { |
#else |
static float qS8[6] = { |
#endif |
1.6377603149e+02, /* 0x4323c6aa */ |
8.0983447266e+03, /* 0x45fd12c2 */ |
1.4253829688e+05, /* 0x480b3293 */ |
8.0330925000e+05, /* 0x49441ed4 */ |
8.4050156250e+05, /* 0x494d3359 */ |
-3.4389928125e+05, /* 0xc8a7eb69 */ |
}; |
#ifdef __STDC__ |
static const float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#else |
static float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#endif |
1.8408595828e-11, /* 0x2da1ec79 */ |
7.3242180049e-02, /* 0x3d95ffff */ |
5.8356351852e+00, /* 0x40babd86 */ |
1.3511157227e+02, /* 0x43071c90 */ |
1.0272437744e+03, /* 0x448067cd */ |
1.9899779053e+03, /* 0x44f8bf4b */ |
}; |
#ifdef __STDC__ |
static const float qS5[6] = { |
#else |
static float qS5[6] = { |
#endif |
8.2776611328e+01, /* 0x42a58da0 */ |
2.0778142090e+03, /* 0x4501dd07 */ |
1.8847289062e+04, /* 0x46933e94 */ |
5.6751113281e+04, /* 0x475daf1d */ |
3.5976753906e+04, /* 0x470c88c1 */ |
-5.3543427734e+03, /* 0xc5a752be */ |
}; |
#ifdef __STDC__ |
static const float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#else |
static float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#endif |
4.3774099900e-09, /* 0x3196681b */ |
7.3241114616e-02, /* 0x3d95ff70 */ |
3.3442313671e+00, /* 0x405607e3 */ |
4.2621845245e+01, /* 0x422a7cc5 */ |
1.7080809021e+02, /* 0x432acedf */ |
1.6673394775e+02, /* 0x4326bbe4 */ |
}; |
#ifdef __STDC__ |
static const float qS3[6] = { |
#else |
static float qS3[6] = { |
#endif |
4.8758872986e+01, /* 0x42430916 */ |
7.0968920898e+02, /* 0x44316c1c */ |
3.7041481934e+03, /* 0x4567825f */ |
6.4604252930e+03, /* 0x45c9e367 */ |
2.5163337402e+03, /* 0x451d4557 */ |
-1.4924745178e+02, /* 0xc3153f59 */ |
}; |
#ifdef __STDC__ |
static const float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#else |
static float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#endif |
1.5044444979e-07, /* 0x342189db */ |
7.3223426938e-02, /* 0x3d95f62a */ |
1.9981917143e+00, /* 0x3fffc4bf */ |
1.4495602608e+01, /* 0x4167edfd */ |
3.1666231155e+01, /* 0x41fd5471 */ |
1.6252708435e+01, /* 0x4182058c */ |
}; |
#ifdef __STDC__ |
static const float qS2[6] = { |
#else |
static float qS2[6] = { |
#endif |
3.0365585327e+01, /* 0x41f2ecb8 */ |
2.6934811401e+02, /* 0x4386ac8f */ |
8.4478375244e+02, /* 0x44533229 */ |
8.8293585205e+02, /* 0x445cbbe5 */ |
2.1266638184e+02, /* 0x4354aa98 */ |
-5.3109550476e+00, /* 0xc0a9f358 */ |
}; |
#ifdef __STDC__ |
static float qzerof(float x) |
#else |
static float qzerof(x) |
float x; |
#endif |
{ |
#ifdef __STDC__ |
const float *p,*q; |
#else |
float *p,*q; |
#endif |
float s,r,z; |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
if(ix>=0x41000000) {p = qR8; q= qS8;} |
else if(ix>=0x40f71c58){p = qR5; q= qS5;} |
else if(ix>=0x4036db68){p = qR3; q= qS3;} |
else {p = qR2; q= qS2;} |
z = one/(x*x); |
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); |
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); |
return (-(float).125 + r/s)/x; |
} |
/contrib/sdk/sources/libc/math/ef_j1.c |
---|
0,0 → 1,439 |
/* ef_j1.c -- float version of e_j1.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static float ponef(float), qonef(float); |
#else |
static float ponef(), qonef(); |
#endif |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
huge = 1e30, |
one = 1.0, |
invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */ |
tpi = 6.3661974669e-01, /* 0x3f22f983 */ |
/* R0/S0 on [0,2] */ |
r00 = -6.2500000000e-02, /* 0xbd800000 */ |
r01 = 1.4070566976e-03, /* 0x3ab86cfd */ |
r02 = -1.5995563444e-05, /* 0xb7862e36 */ |
r03 = 4.9672799207e-08, /* 0x335557d2 */ |
s01 = 1.9153760746e-02, /* 0x3c9ce859 */ |
s02 = 1.8594678841e-04, /* 0x3942fab6 */ |
s03 = 1.1771846857e-06, /* 0x359dffc2 */ |
s04 = 5.0463624390e-09, /* 0x31ad6446 */ |
s05 = 1.2354227016e-11; /* 0x2d59567e */ |
#ifdef __STDC__ |
static const float zero = 0.0; |
#else |
static float zero = 0.0; |
#endif |
#ifdef __STDC__ |
float __ieee754_j1f(float x) |
#else |
float __ieee754_j1f(x) |
float x; |
#endif |
{ |
float z, s,c,ss,cc,r,u,v,y; |
__int32_t hx,ix; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(!FLT_UWORD_IS_FINITE(ix)) return one/x; |
y = fabsf(x); |
if(ix >= 0x40000000) { /* |x| >= 2.0 */ |
s = sinf(y); |
c = cosf(y); |
ss = -s-c; |
cc = s-c; |
if(ix<=FLT_UWORD_HALF_MAX) { /* make sure y+y not overflow */ |
z = cosf(y+y); |
if ((s*c)>zero) cc = z/ss; |
else ss = z/cc; |
} |
/* |
* j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) |
* y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) |
*/ |
if(ix>0x80000000) z = (invsqrtpi*cc)/__ieee754_sqrtf(y); |
else { |
u = ponef(y); v = qonef(y); |
z = invsqrtpi*(u*cc-v*ss)/__ieee754_sqrtf(y); |
} |
if(hx<0) return -z; |
else return z; |
} |
if(ix<0x32000000) { /* |x|<2**-27 */ |
if(huge+x>one) return (float)0.5*x;/* inexact if x!=0 necessary */ |
} |
z = x*x; |
r = z*(r00+z*(r01+z*(r02+z*r03))); |
s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05)))); |
r *= x; |
return(x*(float)0.5+r/s); |
} |
#ifdef __STDC__ |
static const float U0[5] = { |
#else |
static float U0[5] = { |
#endif |
-1.9605709612e-01, /* 0xbe48c331 */ |
5.0443872809e-02, /* 0x3d4e9e3c */ |
-1.9125689287e-03, /* 0xbafaaf2a */ |
2.3525259166e-05, /* 0x37c5581c */ |
-9.1909917899e-08, /* 0xb3c56003 */ |
}; |
#ifdef __STDC__ |
static const float V0[5] = { |
#else |
static float V0[5] = { |
#endif |
1.9916731864e-02, /* 0x3ca3286a */ |
2.0255257550e-04, /* 0x3954644b */ |
1.3560879779e-06, /* 0x35b602d4 */ |
6.2274145840e-09, /* 0x31d5f8eb */ |
1.6655924903e-11, /* 0x2d9281cf */ |
}; |
#ifdef __STDC__ |
float __ieee754_y1f(float x) |
#else |
float __ieee754_y1f(x) |
float x; |
#endif |
{ |
float z, s,c,ss,cc,u,v; |
__int32_t hx,ix; |
GET_FLOAT_WORD(hx,x); |
ix = 0x7fffffff&hx; |
/* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ |
if(!FLT_UWORD_IS_FINITE(ix)) return one/(x+x*x); |
if(FLT_UWORD_IS_ZERO(ix)) return -one/zero; |
if(hx<0) return zero/zero; |
if(ix >= 0x40000000) { /* |x| >= 2.0 */ |
s = sinf(x); |
c = cosf(x); |
ss = -s-c; |
cc = s-c; |
if(ix<=FLT_UWORD_HALF_MAX) { /* make sure x+x not overflow */ |
z = cosf(x+x); |
if ((s*c)>zero) cc = z/ss; |
else ss = z/cc; |
} |
/* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) |
* where x0 = x-3pi/4 |
* Better formula: |
* cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) |
* = 1/sqrt(2) * (sin(x) - cos(x)) |
* sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) |
* = -1/sqrt(2) * (cos(x) + sin(x)) |
* To avoid cancellation, use |
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) |
* to compute the worse one. |
*/ |
if(ix>0x48000000) z = (invsqrtpi*ss)/__ieee754_sqrtf(x); |
else { |
u = ponef(x); v = qonef(x); |
z = invsqrtpi*(u*ss+v*cc)/__ieee754_sqrtf(x); |
} |
return z; |
} |
if(ix<=0x24800000) { /* x < 2**-54 */ |
return(-tpi/x); |
} |
z = x*x; |
u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4]))); |
v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4])))); |
return(x*(u/v) + tpi*(__ieee754_j1f(x)*__ieee754_logf(x)-one/x)); |
} |
/* For x >= 8, the asymptotic expansions of pone is |
* 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. |
* We approximate pone by |
* pone(x) = 1 + (R/S) |
* where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 |
* S = 1 + ps0*s^2 + ... + ps4*s^10 |
* and |
* | pone(x)-1-R/S | <= 2 ** ( -60.06) |
*/ |
#ifdef __STDC__ |
static const float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#else |
static float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#endif |
0.0000000000e+00, /* 0x00000000 */ |
1.1718750000e-01, /* 0x3df00000 */ |
1.3239480972e+01, /* 0x4153d4ea */ |
4.1205184937e+02, /* 0x43ce06a3 */ |
3.8747453613e+03, /* 0x45722bed */ |
7.9144794922e+03, /* 0x45f753d6 */ |
}; |
#ifdef __STDC__ |
static const float ps8[5] = { |
#else |
static float ps8[5] = { |
#endif |
1.1420736694e+02, /* 0x42e46a2c */ |
3.6509309082e+03, /* 0x45642ee5 */ |
3.6956207031e+04, /* 0x47105c35 */ |
9.7602796875e+04, /* 0x47bea166 */ |
3.0804271484e+04, /* 0x46f0a88b */ |
}; |
#ifdef __STDC__ |
static const float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#else |
static float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#endif |
1.3199052094e-11, /* 0x2d68333f */ |
1.1718749255e-01, /* 0x3defffff */ |
6.8027510643e+00, /* 0x40d9b023 */ |
1.0830818176e+02, /* 0x42d89dca */ |
5.1763616943e+02, /* 0x440168b7 */ |
5.2871520996e+02, /* 0x44042dc6 */ |
}; |
#ifdef __STDC__ |
static const float ps5[5] = { |
#else |
static float ps5[5] = { |
#endif |
5.9280597687e+01, /* 0x426d1f55 */ |
9.9140142822e+02, /* 0x4477d9b1 */ |
5.3532670898e+03, /* 0x45a74a23 */ |
7.8446904297e+03, /* 0x45f52586 */ |
1.5040468750e+03, /* 0x44bc0180 */ |
}; |
#ifdef __STDC__ |
static const float pr3[6] = { |
#else |
static float pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#endif |
3.0250391081e-09, /* 0x314fe10d */ |
1.1718686670e-01, /* 0x3defffab */ |
3.9329774380e+00, /* 0x407bb5e7 */ |
3.5119403839e+01, /* 0x420c7a45 */ |
9.1055007935e+01, /* 0x42b61c2a */ |
4.8559066772e+01, /* 0x42423c7c */ |
}; |
#ifdef __STDC__ |
static const float ps3[5] = { |
#else |
static float ps3[5] = { |
#endif |
3.4791309357e+01, /* 0x420b2a4d */ |
3.3676245117e+02, /* 0x43a86198 */ |
1.0468714600e+03, /* 0x4482dbe3 */ |
8.9081134033e+02, /* 0x445eb3ed */ |
1.0378793335e+02, /* 0x42cf936c */ |
}; |
#ifdef __STDC__ |
static const float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#else |
static float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#endif |
1.0771083225e-07, /* 0x33e74ea8 */ |
1.1717621982e-01, /* 0x3deffa16 */ |
2.3685150146e+00, /* 0x401795c0 */ |
1.2242610931e+01, /* 0x4143e1bc */ |
1.7693971634e+01, /* 0x418d8d41 */ |
5.0735230446e+00, /* 0x40a25a4d */ |
}; |
#ifdef __STDC__ |
static const float ps2[5] = { |
#else |
static float ps2[5] = { |
#endif |
2.1436485291e+01, /* 0x41ab7dec */ |
1.2529022980e+02, /* 0x42fa9499 */ |
2.3227647400e+02, /* 0x436846c7 */ |
1.1767937469e+02, /* 0x42eb5bd7 */ |
8.3646392822e+00, /* 0x4105d590 */ |
}; |
#ifdef __STDC__ |
static float ponef(float x) |
#else |
static float ponef(x) |
float x; |
#endif |
{ |
#ifdef __STDC__ |
const float *p,*q; |
#else |
float *p,*q; |
#endif |
float z,r,s; |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
if(ix>=0x41000000) {p = pr8; q= ps8;} |
else if(ix>=0x40f71c58){p = pr5; q= ps5;} |
else if(ix>=0x4036db68){p = pr3; q= ps3;} |
else {p = pr2; q= ps2;} |
z = one/(x*x); |
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); |
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); |
return one+ r/s; |
} |
/* For x >= 8, the asymptotic expansions of qone is |
* 3/8 s - 105/1024 s^3 - ..., where s = 1/x. |
* We approximate qone by |
* qone(x) = s*(0.375 + (R/S)) |
* where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10 |
* S = 1 + qs1*s^2 + ... + qs6*s^12 |
* and |
* | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) |
*/ |
#ifdef __STDC__ |
static const float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#else |
static float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ |
#endif |
0.0000000000e+00, /* 0x00000000 */ |
-1.0253906250e-01, /* 0xbdd20000 */ |
-1.6271753311e+01, /* 0xc1822c8d */ |
-7.5960174561e+02, /* 0xc43de683 */ |
-1.1849806641e+04, /* 0xc639273a */ |
-4.8438511719e+04, /* 0xc73d3683 */ |
}; |
#ifdef __STDC__ |
static const float qs8[6] = { |
#else |
static float qs8[6] = { |
#endif |
1.6139537048e+02, /* 0x43216537 */ |
7.8253862305e+03, /* 0x45f48b17 */ |
1.3387534375e+05, /* 0x4802bcd6 */ |
7.1965775000e+05, /* 0x492fb29c */ |
6.6660125000e+05, /* 0x4922be94 */ |
-2.9449025000e+05, /* 0xc88fcb48 */ |
}; |
#ifdef __STDC__ |
static const float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#else |
static float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ |
#endif |
-2.0897993405e-11, /* 0xadb7d219 */ |
-1.0253904760e-01, /* 0xbdd1fffe */ |
-8.0564479828e+00, /* 0xc100e736 */ |
-1.8366960144e+02, /* 0xc337ab6b */ |
-1.3731937256e+03, /* 0xc4aba633 */ |
-2.6124443359e+03, /* 0xc523471c */ |
}; |
#ifdef __STDC__ |
static const float qs5[6] = { |
#else |
static float qs5[6] = { |
#endif |
8.1276550293e+01, /* 0x42a28d98 */ |
1.9917987061e+03, /* 0x44f8f98f */ |
1.7468484375e+04, /* 0x468878f8 */ |
4.9851425781e+04, /* 0x4742bb6d */ |
2.7948074219e+04, /* 0x46da5826 */ |
-4.7191835938e+03, /* 0xc5937978 */ |
}; |
#ifdef __STDC__ |
static const float qr3[6] = { |
#else |
static float qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ |
#endif |
-5.0783124372e-09, /* 0xb1ae7d4f */ |
-1.0253783315e-01, /* 0xbdd1ff5b */ |
-4.6101160049e+00, /* 0xc0938612 */ |
-5.7847221375e+01, /* 0xc267638e */ |
-2.2824453735e+02, /* 0xc3643e9a */ |
-2.1921012878e+02, /* 0xc35b35cb */ |
}; |
#ifdef __STDC__ |
static const float qs3[6] = { |
#else |
static float qs3[6] = { |
#endif |
4.7665153503e+01, /* 0x423ea91e */ |
6.7386511230e+02, /* 0x4428775e */ |
3.3801528320e+03, /* 0x45534272 */ |
5.5477290039e+03, /* 0x45ad5dd5 */ |
1.9031191406e+03, /* 0x44ede3d0 */ |
-1.3520118713e+02, /* 0xc3073381 */ |
}; |
#ifdef __STDC__ |
static const float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#else |
static float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ |
#endif |
-1.7838172539e-07, /* 0xb43f8932 */ |
-1.0251704603e-01, /* 0xbdd1f475 */ |
-2.7522056103e+00, /* 0xc0302423 */ |
-1.9663616180e+01, /* 0xc19d4f16 */ |
-4.2325313568e+01, /* 0xc2294d1f */ |
-2.1371921539e+01, /* 0xc1aaf9b2 */ |
}; |
#ifdef __STDC__ |
static const float qs2[6] = { |
#else |
static float qs2[6] = { |
#endif |
2.9533363342e+01, /* 0x41ec4454 */ |
2.5298155212e+02, /* 0x437cfb47 */ |
7.5750280762e+02, /* 0x443d602e */ |
7.3939318848e+02, /* 0x4438d92a */ |
1.5594900513e+02, /* 0x431bf2f2 */ |
-4.9594988823e+00, /* 0xc09eb437 */ |
}; |
#ifdef __STDC__ |
static float qonef(float x) |
#else |
static float qonef(x) |
float x; |
#endif |
{ |
#ifdef __STDC__ |
const float *p,*q; |
#else |
float *p,*q; |
#endif |
float s,r,z; |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
if(ix>=0x40200000) {p = qr8; q= qs8;} |
else if(ix>=0x40f71c58){p = qr5; q= qs5;} |
else if(ix>=0x4036db68){p = qr3; q= qs3;} |
else {p = qr2; q= qs2;} |
z = one/(x*x); |
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); |
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); |
return ((float).375 + r/s)/x; |
} |
/contrib/sdk/sources/libc/math/ef_jn.c |
---|
0,0 → 1,207 |
/* ef_jn.c -- float version of e_jn.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */ |
two = 2.0000000000e+00, /* 0x40000000 */ |
one = 1.0000000000e+00; /* 0x3F800000 */ |
#ifdef __STDC__ |
static const float zero = 0.0000000000e+00; |
#else |
static float zero = 0.0000000000e+00; |
#endif |
#ifdef __STDC__ |
float __ieee754_jnf(int n, float x) |
#else |
float __ieee754_jnf(n,x) |
int n; float x; |
#endif |
{ |
__int32_t i,hx,ix, sgn; |
float a, b, temp, di; |
float z, w; |
/* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) |
* Thus, J(-n,x) = J(n,-x) |
*/ |
GET_FLOAT_WORD(hx,x); |
ix = 0x7fffffff&hx; |
/* if J(n,NaN) is NaN */ |
if(FLT_UWORD_IS_NAN(ix)) return x+x; |
if(n<0){ |
n = -n; |
x = -x; |
hx ^= 0x80000000; |
} |
if(n==0) return(__ieee754_j0f(x)); |
if(n==1) return(__ieee754_j1f(x)); |
sgn = (n&1)&(hx>>31); /* even n -- 0, odd n -- sign(x) */ |
x = fabsf(x); |
if(FLT_UWORD_IS_ZERO(ix)||FLT_UWORD_IS_INFINITE(ix)) |
b = zero; |
else if((float)n<=x) { |
/* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ |
a = __ieee754_j0f(x); |
b = __ieee754_j1f(x); |
for(i=1;i<n;i++){ |
temp = b; |
b = b*((float)(i+i)/x) - a; /* avoid underflow */ |
a = temp; |
} |
} else { |
if(ix<0x30800000) { /* x < 2**-29 */ |
/* x is tiny, return the first Taylor expansion of J(n,x) |
* J(n,x) = 1/n!*(x/2)^n - ... |
*/ |
if(n>33) /* underflow */ |
b = zero; |
else { |
temp = x*(float)0.5; b = temp; |
for (a=one,i=2;i<=n;i++) { |
a *= (float)i; /* a = n! */ |
b *= temp; /* b = (x/2)^n */ |
} |
b = b/a; |
} |
} else { |
/* use backward recurrence */ |
/* x x^2 x^2 |
* J(n,x)/J(n-1,x) = ---- ------ ------ ..... |
* 2n - 2(n+1) - 2(n+2) |
* |
* 1 1 1 |
* (for large x) = ---- ------ ------ ..... |
* 2n 2(n+1) 2(n+2) |
* -- - ------ - ------ - |
* x x x |
* |
* Let w = 2n/x and h=2/x, then the above quotient |
* is equal to the continued fraction: |
* 1 |
* = ----------------------- |
* 1 |
* w - ----------------- |
* 1 |
* w+h - --------- |
* w+2h - ... |
* |
* To determine how many terms needed, let |
* Q(0) = w, Q(1) = w(w+h) - 1, |
* Q(k) = (w+k*h)*Q(k-1) - Q(k-2), |
* When Q(k) > 1e4 good for single |
* When Q(k) > 1e9 good for double |
* When Q(k) > 1e17 good for quadruple |
*/ |
/* determine k */ |
float t,v; |
float q0,q1,h,tmp; __int32_t k,m; |
w = (n+n)/(float)x; h = (float)2.0/(float)x; |
q0 = w; z = w+h; q1 = w*z - (float)1.0; k=1; |
while(q1<(float)1.0e9) { |
k += 1; z += h; |
tmp = z*q1 - q0; |
q0 = q1; |
q1 = tmp; |
} |
m = n+n; |
for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t); |
a = t; |
b = one; |
/* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) |
* Hence, if n*(log(2n/x)) > ... |
* single 8.8722839355e+01 |
* double 7.09782712893383973096e+02 |
* long double 1.1356523406294143949491931077970765006170e+04 |
* then recurrent value may overflow and the result is |
* likely underflow to zero |
*/ |
tmp = n; |
v = two/x; |
tmp = tmp*__ieee754_logf(fabsf(v*tmp)); |
if(tmp<(float)8.8721679688e+01) { |
for(i=n-1,di=(float)(i+i);i>0;i--){ |
temp = b; |
b *= di; |
b = b/x - a; |
a = temp; |
di -= two; |
} |
} else { |
for(i=n-1,di=(float)(i+i);i>0;i--){ |
temp = b; |
b *= di; |
b = b/x - a; |
a = temp; |
di -= two; |
/* scale b to avoid spurious overflow */ |
if(b>(float)1e10) { |
a /= b; |
t /= b; |
b = one; |
} |
} |
} |
b = (t*__ieee754_j0f(x)/b); |
} |
} |
if(sgn==1) return -b; else return b; |
} |
#ifdef __STDC__ |
float __ieee754_ynf(int n, float x) |
#else |
float __ieee754_ynf(n,x) |
int n; float x; |
#endif |
{ |
__int32_t i,hx,ix,ib; |
__int32_t sign; |
float a, b, temp; |
GET_FLOAT_WORD(hx,x); |
ix = 0x7fffffff&hx; |
/* if Y(n,NaN) is NaN */ |
if(FLT_UWORD_IS_NAN(ix)) return x+x; |
if(FLT_UWORD_IS_ZERO(ix)) return -one/zero; |
if(hx<0) return zero/zero; |
sign = 1; |
if(n<0){ |
n = -n; |
sign = 1 - ((n&1)<<1); |
} |
if(n==0) return(__ieee754_y0f(x)); |
if(n==1) return(sign*__ieee754_y1f(x)); |
if(FLT_UWORD_IS_INFINITE(ix)) return zero; |
a = __ieee754_y0f(x); |
b = __ieee754_y1f(x); |
/* quit if b is -inf */ |
GET_FLOAT_WORD(ib,b); |
for(i=1;i<n&&ib!=0xff800000;i++){ |
temp = b; |
b = ((float)(i+i)/x)*b - a; |
GET_FLOAT_WORD(ib,b); |
a = temp; |
} |
if(sign>0) return b; else return -b; |
} |
/contrib/sdk/sources/libc/math/ef_log.c |
---|
0,0 → 1,92 |
/* ef_log.c -- float version of e_log.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ |
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */ |
two25 = 3.355443200e+07, /* 0x4c000000 */ |
Lg1 = 6.6666668653e-01, /* 3F2AAAAB */ |
Lg2 = 4.0000000596e-01, /* 3ECCCCCD */ |
Lg3 = 2.8571429849e-01, /* 3E924925 */ |
Lg4 = 2.2222198546e-01, /* 3E638E29 */ |
Lg5 = 1.8183572590e-01, /* 3E3A3325 */ |
Lg6 = 1.5313838422e-01, /* 3E1CD04F */ |
Lg7 = 1.4798198640e-01; /* 3E178897 */ |
#ifdef __STDC__ |
static const float zero = 0.0; |
#else |
static float zero = 0.0; |
#endif |
#ifdef __STDC__ |
float __ieee754_logf(float x) |
#else |
float __ieee754_logf(x) |
float x; |
#endif |
{ |
float hfsq,f,s,z,R,w,t1,t2,dk; |
__int32_t k,ix,i,j; |
GET_FLOAT_WORD(ix,x); |
k=0; |
if (FLT_UWORD_IS_ZERO(ix&0x7fffffff)) |
return -two25/zero; /* log(+-0)=-inf */ |
if (ix<0) return (x-x)/zero; /* log(-#) = NaN */ |
if (!FLT_UWORD_IS_FINITE(ix)) return x+x; |
if (FLT_UWORD_IS_SUBNORMAL(ix)) { |
k -= 25; x *= two25; /* subnormal number, scale up x */ |
GET_FLOAT_WORD(ix,x); |
} |
k += (ix>>23)-127; |
ix &= 0x007fffff; |
i = (ix+(0x95f64<<3))&0x800000; |
SET_FLOAT_WORD(x,ix|(i^0x3f800000)); /* normalize x or x/2 */ |
k += (i>>23); |
f = x-(float)1.0; |
if((0x007fffff&(15+ix))<16) { /* |f| < 2**-20 */ |
if(f==zero) { if(k==0) return zero; else {dk=(float)k; |
return dk*ln2_hi+dk*ln2_lo;}} |
R = f*f*((float)0.5-(float)0.33333333333333333*f); |
if(k==0) return f-R; else {dk=(float)k; |
return dk*ln2_hi-((R-dk*ln2_lo)-f);} |
} |
s = f/((float)2.0+f); |
dk = (float)k; |
z = s*s; |
i = ix-(0x6147a<<3); |
w = z*z; |
j = (0x6b851<<3)-ix; |
t1= w*(Lg2+w*(Lg4+w*Lg6)); |
t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); |
i |= j; |
R = t2+t1; |
if(i>0) { |
hfsq=(float)0.5*f*f; |
if(k==0) return f-(hfsq-s*(hfsq+R)); else |
return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f); |
} else { |
if(k==0) return f-s*(f-R); else |
return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f); |
} |
} |
/contrib/sdk/sources/libc/math/ef_log10.c |
---|
0,0 → 1,62 |
/* ef_log10.c -- float version of e_log10.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
two25 = 3.3554432000e+07, /* 0x4c000000 */ |
ivln10 = 4.3429449201e-01, /* 0x3ede5bd9 */ |
log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */ |
log10_2lo = 7.9034151668e-07; /* 0x355427db */ |
#ifdef __STDC__ |
static const float zero = 0.0; |
#else |
static float zero = 0.0; |
#endif |
#ifdef __STDC__ |
float __ieee754_log10f(float x) |
#else |
float __ieee754_log10f(x) |
float x; |
#endif |
{ |
float y,z; |
__int32_t i,k,hx; |
GET_FLOAT_WORD(hx,x); |
k=0; |
if (FLT_UWORD_IS_ZERO(hx&0x7fffffff)) |
return -two25/zero; /* log(+-0)=-inf */ |
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */ |
if (!FLT_UWORD_IS_FINITE(hx)) return x+x; |
if (FLT_UWORD_IS_SUBNORMAL(hx)) { |
k -= 25; x *= two25; /* subnormal number, scale up x */ |
GET_FLOAT_WORD(hx,x); |
} |
k += (hx>>23)-127; |
i = ((__uint32_t)k&0x80000000)>>31; |
hx = (hx&0x007fffff)|((0x7f-i)<<23); |
y = (float)(k+i); |
SET_FLOAT_WORD(x,hx); |
z = y*log10_2lo + ivln10*__ieee754_logf(x); |
return z+y*log10_2hi; |
} |
/contrib/sdk/sources/libc/math/ef_pow.c |
---|
0,0 → 1,255 |
/* ef_pow.c -- float version of e_pow.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __v810__ |
#define const |
#endif |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
bp[] = {1.0, 1.5,}, |
dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */ |
dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */ |
zero = 0.0, |
one = 1.0, |
two = 2.0, |
two24 = 16777216.0, /* 0x4b800000 */ |
huge = 1.0e30, |
tiny = 1.0e-30, |
/* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ |
L1 = 6.0000002384e-01, /* 0x3f19999a */ |
L2 = 4.2857143283e-01, /* 0x3edb6db7 */ |
L3 = 3.3333334327e-01, /* 0x3eaaaaab */ |
L4 = 2.7272811532e-01, /* 0x3e8ba305 */ |
L5 = 2.3066075146e-01, /* 0x3e6c3255 */ |
L6 = 2.0697501302e-01, /* 0x3e53f142 */ |
P1 = 1.6666667163e-01, /* 0x3e2aaaab */ |
P2 = -2.7777778450e-03, /* 0xbb360b61 */ |
P3 = 6.6137559770e-05, /* 0x388ab355 */ |
P4 = -1.6533901999e-06, /* 0xb5ddea0e */ |
P5 = 4.1381369442e-08, /* 0x3331bb4c */ |
lg2 = 6.9314718246e-01, /* 0x3f317218 */ |
lg2_h = 6.93145752e-01, /* 0x3f317200 */ |
lg2_l = 1.42860654e-06, /* 0x35bfbe8c */ |
ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */ |
cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */ |
cp_h = 9.6179199219e-01, /* 0x3f763800 =head of cp */ |
cp_l = 4.7017383622e-06, /* 0x369dc3a0 =tail of cp_h */ |
ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */ |
ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/ |
ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/ |
#ifdef __STDC__ |
float __ieee754_powf(float x, float y) |
#else |
float __ieee754_powf(x,y) |
float x, y; |
#endif |
{ |
float z,ax,z_h,z_l,p_h,p_l; |
float y1,t1,t2,r,s,t,u,v,w; |
__int32_t i,j,k,yisint,n; |
__int32_t hx,hy,ix,iy,is; |
GET_FLOAT_WORD(hx,x); |
GET_FLOAT_WORD(hy,y); |
ix = hx&0x7fffffff; iy = hy&0x7fffffff; |
/* y==zero: x**0 = 1 */ |
if(FLT_UWORD_IS_ZERO(iy)) return one; |
/* x|y==NaN return NaN unless x==1 then return 1 */ |
if(FLT_UWORD_IS_NAN(ix) || |
FLT_UWORD_IS_NAN(iy)) { |
if(ix==0x3f800000) return one; |
else return nanf(""); |
} |
/* determine if y is an odd int when x < 0 |
* yisint = 0 ... y is not an integer |
* yisint = 1 ... y is an odd int |
* yisint = 2 ... y is an even int |
*/ |
yisint = 0; |
if(hx<0) { |
if(iy>=0x4b800000) yisint = 2; /* even integer y */ |
else if(iy>=0x3f800000) { |
k = (iy>>23)-0x7f; /* exponent */ |
j = iy>>(23-k); |
if((j<<(23-k))==iy) yisint = 2-(j&1); |
} |
} |
/* special value of y */ |
if (FLT_UWORD_IS_INFINITE(iy)) { /* y is +-inf */ |
if (ix==0x3f800000) |
return one; /* +-1**+-inf = 1 */ |
else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */ |
return (hy>=0)? y: zero; |
else /* (|x|<1)**-,+inf = inf,0 */ |
return (hy<0)?-y: zero; |
} |
if(iy==0x3f800000) { /* y is +-1 */ |
if(hy<0) return one/x; else return x; |
} |
if(hy==0x40000000) return x*x; /* y is 2 */ |
if(hy==0x3f000000) { /* y is 0.5 */ |
if(hx>=0) /* x >= +0 */ |
return __ieee754_sqrtf(x); |
} |
ax = fabsf(x); |
/* special value of x */ |
if(FLT_UWORD_IS_INFINITE(ix)||FLT_UWORD_IS_ZERO(ix)||ix==0x3f800000){ |
z = ax; /*x is +-0,+-inf,+-1*/ |
if(hy<0) z = one/z; /* z = (1/|x|) */ |
if(hx<0) { |
if(((ix-0x3f800000)|yisint)==0) { |
z = (z-z)/(z-z); /* (-1)**non-int is NaN */ |
} else if(yisint==1) |
z = -z; /* (x<0)**odd = -(|x|**odd) */ |
} |
return z; |
} |
/* (x<0)**(non-int) is NaN */ |
if(((((__uint32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); |
/* |y| is huge */ |
if(iy>0x4d000000) { /* if |y| > 2**27 */ |
/* over/underflow if x is not close to one */ |
if(ix<0x3f7ffff8) return (hy<0)? huge*huge:tiny*tiny; |
if(ix>0x3f800007) return (hy>0)? huge*huge:tiny*tiny; |
/* now |1-x| is tiny <= 2**-20, suffice to compute |
log(x) by x-x^2/2+x^3/3-x^4/4 */ |
t = ax-1; /* t has 20 trailing zeros */ |
w = (t*t)*((float)0.5-t*((float)0.333333333333-t*(float)0.25)); |
u = ivln2_h*t; /* ivln2_h has 16 sig. bits */ |
v = t*ivln2_l-w*ivln2; |
t1 = u+v; |
GET_FLOAT_WORD(is,t1); |
SET_FLOAT_WORD(t1,is&0xfffff000); |
t2 = v-(t1-u); |
} else { |
float s2,s_h,s_l,t_h,t_l; |
n = 0; |
/* take care subnormal number */ |
if(FLT_UWORD_IS_SUBNORMAL(ix)) |
{ax *= two24; n -= 24; GET_FLOAT_WORD(ix,ax); } |
n += ((ix)>>23)-0x7f; |
j = ix&0x007fffff; |
/* determine interval */ |
ix = j|0x3f800000; /* normalize ix */ |
if(j<=0x1cc471) k=0; /* |x|<sqrt(3/2) */ |
else if(j<0x5db3d7) k=1; /* |x|<sqrt(3) */ |
else {k=0;n+=1;ix -= 0x00800000;} |
SET_FLOAT_WORD(ax,ix); |
/* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ |
u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ |
v = one/(ax+bp[k]); |
s = u*v; |
s_h = s; |
GET_FLOAT_WORD(is,s_h); |
SET_FLOAT_WORD(s_h,is&0xfffff000); |
/* t_h=ax+bp[k] High */ |
SET_FLOAT_WORD(t_h,((ix>>1)|0x20000000)+0x0040000+(k<<21)); |
t_l = ax - (t_h-bp[k]); |
s_l = v*((u-s_h*t_h)-s_h*t_l); |
/* compute log(ax) */ |
s2 = s*s; |
r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); |
r += s_l*(s_h+s); |
s2 = s_h*s_h; |
t_h = (float)3.0+s2+r; |
GET_FLOAT_WORD(is,t_h); |
SET_FLOAT_WORD(t_h,is&0xfffff000); |
t_l = r-((t_h-(float)3.0)-s2); |
/* u+v = s*(1+...) */ |
u = s_h*t_h; |
v = s_l*t_h+t_l*s; |
/* 2/(3log2)*(s+...) */ |
p_h = u+v; |
GET_FLOAT_WORD(is,p_h); |
SET_FLOAT_WORD(p_h,is&0xfffff000); |
p_l = v-(p_h-u); |
z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ |
z_l = cp_l*p_h+p_l*cp+dp_l[k]; |
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ |
t = (float)n; |
t1 = (((z_h+z_l)+dp_h[k])+t); |
GET_FLOAT_WORD(is,t1); |
SET_FLOAT_WORD(t1,is&0xfffff000); |
t2 = z_l-(((t1-t)-dp_h[k])-z_h); |
} |
s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ |
if(((((__uint32_t)hx>>31)-1)|(yisint-1))==0) |
s = -one; /* (-ve)**(odd int) */ |
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ |
GET_FLOAT_WORD(is,y); |
SET_FLOAT_WORD(y1,is&0xfffff000); |
p_l = (y-y1)*t1+y*t2; |
p_h = y1*t1; |
z = p_l+p_h; |
GET_FLOAT_WORD(j,z); |
i = j&0x7fffffff; |
if (j>0) { |
if (i>FLT_UWORD_EXP_MAX) |
return s*huge*huge; /* overflow */ |
else if (i==FLT_UWORD_EXP_MAX) |
if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */ |
} else { |
if (i>FLT_UWORD_EXP_MIN) |
return s*tiny*tiny; /* underflow */ |
else if (i==FLT_UWORD_EXP_MIN) |
if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */ |
} |
/* |
* compute 2**(p_h+p_l) |
*/ |
k = (i>>23)-0x7f; |
n = 0; |
if(i>0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */ |
n = j+(0x00800000>>(k+1)); |
k = ((n&0x7fffffff)>>23)-0x7f; /* new k for n */ |
SET_FLOAT_WORD(t,n&~(0x007fffff>>k)); |
n = ((n&0x007fffff)|0x00800000)>>(23-k); |
if(j<0) n = -n; |
p_h -= t; |
} |
t = p_l+p_h; |
GET_FLOAT_WORD(is,t); |
SET_FLOAT_WORD(t,is&0xfffff000); |
u = t*lg2_h; |
v = (p_l-(t-p_h))*lg2+t*lg2_l; |
z = u+v; |
w = v-(z-u); |
t = z*z; |
t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); |
r = (z*t1)/(t1-two)-(w+z*w); |
z = one-(r-z); |
GET_FLOAT_WORD(j,z); |
j += (n<<23); |
if((j>>23)<=0) z = scalbnf(z,(int)n); /* subnormal output */ |
else SET_FLOAT_WORD(z,j); |
return s*z; |
} |
/contrib/sdk/sources/libc/math/ef_rem_pio2.c |
---|
0,0 → 1,193 |
/* ef_rem_pio2.c -- float version of e_rem_pio2.c |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* __ieee754_rem_pio2f(x,y) |
* |
* return the remainder of x rem pi/2 in y[0]+y[1] |
* use __kernel_rem_pio2f() |
*/ |
#include "fdlibm.h" |
/* |
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi |
*/ |
#ifdef __STDC__ |
static const __int32_t two_over_pi[] = { |
#else |
static __int32_t two_over_pi[] = { |
#endif |
0xA2, 0xF9, 0x83, 0x6E, 0x4E, 0x44, 0x15, 0x29, 0xFC, |
0x27, 0x57, 0xD1, 0xF5, 0x34, 0xDD, 0xC0, 0xDB, 0x62, |
0x95, 0x99, 0x3C, 0x43, 0x90, 0x41, 0xFE, 0x51, 0x63, |
0xAB, 0xDE, 0xBB, 0xC5, 0x61, 0xB7, 0x24, 0x6E, 0x3A, |
0x42, 0x4D, 0xD2, 0xE0, 0x06, 0x49, 0x2E, 0xEA, 0x09, |
0xD1, 0x92, 0x1C, 0xFE, 0x1D, 0xEB, 0x1C, 0xB1, 0x29, |
0xA7, 0x3E, 0xE8, 0x82, 0x35, 0xF5, 0x2E, 0xBB, 0x44, |
0x84, 0xE9, 0x9C, 0x70, 0x26, 0xB4, 0x5F, 0x7E, 0x41, |
0x39, 0x91, 0xD6, 0x39, 0x83, 0x53, 0x39, 0xF4, 0x9C, |
0x84, 0x5F, 0x8B, 0xBD, 0xF9, 0x28, 0x3B, 0x1F, 0xF8, |
0x97, 0xFF, 0xDE, 0x05, 0x98, 0x0F, 0xEF, 0x2F, 0x11, |
0x8B, 0x5A, 0x0A, 0x6D, 0x1F, 0x6D, 0x36, 0x7E, 0xCF, |
0x27, 0xCB, 0x09, 0xB7, 0x4F, 0x46, 0x3F, 0x66, 0x9E, |
0x5F, 0xEA, 0x2D, 0x75, 0x27, 0xBA, 0xC7, 0xEB, 0xE5, |
0xF1, 0x7B, 0x3D, 0x07, 0x39, 0xF7, 0x8A, 0x52, 0x92, |
0xEA, 0x6B, 0xFB, 0x5F, 0xB1, 0x1F, 0x8D, 0x5D, 0x08, |
0x56, 0x03, 0x30, 0x46, 0xFC, 0x7B, 0x6B, 0xAB, 0xF0, |
0xCF, 0xBC, 0x20, 0x9A, 0xF4, 0x36, 0x1D, 0xA9, 0xE3, |
0x91, 0x61, 0x5E, 0xE6, 0x1B, 0x08, 0x65, 0x99, 0x85, |
0x5F, 0x14, 0xA0, 0x68, 0x40, 0x8D, 0xFF, 0xD8, 0x80, |
0x4D, 0x73, 0x27, 0x31, 0x06, 0x06, 0x15, 0x56, 0xCA, |
0x73, 0xA8, 0xC9, 0x60, 0xE2, 0x7B, 0xC0, 0x8C, 0x6B, |
}; |
/* This array is like the one in e_rem_pio2.c, but the numbers are |
single precision and the last 8 bits are forced to 0. */ |
#ifdef __STDC__ |
static const __int32_t npio2_hw[] = { |
#else |
static __int32_t npio2_hw[] = { |
#endif |
0x3fc90f00, 0x40490f00, 0x4096cb00, 0x40c90f00, 0x40fb5300, 0x4116cb00, |
0x412fed00, 0x41490f00, 0x41623100, 0x417b5300, 0x418a3a00, 0x4196cb00, |
0x41a35c00, 0x41afed00, 0x41bc7e00, 0x41c90f00, 0x41d5a000, 0x41e23100, |
0x41eec200, 0x41fb5300, 0x4203f200, 0x420a3a00, 0x42108300, 0x4216cb00, |
0x421d1400, 0x42235c00, 0x4229a500, 0x422fed00, 0x42363600, 0x423c7e00, |
0x4242c700, 0x42490f00 |
}; |
/* |
* invpio2: 24 bits of 2/pi |
* pio2_1: first 17 bit of pi/2 |
* pio2_1t: pi/2 - pio2_1 |
* pio2_2: second 17 bit of pi/2 |
* pio2_2t: pi/2 - (pio2_1+pio2_2) |
* pio2_3: third 17 bit of pi/2 |
* pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) |
*/ |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
zero = 0.0000000000e+00, /* 0x00000000 */ |
half = 5.0000000000e-01, /* 0x3f000000 */ |
two8 = 2.5600000000e+02, /* 0x43800000 */ |
invpio2 = 6.3661980629e-01, /* 0x3f22f984 */ |
pio2_1 = 1.5707855225e+00, /* 0x3fc90f80 */ |
pio2_1t = 1.0804334124e-05, /* 0x37354443 */ |
pio2_2 = 1.0804273188e-05, /* 0x37354400 */ |
pio2_2t = 6.0770999344e-11, /* 0x2e85a308 */ |
pio2_3 = 6.0770943833e-11, /* 0x2e85a300 */ |
pio2_3t = 6.1232342629e-17; /* 0x248d3132 */ |
#ifdef __STDC__ |
__int32_t __ieee754_rem_pio2f(float x, float *y) |
#else |
__int32_t __ieee754_rem_pio2f(x,y) |
float x,y[]; |
#endif |
{ |
float z,w,t,r,fn; |
float tx[3]; |
__int32_t i,j,n,ix,hx; |
int e0,nx; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix<=0x3f490fd8) /* |x| ~<= pi/4 , no need for reduction */ |
{y[0] = x; y[1] = 0; return 0;} |
if(ix<0x4016cbe4) { /* |x| < 3pi/4, special case with n=+-1 */ |
if(hx>0) { |
z = x - pio2_1; |
if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */ |
y[0] = z - pio2_1t; |
y[1] = (z-y[0])-pio2_1t; |
} else { /* near pi/2, use 24+24+24 bit pi */ |
z -= pio2_2; |
y[0] = z - pio2_2t; |
y[1] = (z-y[0])-pio2_2t; |
} |
return 1; |
} else { /* negative x */ |
z = x + pio2_1; |
if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */ |
y[0] = z + pio2_1t; |
y[1] = (z-y[0])+pio2_1t; |
} else { /* near pi/2, use 24+24+24 bit pi */ |
z += pio2_2; |
y[0] = z + pio2_2t; |
y[1] = (z-y[0])+pio2_2t; |
} |
return -1; |
} |
} |
if(ix<=0x43490f80) { /* |x| ~<= 2^7*(pi/2), medium size */ |
t = fabsf(x); |
n = (__int32_t) (t*invpio2+half); |
fn = (float)n; |
r = t-fn*pio2_1; |
w = fn*pio2_1t; /* 1st round good to 40 bit */ |
if(n<32&&(ix&0xffffff00)!=npio2_hw[n-1]) { |
y[0] = r-w; /* quick check no cancellation */ |
} else { |
__uint32_t high; |
j = ix>>23; |
y[0] = r-w; |
GET_FLOAT_WORD(high,y[0]); |
i = j-((high>>23)&0xff); |
if(i>8) { /* 2nd iteration needed, good to 57 */ |
t = r; |
w = fn*pio2_2; |
r = t-w; |
w = fn*pio2_2t-((t-r)-w); |
y[0] = r-w; |
GET_FLOAT_WORD(high,y[0]); |
i = j-((high>>23)&0xff); |
if(i>25) { /* 3rd iteration need, 74 bits acc */ |
t = r; /* will cover all possible cases */ |
w = fn*pio2_3; |
r = t-w; |
w = fn*pio2_3t-((t-r)-w); |
y[0] = r-w; |
} |
} |
} |
y[1] = (r-y[0])-w; |
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} |
else return n; |
} |
/* |
* all other (large) arguments |
*/ |
if(!FLT_UWORD_IS_FINITE(ix)) { |
y[0]=y[1]=x-x; return 0; |
} |
/* set z = scalbn(|x|,ilogb(x)-7) */ |
e0 = (int)((ix>>23)-134); /* e0 = ilogb(z)-7; */ |
SET_FLOAT_WORD(z, ix - ((__int32_t)e0<<23)); |
for(i=0;i<2;i++) { |
tx[i] = (float)((__int32_t)(z)); |
z = (z-tx[i])*two8; |
} |
tx[2] = z; |
nx = 3; |
while(tx[nx-1]==zero) nx--; /* skip zero term */ |
n = __kernel_rem_pio2f(tx,y,e0,nx,2,two_over_pi); |
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} |
return n; |
} |
/contrib/sdk/sources/libc/math/ef_remainder.c |
---|
0,0 → 1,68 |
/* ef_remainder.c -- float version of e_remainder.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float zero = 0.0; |
#else |
static float zero = 0.0; |
#endif |
#ifdef __STDC__ |
float __ieee754_remainderf(float x, float p) |
#else |
float __ieee754_remainderf(x,p) |
float x,p; |
#endif |
{ |
__int32_t hx,hp; |
__uint32_t sx; |
float p_half; |
GET_FLOAT_WORD(hx,x); |
GET_FLOAT_WORD(hp,p); |
sx = hx&0x80000000; |
hp &= 0x7fffffff; |
hx &= 0x7fffffff; |
/* purge off exception values */ |
if(FLT_UWORD_IS_ZERO(hp)|| |
!FLT_UWORD_IS_FINITE(hx)|| |
FLT_UWORD_IS_NAN(hp)) |
return (x*p)/(x*p); |
if (hp<=FLT_UWORD_HALF_MAX) x = __ieee754_fmodf(x,p+p); /* now x < 2p */ |
if ((hx-hp)==0) return zero*x; |
x = fabsf(x); |
p = fabsf(p); |
if (hp<0x01000000) { |
if(x+x>p) { |
x-=p; |
if(x+x>=p) x -= p; |
} |
} else { |
p_half = (float)0.5*p; |
if(x>p_half) { |
x-=p; |
if(x>=p_half) x -= p; |
} |
} |
GET_FLOAT_WORD(hx,x); |
SET_FLOAT_WORD(x,hx^sx); |
return x; |
} |
/contrib/sdk/sources/libc/math/ef_scalb.c |
---|
0,0 → 1,53 |
/* ef_scalb.c -- float version of e_scalb.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#include <limits.h> |
#ifdef _SCALB_INT |
#ifdef __STDC__ |
float __ieee754_scalbf(float x, int fn) |
#else |
float __ieee754_scalbf(x,fn) |
float x; int fn; |
#endif |
#else |
#ifdef __STDC__ |
float __ieee754_scalbf(float x, float fn) |
#else |
float __ieee754_scalbf(x,fn) |
float x, fn; |
#endif |
#endif |
{ |
#ifdef _SCALB_INT |
return scalbnf(x,fn); |
#else |
if (isnan(x)||isnan(fn)) return x*fn; |
if (!finitef(fn)) { |
if(fn>(float)0.0) return x*fn; |
else return x/(-fn); |
} |
if (rintf(fn)!=fn) return (fn-fn)/(fn-fn); |
#if INT_MAX > 65000 |
if ( fn > (float)65000.0) return scalbnf(x, 65000); |
if (-fn > (float)65000.0) return scalbnf(x,-65000); |
#else |
if ( fn > (float)32000.0) return scalbnf(x, 32000); |
if (-fn > (float)32000.0) return scalbnf(x,-32000); |
#endif |
return scalbnf(x,(int)fn); |
#endif |
} |
/contrib/sdk/sources/libc/math/ef_sinh.c |
---|
0,0 → 1,63 |
/* ef_sinh.c -- float version of e_sinh.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float one = 1.0, shuge = 1.0e37; |
#else |
static float one = 1.0, shuge = 1.0e37; |
#endif |
#ifdef __STDC__ |
float __ieee754_sinhf(float x) |
#else |
float __ieee754_sinhf(x) |
float x; |
#endif |
{ |
float t,w,h; |
__int32_t ix,jx; |
GET_FLOAT_WORD(jx,x); |
ix = jx&0x7fffffff; |
/* x is INF or NaN */ |
if(!FLT_UWORD_IS_FINITE(ix)) return x+x; |
h = 0.5; |
if (jx<0) h = -h; |
/* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */ |
if (ix < 0x41b00000) { /* |x|<22 */ |
if (ix<0x31800000) /* |x|<2**-28 */ |
if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */ |
t = expm1f(fabsf(x)); |
if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one)); |
return h*(t+t/(t+one)); |
} |
/* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */ |
if (ix<=FLT_UWORD_LOG_MAX) return h*__ieee754_expf(fabsf(x)); |
/* |x| in [log(maxdouble), overflowthresold] */ |
if (ix<=FLT_UWORD_LOG_2MAX) { |
w = __ieee754_expf((float)0.5*fabsf(x)); |
t = h*w; |
return t*w; |
} |
/* |x| > overflowthresold, sinh(x) overflow */ |
return x*shuge; |
} |
/contrib/sdk/sources/libc/math/ef_sqrt.c |
---|
0,0 → 1,89 |
/* ef_sqrtf.c -- float version of e_sqrt.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float one = 1.0, tiny=1.0e-30; |
#else |
static float one = 1.0, tiny=1.0e-30; |
#endif |
#ifdef __STDC__ |
float __ieee754_sqrtf(float x) |
#else |
float __ieee754_sqrtf(x) |
float x; |
#endif |
{ |
float z; |
__uint32_t r,hx; |
__int32_t ix,s,q,m,t,i; |
GET_FLOAT_WORD(ix,x); |
hx = ix&0x7fffffff; |
/* take care of Inf and NaN */ |
if(!FLT_UWORD_IS_FINITE(hx)) |
return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf |
sqrt(-inf)=sNaN */ |
/* take care of zero and -ves */ |
if(FLT_UWORD_IS_ZERO(hx)) return x;/* sqrt(+-0) = +-0 */ |
if(ix<0) return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ |
/* normalize x */ |
m = (ix>>23); |
if(FLT_UWORD_IS_SUBNORMAL(hx)) { /* subnormal x */ |
for(i=0;(ix&0x00800000L)==0;i++) ix<<=1; |
m -= i-1; |
} |
m -= 127; /* unbias exponent */ |
ix = (ix&0x007fffffL)|0x00800000L; |
if(m&1) /* odd m, double x to make it even */ |
ix += ix; |
m >>= 1; /* m = [m/2] */ |
/* generate sqrt(x) bit by bit */ |
ix += ix; |
q = s = 0; /* q = sqrt(x) */ |
r = 0x01000000L; /* r = moving bit from right to left */ |
while(r!=0) { |
t = s+r; |
if(t<=ix) { |
s = t+r; |
ix -= t; |
q += r; |
} |
ix += ix; |
r>>=1; |
} |
/* use floating add to find out rounding direction */ |
if(ix!=0) { |
z = one-tiny; /* trigger inexact flag */ |
if (z>=one) { |
z = one+tiny; |
if (z>one) |
q += 2; |
else |
q += (q&1); |
} |
} |
ix = (q>>1)+0x3f000000L; |
ix += (m <<23); |
SET_FLOAT_WORD(z,ix); |
return z; |
} |
/contrib/sdk/sources/libc/math/er_gamma.c |
---|
0,0 → 1,32 |
/* @(#)er_gamma.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* __ieee754_gamma_r(x, signgamp) |
* Reentrant version of the logarithm of the Gamma function |
* with user provide pointer for the sign of Gamma(x). |
* |
* Method: See __ieee754_lgamma_r |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
double __ieee754_gamma_r(double x, int *signgamp) |
#else |
double __ieee754_gamma_r(x,signgamp) |
double x; int *signgamp; |
#endif |
{ |
return __ieee754_exp (__ieee754_lgamma_r(x,signgamp)); |
} |
/contrib/sdk/sources/libc/math/er_lgamma.c |
---|
0,0 → 1,309 |
/* @(#)er_lgamma.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* __ieee754_lgamma_r(x, signgamp) |
* Reentrant version of the logarithm of the Gamma function |
* with user provide pointer for the sign of Gamma(x). |
* |
* Method: |
* 1. Argument Reduction for 0 < x <= 8 |
* Since gamma(1+s)=s*gamma(s), for x in [0,8], we may |
* reduce x to a number in [1.5,2.5] by |
* lgamma(1+s) = log(s) + lgamma(s) |
* for example, |
* lgamma(7.3) = log(6.3) + lgamma(6.3) |
* = log(6.3*5.3) + lgamma(5.3) |
* = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3) |
* 2. Polynomial approximation of lgamma around its |
* minimun ymin=1.461632144968362245 to maintain monotonicity. |
* On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use |
* Let z = x-ymin; |
* lgamma(x) = -1.214862905358496078218 + z^2*poly(z) |
* where |
* poly(z) is a 14 degree polynomial. |
* 2. Rational approximation in the primary interval [2,3] |
* We use the following approximation: |
* s = x-2.0; |
* lgamma(x) = 0.5*s + s*P(s)/Q(s) |
* with accuracy |
* |P/Q - (lgamma(x)-0.5s)| < 2**-61.71 |
* Our algorithms are based on the following observation |
* |
* zeta(2)-1 2 zeta(3)-1 3 |
* lgamma(2+s) = s*(1-Euler) + --------- * s - --------- * s + ... |
* 2 3 |
* |
* where Euler = 0.5771... is the Euler constant, which is very |
* close to 0.5. |
* |
* 3. For x>=8, we have |
* lgamma(x)~(x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+.... |
* (better formula: |
* lgamma(x)~(x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...) |
* Let z = 1/x, then we approximation |
* f(z) = lgamma(x) - (x-0.5)(log(x)-1) |
* by |
* 3 5 11 |
* w = w0 + w1*z + w2*z + w3*z + ... + w6*z |
* where |
* |w - f(z)| < 2**-58.74 |
* |
* 4. For negative x, since (G is gamma function) |
* -x*G(-x)*G(x) = pi/sin(pi*x), |
* we have |
* G(x) = pi/(sin(pi*x)*(-x)*G(-x)) |
* since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0 |
* Hence, for x<0, signgam = sign(sin(pi*x)) and |
* lgamma(x) = log(|Gamma(x)|) |
* = log(pi/(|x*sin(pi*x)|)) - lgamma(-x); |
* Note: one should avoid compute pi*(-x) directly in the |
* computation of sin(pi*(-x)). |
* |
* 5. Special Cases |
* lgamma(2+s) ~ s*(1-Euler) for tiny s |
* lgamma(1)=lgamma(2)=0 |
* lgamma(x) ~ -log(x) for tiny x |
* lgamma(0) = lgamma(inf) = inf |
* lgamma(-integer) = +-inf |
* |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
two52= 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ |
half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ |
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */ |
a0 = 7.72156649015328655494e-02, /* 0x3FB3C467, 0xE37DB0C8 */ |
a1 = 3.22467033424113591611e-01, /* 0x3FD4A34C, 0xC4A60FAD */ |
a2 = 6.73523010531292681824e-02, /* 0x3FB13E00, 0x1A5562A7 */ |
a3 = 2.05808084325167332806e-02, /* 0x3F951322, 0xAC92547B */ |
a4 = 7.38555086081402883957e-03, /* 0x3F7E404F, 0xB68FEFE8 */ |
a5 = 2.89051383673415629091e-03, /* 0x3F67ADD8, 0xCCB7926B */ |
a6 = 1.19270763183362067845e-03, /* 0x3F538A94, 0x116F3F5D */ |
a7 = 5.10069792153511336608e-04, /* 0x3F40B6C6, 0x89B99C00 */ |
a8 = 2.20862790713908385557e-04, /* 0x3F2CF2EC, 0xED10E54D */ |
a9 = 1.08011567247583939954e-04, /* 0x3F1C5088, 0x987DFB07 */ |
a10 = 2.52144565451257326939e-05, /* 0x3EFA7074, 0x428CFA52 */ |
a11 = 4.48640949618915160150e-05, /* 0x3F07858E, 0x90A45837 */ |
tc = 1.46163214496836224576e+00, /* 0x3FF762D8, 0x6356BE3F */ |
tf = -1.21486290535849611461e-01, /* 0xBFBF19B9, 0xBCC38A42 */ |
/* tt = -(tail of tf) */ |
tt = -3.63867699703950536541e-18, /* 0xBC50C7CA, 0xA48A971F */ |
t0 = 4.83836122723810047042e-01, /* 0x3FDEF72B, 0xC8EE38A2 */ |
t1 = -1.47587722994593911752e-01, /* 0xBFC2E427, 0x8DC6C509 */ |
t2 = 6.46249402391333854778e-02, /* 0x3FB08B42, 0x94D5419B */ |
t3 = -3.27885410759859649565e-02, /* 0xBFA0C9A8, 0xDF35B713 */ |
t4 = 1.79706750811820387126e-02, /* 0x3F9266E7, 0x970AF9EC */ |
t5 = -1.03142241298341437450e-02, /* 0xBF851F9F, 0xBA91EC6A */ |
t6 = 6.10053870246291332635e-03, /* 0x3F78FCE0, 0xE370E344 */ |
t7 = -3.68452016781138256760e-03, /* 0xBF6E2EFF, 0xB3E914D7 */ |
t8 = 2.25964780900612472250e-03, /* 0x3F6282D3, 0x2E15C915 */ |
t9 = -1.40346469989232843813e-03, /* 0xBF56FE8E, 0xBF2D1AF1 */ |
t10 = 8.81081882437654011382e-04, /* 0x3F4CDF0C, 0xEF61A8E9 */ |
t11 = -5.38595305356740546715e-04, /* 0xBF41A610, 0x9C73E0EC */ |
t12 = 3.15632070903625950361e-04, /* 0x3F34AF6D, 0x6C0EBBF7 */ |
t13 = -3.12754168375120860518e-04, /* 0xBF347F24, 0xECC38C38 */ |
t14 = 3.35529192635519073543e-04, /* 0x3F35FD3E, 0xE8C2D3F4 */ |
u0 = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */ |
u1 = 6.32827064025093366517e-01, /* 0x3FE4401E, 0x8B005DFF */ |
u2 = 1.45492250137234768737e+00, /* 0x3FF7475C, 0xD119BD6F */ |
u3 = 9.77717527963372745603e-01, /* 0x3FEF4976, 0x44EA8450 */ |
u4 = 2.28963728064692451092e-01, /* 0x3FCD4EAE, 0xF6010924 */ |
u5 = 1.33810918536787660377e-02, /* 0x3F8B678B, 0xBF2BAB09 */ |
v1 = 2.45597793713041134822e+00, /* 0x4003A5D7, 0xC2BD619C */ |
v2 = 2.12848976379893395361e+00, /* 0x40010725, 0xA42B18F5 */ |
v3 = 7.69285150456672783825e-01, /* 0x3FE89DFB, 0xE45050AF */ |
v4 = 1.04222645593369134254e-01, /* 0x3FBAAE55, 0xD6537C88 */ |
v5 = 3.21709242282423911810e-03, /* 0x3F6A5ABB, 0x57D0CF61 */ |
s0 = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */ |
s1 = 2.14982415960608852501e-01, /* 0x3FCB848B, 0x36E20878 */ |
s2 = 3.25778796408930981787e-01, /* 0x3FD4D98F, 0x4F139F59 */ |
s3 = 1.46350472652464452805e-01, /* 0x3FC2BB9C, 0xBEE5F2F7 */ |
s4 = 2.66422703033638609560e-02, /* 0x3F9B481C, 0x7E939961 */ |
s5 = 1.84028451407337715652e-03, /* 0x3F5E26B6, 0x7368F239 */ |
s6 = 3.19475326584100867617e-05, /* 0x3F00BFEC, 0xDD17E945 */ |
r1 = 1.39200533467621045958e+00, /* 0x3FF645A7, 0x62C4AB74 */ |
r2 = 7.21935547567138069525e-01, /* 0x3FE71A18, 0x93D3DCDC */ |
r3 = 1.71933865632803078993e-01, /* 0x3FC601ED, 0xCCFBDF27 */ |
r4 = 1.86459191715652901344e-02, /* 0x3F9317EA, 0x742ED475 */ |
r5 = 7.77942496381893596434e-04, /* 0x3F497DDA, 0xCA41A95B */ |
r6 = 7.32668430744625636189e-06, /* 0x3EDEBAF7, 0xA5B38140 */ |
w0 = 4.18938533204672725052e-01, /* 0x3FDACFE3, 0x90C97D69 */ |
w1 = 8.33333333333329678849e-02, /* 0x3FB55555, 0x5555553B */ |
w2 = -2.77777777728775536470e-03, /* 0xBF66C16C, 0x16B02E5C */ |
w3 = 7.93650558643019558500e-04, /* 0x3F4A019F, 0x98CF38B6 */ |
w4 = -5.95187557450339963135e-04, /* 0xBF4380CB, 0x8C0FE741 */ |
w5 = 8.36339918996282139126e-04, /* 0x3F4B67BA, 0x4CDAD5D1 */ |
w6 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */ |
#ifdef __STDC__ |
static const double zero= 0.00000000000000000000e+00; |
#else |
static double zero= 0.00000000000000000000e+00; |
#endif |
#ifdef __STDC__ |
static double sin_pi(double x) |
#else |
static double sin_pi(x) |
double x; |
#endif |
{ |
double y,z; |
__int32_t n,ix; |
GET_HIGH_WORD(ix,x); |
ix &= 0x7fffffff; |
if(ix<0x3fd00000) return __kernel_sin(pi*x,zero,0); |
y = -x; /* x is assume negative */ |
/* |
* argument reduction, make sure inexact flag not raised if input |
* is an integer |
*/ |
z = floor(y); |
if(z!=y) { /* inexact anyway */ |
y *= 0.5; |
y = 2.0*(y - floor(y)); /* y = |x| mod 2.0 */ |
n = (__int32_t) (y*4.0); |
} else { |
if(ix>=0x43400000) { |
y = zero; n = 0; /* y must be even */ |
} else { |
if(ix<0x43300000) z = y+two52; /* exact */ |
GET_LOW_WORD(n,z); |
n &= 1; |
y = n; |
n<<= 2; |
} |
} |
switch (n) { |
case 0: y = __kernel_sin(pi*y,zero,0); break; |
case 1: |
case 2: y = __kernel_cos(pi*(0.5-y),zero); break; |
case 3: |
case 4: y = __kernel_sin(pi*(one-y),zero,0); break; |
case 5: |
case 6: y = -__kernel_cos(pi*(y-1.5),zero); break; |
default: y = __kernel_sin(pi*(y-2.0),zero,0); break; |
} |
return -y; |
} |
#ifdef __STDC__ |
double __ieee754_lgamma_r(double x, int *signgamp) |
#else |
double __ieee754_lgamma_r(x,signgamp) |
double x; int *signgamp; |
#endif |
{ |
double t,y,z,nadj = 0.0,p,p1,p2,p3,q,r,w; |
__int32_t i,hx,lx,ix; |
EXTRACT_WORDS(hx,lx,x); |
/* purge off +-inf, NaN, +-0, and negative arguments */ |
*signgamp = 1; |
ix = hx&0x7fffffff; |
if(ix>=0x7ff00000) return x*x; |
if((ix|lx)==0) return one/zero; |
if(ix<0x3b900000) { /* |x|<2**-70, return -log(|x|) */ |
if(hx<0) { |
*signgamp = -1; |
return -__ieee754_log(-x); |
} else return -__ieee754_log(x); |
} |
if(hx<0) { |
if(ix>=0x43300000) /* |x|>=2**52, must be -integer */ |
return one/zero; |
t = sin_pi(x); |
if(t==zero) return one/zero; /* -integer */ |
nadj = __ieee754_log(pi/fabs(t*x)); |
if(t<zero) *signgamp = -1; |
x = -x; |
} |
/* purge off 1 and 2 */ |
if((((ix-0x3ff00000)|lx)==0)||(((ix-0x40000000)|lx)==0)) r = 0; |
/* for x < 2.0 */ |
else if(ix<0x40000000) { |
if(ix<=0x3feccccc) { /* lgamma(x) = lgamma(x+1)-log(x) */ |
r = -__ieee754_log(x); |
if(ix>=0x3FE76944) {y = one-x; i= 0;} |
else if(ix>=0x3FCDA661) {y= x-(tc-one); i=1;} |
else {y = x; i=2;} |
} else { |
r = zero; |
if(ix>=0x3FFBB4C3) {y=2.0-x;i=0;} /* [1.7316,2] */ |
else if(ix>=0x3FF3B4C4) {y=x-tc;i=1;} /* [1.23,1.73] */ |
else {y=x-one;i=2;} |
} |
switch(i) { |
case 0: |
z = y*y; |
p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10)))); |
p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11))))); |
p = y*p1+p2; |
r += (p-0.5*y); break; |
case 1: |
z = y*y; |
w = z*y; |
p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */ |
p2 = t1+w*(t4+w*(t7+w*(t10+w*t13))); |
p3 = t2+w*(t5+w*(t8+w*(t11+w*t14))); |
p = z*p1-(tt-w*(p2+y*p3)); |
r += (tf + p); break; |
case 2: |
p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5))))); |
p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5)))); |
r += (-0.5*y + p1/p2); |
} |
} |
else if(ix<0x40200000) { /* x < 8.0 */ |
i = (__int32_t)x; |
t = zero; |
y = x-(double)i; |
p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6)))))); |
q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6))))); |
r = half*y+p/q; |
z = one; /* lgamma(1+s) = log(s) + lgamma(s) */ |
switch(i) { |
case 7: z *= (y+6.0); /* FALLTHRU */ |
case 6: z *= (y+5.0); /* FALLTHRU */ |
case 5: z *= (y+4.0); /* FALLTHRU */ |
case 4: z *= (y+3.0); /* FALLTHRU */ |
case 3: z *= (y+2.0); /* FALLTHRU */ |
r += __ieee754_log(z); break; |
} |
/* 8.0 <= x < 2**58 */ |
} else if (ix < 0x43900000) { |
t = __ieee754_log(x); |
z = one/x; |
y = z*z; |
w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6))))); |
r = (x-half)*(t-one)+w; |
} else |
/* 2**58 <= x <= inf */ |
r = x*(__ieee754_log(x)-one); |
if(hx<0) r = nadj - r; |
return r; |
} |
/contrib/sdk/sources/libc/math/erf_gamma.c |
---|
0,0 → 1,34 |
/* erf_gamma.c -- float version of er_gamma.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* __ieee754_gammaf_r(x, signgamp) |
* Reentrant version of the logarithm of the Gamma function |
* with user provide pointer for the sign of Gamma(x). |
* |
* Method: See __ieee754_lgammaf_r |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float __ieee754_gammaf_r(float x, int *signgamp) |
#else |
float __ieee754_gammaf_r(x,signgamp) |
float x; int *signgamp; |
#endif |
{ |
return __ieee754_expf (__ieee754_lgammaf_r(x,signgamp)); |
} |
/contrib/sdk/sources/libc/math/erf_lgamma.c |
---|
0,0 → 1,244 |
/* erf_lgamma.c -- float version of er_lgamma.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
two23= 8.3886080000e+06, /* 0x4b000000 */ |
half= 5.0000000000e-01, /* 0x3f000000 */ |
one = 1.0000000000e+00, /* 0x3f800000 */ |
pi = 3.1415927410e+00, /* 0x40490fdb */ |
a0 = 7.7215664089e-02, /* 0x3d9e233f */ |
a1 = 3.2246702909e-01, /* 0x3ea51a66 */ |
a2 = 6.7352302372e-02, /* 0x3d89f001 */ |
a3 = 2.0580807701e-02, /* 0x3ca89915 */ |
a4 = 7.3855509982e-03, /* 0x3bf2027e */ |
a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */ |
a6 = 1.1927076848e-03, /* 0x3a9c54a1 */ |
a7 = 5.1006977446e-04, /* 0x3a05b634 */ |
a8 = 2.2086278477e-04, /* 0x39679767 */ |
a9 = 1.0801156895e-04, /* 0x38e28445 */ |
a10 = 2.5214456400e-05, /* 0x37d383a2 */ |
a11 = 4.4864096708e-05, /* 0x383c2c75 */ |
tc = 1.4616321325e+00, /* 0x3fbb16c3 */ |
tf = -1.2148628384e-01, /* 0xbdf8cdcd */ |
/* tt = -(tail of tf) */ |
tt = 6.6971006518e-09, /* 0x31e61c52 */ |
t0 = 4.8383611441e-01, /* 0x3ef7b95e */ |
t1 = -1.4758771658e-01, /* 0xbe17213c */ |
t2 = 6.4624942839e-02, /* 0x3d845a15 */ |
t3 = -3.2788541168e-02, /* 0xbd064d47 */ |
t4 = 1.7970675603e-02, /* 0x3c93373d */ |
t5 = -1.0314224288e-02, /* 0xbc28fcfe */ |
t6 = 6.1005386524e-03, /* 0x3bc7e707 */ |
t7 = -3.6845202558e-03, /* 0xbb7177fe */ |
t8 = 2.2596477065e-03, /* 0x3b141699 */ |
t9 = -1.4034647029e-03, /* 0xbab7f476 */ |
t10 = 8.8108185446e-04, /* 0x3a66f867 */ |
t11 = -5.3859531181e-04, /* 0xba0d3085 */ |
t12 = 3.1563205994e-04, /* 0x39a57b6b */ |
t13 = -3.1275415677e-04, /* 0xb9a3f927 */ |
t14 = 3.3552918467e-04, /* 0x39afe9f7 */ |
u0 = -7.7215664089e-02, /* 0xbd9e233f */ |
u1 = 6.3282704353e-01, /* 0x3f2200f4 */ |
u2 = 1.4549225569e+00, /* 0x3fba3ae7 */ |
u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */ |
u4 = 2.2896373272e-01, /* 0x3e6a7578 */ |
u5 = 1.3381091878e-02, /* 0x3c5b3c5e */ |
v1 = 2.4559779167e+00, /* 0x401d2ebe */ |
v2 = 2.1284897327e+00, /* 0x4008392d */ |
v3 = 7.6928514242e-01, /* 0x3f44efdf */ |
v4 = 1.0422264785e-01, /* 0x3dd572af */ |
v5 = 3.2170924824e-03, /* 0x3b52d5db */ |
s0 = -7.7215664089e-02, /* 0xbd9e233f */ |
s1 = 2.1498242021e-01, /* 0x3e5c245a */ |
s2 = 3.2577878237e-01, /* 0x3ea6cc7a */ |
s3 = 1.4635047317e-01, /* 0x3e15dce6 */ |
s4 = 2.6642270386e-02, /* 0x3cda40e4 */ |
s5 = 1.8402845599e-03, /* 0x3af135b4 */ |
s6 = 3.1947532989e-05, /* 0x3805ff67 */ |
r1 = 1.3920053244e+00, /* 0x3fb22d3b */ |
r2 = 7.2193557024e-01, /* 0x3f38d0c5 */ |
r3 = 1.7193385959e-01, /* 0x3e300f6e */ |
r4 = 1.8645919859e-02, /* 0x3c98bf54 */ |
r5 = 7.7794247773e-04, /* 0x3a4beed6 */ |
r6 = 7.3266842264e-06, /* 0x36f5d7bd */ |
w0 = 4.1893854737e-01, /* 0x3ed67f1d */ |
w1 = 8.3333335817e-02, /* 0x3daaaaab */ |
w2 = -2.7777778450e-03, /* 0xbb360b61 */ |
w3 = 7.9365057172e-04, /* 0x3a500cfd */ |
w4 = -5.9518753551e-04, /* 0xba1c065c */ |
w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */ |
w6 = -1.6309292987e-03; /* 0xbad5c4e8 */ |
#ifdef __STDC__ |
static const float zero= 0.0000000000e+00; |
#else |
static float zero= 0.0000000000e+00; |
#endif |
#ifdef __STDC__ |
static float sin_pif(float x) |
#else |
static float sin_pif(x) |
float x; |
#endif |
{ |
float y,z; |
__int32_t n,ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
if(ix<0x3e800000) return __kernel_sinf(pi*x,zero,0); |
y = -x; /* x is assume negative */ |
/* |
* argument reduction, make sure inexact flag not raised if input |
* is an integer |
*/ |
z = floorf(y); |
if(z!=y) { /* inexact anyway */ |
y *= (float)0.5; |
y = (float)2.0*(y - floorf(y)); /* y = |x| mod 2.0 */ |
n = (__int32_t) (y*(float)4.0); |
} else { |
if(ix>=0x4b800000) { |
y = zero; n = 0; /* y must be even */ |
} else { |
if(ix<0x4b000000) z = y+two23; /* exact */ |
GET_FLOAT_WORD(n,z); |
n &= 1; |
y = n; |
n<<= 2; |
} |
} |
switch (n) { |
case 0: y = __kernel_sinf(pi*y,zero,0); break; |
case 1: |
case 2: y = __kernel_cosf(pi*((float)0.5-y),zero); break; |
case 3: |
case 4: y = __kernel_sinf(pi*(one-y),zero,0); break; |
case 5: |
case 6: y = -__kernel_cosf(pi*(y-(float)1.5),zero); break; |
default: y = __kernel_sinf(pi*(y-(float)2.0),zero,0); break; |
} |
return -y; |
} |
#ifdef __STDC__ |
float __ieee754_lgammaf_r(float x, int *signgamp) |
#else |
float __ieee754_lgammaf_r(x,signgamp) |
float x; int *signgamp; |
#endif |
{ |
float t,y,z,nadj = 0.0,p,p1,p2,p3,q,r,w; |
__int32_t i,hx,ix; |
GET_FLOAT_WORD(hx,x); |
/* purge off +-inf, NaN, +-0, and negative arguments */ |
*signgamp = 1; |
ix = hx&0x7fffffff; |
if(ix>=0x7f800000) return x*x; |
if(ix==0) return one/zero; |
if(ix<0x1c800000) { /* |x|<2**-70, return -log(|x|) */ |
if(hx<0) { |
*signgamp = -1; |
return -__ieee754_logf(-x); |
} else return -__ieee754_logf(x); |
} |
if(hx<0) { |
if(ix>=0x4b000000) /* |x|>=2**23, must be -integer */ |
return one/zero; |
t = sin_pif(x); |
if(t==zero) return one/zero; /* -integer */ |
nadj = __ieee754_logf(pi/fabsf(t*x)); |
if(t<zero) *signgamp = -1; |
x = -x; |
} |
/* purge off 1 and 2 */ |
if (ix==0x3f800000||ix==0x40000000) r = 0; |
/* for x < 2.0 */ |
else if(ix<0x40000000) { |
if(ix<=0x3f666666) { /* lgamma(x) = lgamma(x+1)-log(x) */ |
r = -__ieee754_logf(x); |
if(ix>=0x3f3b4a20) {y = one-x; i= 0;} |
else if(ix>=0x3e6d3308) {y= x-(tc-one); i=1;} |
else {y = x; i=2;} |
} else { |
r = zero; |
if(ix>=0x3fdda618) {y=(float)2.0-x;i=0;} /* [1.7316,2] */ |
else if(ix>=0x3F9da620) {y=x-tc;i=1;} /* [1.23,1.73] */ |
else {y=x-one;i=2;} |
} |
switch(i) { |
case 0: |
z = y*y; |
p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10)))); |
p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11))))); |
p = y*p1+p2; |
r += (p-(float)0.5*y); break; |
case 1: |
z = y*y; |
w = z*y; |
p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */ |
p2 = t1+w*(t4+w*(t7+w*(t10+w*t13))); |
p3 = t2+w*(t5+w*(t8+w*(t11+w*t14))); |
p = z*p1-(tt-w*(p2+y*p3)); |
r += (tf + p); break; |
case 2: |
p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5))))); |
p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5)))); |
r += (-(float)0.5*y + p1/p2); |
} |
} |
else if(ix<0x41000000) { /* x < 8.0 */ |
i = (__int32_t)x; |
t = zero; |
y = x-(float)i; |
p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6)))))); |
q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6))))); |
r = half*y+p/q; |
z = one; /* lgamma(1+s) = log(s) + lgamma(s) */ |
switch(i) { |
case 7: z *= (y+(float)6.0); /* FALLTHRU */ |
case 6: z *= (y+(float)5.0); /* FALLTHRU */ |
case 5: z *= (y+(float)4.0); /* FALLTHRU */ |
case 4: z *= (y+(float)3.0); /* FALLTHRU */ |
case 3: z *= (y+(float)2.0); /* FALLTHRU */ |
r += __ieee754_logf(z); break; |
} |
/* 8.0 <= x < 2**58 */ |
} else if (ix < 0x5c800000) { |
t = __ieee754_logf(x); |
z = one/x; |
y = z*z; |
w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6))))); |
r = (x-half)*(t-one)+w; |
} else |
/* 2**58 <= x <= inf */ |
r = x*(__ieee754_logf(x)-one); |
if(hx<0) r = nadj - r; |
return r; |
} |
/contrib/sdk/sources/libc/math/f_atan2.S |
---|
0,0 → 1,37 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of atan2 using Intel float instructions. |
double _f_atan2 (double y, double x); |
Function computes arctan ( y / x ). |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_atan2) |
SOTYPE_FUNCTION(_f_atan2) |
SYM (_f_atan2): |
pushl ebp |
movl esp,ebp |
fldl 8(ebp) |
fldl 16(ebp) |
fpatan |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_atan2f.S |
---|
0,0 → 1,37 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of atan2f using Intel float instructions. |
float _f_atan2f (float y, float x); |
Function computes arctan ( y / x ). |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_atan2f) |
SOTYPE_FUNCTION(_f_atan2f) |
SYM (_f_atan2f): |
pushl ebp |
movl esp,ebp |
flds 8(ebp) |
flds 12(ebp) |
fpatan |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_exp.c |
---|
0,0 → 1,47 |
/* |
* ==================================================== |
* Copyright (C) 1998,2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of exp using Intel float instructions. |
double _f_exp (double x); |
Function computes e ** x. The following special cases exist: |
1. if x is 0.0 ==> return 1.0 |
2. if x is infinity ==> return infinity |
3. if x is -infinity ==> return 0.0 |
4. if x is NaN ==> return x |
There is no error checking or setting of errno. |
*/ |
#include <math.h> |
#include <ieeefp.h> |
#include "f_math.h" |
double _f_exp (double x) |
{ |
if (check_finite(x)) |
{ |
double result; |
asm ("fldl2e; fmulp; fld %%st; frndint; fsub %%st,%%st(1); fxch;" \ |
"fchs; f2xm1; fld1; faddp; fxch; fld1; fscale; fstp %%st(1); fmulp" : |
"=t"(result) : "0"(x)); |
return result; |
} |
else if (x == -infinity()) |
return 0.0; |
return x; |
} |
#endif |
/contrib/sdk/sources/libc/math/f_expf.c |
---|
0,0 → 1,47 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of exp using Intel float instructions. |
float _f_expf (float x); |
Function computes e ** x. The following special cases exist: |
1. if x is 0.0 ==> return 1.0 |
2. if x is infinity ==> return infinity |
3. if x is -infinity ==> return 0.0 |
4. if x is NaN ==> return x |
There is no error checking or setting of errno. |
*/ |
#include <math.h> |
#include <ieeefp.h> |
#include "f_math.h" |
float _f_expf (float x) |
{ |
if (check_finitef(x)) |
{ |
float result; |
asm ("fldl2e; fmulp; fld %%st; frndint; fsub %%st,%%st(1); fxch;" \ |
"fchs; f2xm1; fld1; faddp; fxch; fld1; fscale; fstp %%st(1); fmulp" : |
"=t"(result) : "0"(x)); |
return result; |
} |
else if (x == -infinityf()) |
return 0.0; |
return x; |
} |
#endif |
/contrib/sdk/sources/libc/math/f_frexp.S |
---|
0,0 → 1,48 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of frexp using Intel float instructions. |
double _f_frexp (double x, int *exp); |
Function splits x into y * 2 ** z. It then |
returns the value of y and updates *exp with z. |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_frexp) |
SOTYPE_FUNCTION(_f_frexp) |
SYM (_f_frexp): |
pushl ebp |
movl esp,ebp |
fldl 8(ebp) |
movl 16(ebp),eax |
fxtract |
fld1 |
fchs |
fxch |
fscale |
fstp st1 |
fxch |
fld1 |
faddp |
fistpl 0(eax) |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_frexpf.S |
---|
0,0 → 1,48 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of frexpf using Intel float instructions. |
float _f_frexpf (float x, int *exp); |
Function splits x into y * 2 ** z. It then |
returns the value of y and updates *exp with z. |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_frexpf) |
SOTYPE_FUNCTION(_f_frexpf) |
SYM (_f_frexpf): |
pushl ebp |
movl esp,ebp |
flds 8(ebp) |
movl 12(ebp),eax |
fxtract |
fld1 |
fchs |
fxch |
fscale |
fstp st1 |
fxch |
fld1 |
faddp |
fistpl 0(eax) |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_ldexp.S |
---|
0,0 → 1,38 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of ldexp using Intel float instructions. |
double _f_ldexp (double x, int exp); |
Function calculates x * 2 ** exp. |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_ldexp) |
SOTYPE_FUNCTION(_f_ldexp) |
SYM (_f_ldexp): |
pushl ebp |
movl esp,ebp |
fild 16(ebp) |
fldl 8(ebp) |
fscale |
fstp st1 |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_ldexpf.S |
---|
0,0 → 1,38 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of ldexpf using Intel float instructions. |
float _f_ldexpf (float x, int exp); |
Function calculates x * 2 ** exp. |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_ldexpf) |
SOTYPE_FUNCTION(_f_ldexpf) |
SYM (_f_ldexpf): |
pushl ebp |
movl esp,ebp |
fild 12(ebp) |
flds 8(ebp) |
fscale |
fstp st1 |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_llrint.c |
---|
0,0 → 1,70 |
/* |
* ==================================================== |
* x87 FP implementation contributed to Newlib by |
* Dave Korn, November 2007. This file is placed in the |
* public domain. Permission to use, copy, modify, and |
* distribute this software is freely granted. |
* ==================================================== |
*/ |
#ifdef __GNUC__ |
#if !defined(_SOFT_FLOAT) |
#include <math.h> |
/* |
FUNCTION |
<<llrint>>, <<llrintf>>, <<llrintl>>---round and convert to long long integer |
INDEX |
llrint |
INDEX |
llrintf |
INDEX |
llrintl |
ANSI_SYNOPSIS |
#include <math.h> |
long long int llrint(double x); |
long long int llrintf(float x); |
long long int llrintl(long double x); |
TRAD_SYNOPSIS |
ANSI-only. |
DESCRIPTION |
The <<llrint>>, <<llrintf>> and <<llrintl>> functions round <[x]> to the nearest integer value, |
according to the current rounding direction. If the rounded value is outside the |
range of the return type, the numeric result is unspecified. A range error may |
occur if the magnitude of <[x]> is too large. |
RETURNS |
These functions return the rounded integer value of <[x]>. |
<<llrint>>, <<llrintf>> and <<llrintl>> return the result as a long long integer. |
PORTABILITY |
<<llrint>>, <<llrintf>> and <<llrintl>> are ANSI. |
The fast math versions of <<llrint>>, <<llrintf>> and <<llrintl>> are only |
available on i386 platforms when hardware floating point support is available |
and when compiling with GCC. |
*/ |
/* |
* Fast math version of llrint(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using inline x87 asms. |
* Exception: |
* Governed by x87 FPCR. |
*/ |
long long int _f_llrint (double x) |
{ |
long long int _result; |
asm ("fistpll %0" : "=m" (_result) : "t" (x) : "st"); |
return _result; |
} |
#endif /* !_SOFT_FLOAT */ |
#endif /* __GNUC__ */ |
/contrib/sdk/sources/libc/math/f_llrintf.c |
---|
0,0 → 1,33 |
/* |
* ==================================================== |
* x87 FP implementation contributed to Newlib by |
* Dave Korn, November 2007. This file is placed in the |
* public domain. Permission to use, copy, modify, and |
* distribute this software is freely granted. |
* ==================================================== |
*/ |
#ifdef __GNUC__ |
#if !defined(_SOFT_FLOAT) |
#include <math.h> |
/* |
* Fast math version of llrintf(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using inline x87 asms. |
* Exception: |
* Governed by x87 FPCR. |
*/ |
long long int _f_llrintf (float x) |
{ |
long long int _result; |
asm ("fistpll %0" : "=m" (_result) : "t" (x) : "st"); |
return _result; |
} |
#endif /* !_SOFT_FLOAT */ |
#endif /* __GNUC__ */ |
/contrib/sdk/sources/libc/math/f_llrintl.c |
---|
0,0 → 1,38 |
/* |
* ==================================================== |
* x87 FP implementation contributed to Newlib by |
* Dave Korn, November 2007. This file is placed in the |
* public domain. Permission to use, copy, modify, and |
* distribute this software is freely granted. |
* ==================================================== |
*/ |
#ifdef __GNUC__ |
#if !defined(_SOFT_FLOAT) |
#include <math.h> |
/* |
* Fast math version of llrintl(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using inline x87 asms. |
* Exception: |
* Governed by x87 FPCR. |
*/ |
long long int _f_llrintl (long double x) |
{ |
long long int _result; |
asm ("fistpll %0" : "=m" (_result) : "t" (x) : "st"); |
return _result; |
} |
/* For now, we only have the fast math version. */ |
long long int llrintl (long double x) { |
return _f_llrintl(x); |
} |
#endif /* !_SOFT_FLOAT */ |
#endif /* __GNUC__ */ |
/contrib/sdk/sources/libc/math/f_log.S |
---|
0,0 → 1,40 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of log using Intel float instructions. |
double _f_log (double x); |
Function calculates the log base e of x. |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_log) |
SOTYPE_FUNCTION(_f_log) |
SYM (_f_log): |
pushl ebp |
movl esp,ebp |
fld1 |
fldl2e |
fdivrp |
fldl 8(ebp) |
fyl2x |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_log10.S |
---|
0,0 → 1,40 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of log10 using Intel float instructions. |
double _f_log10 (double x); |
Function calculates the log base 10 of x. |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_log10) |
SOTYPE_FUNCTION(_f_log10) |
SYM (_f_log10): |
pushl ebp |
movl esp,ebp |
fld1 |
fldl2t |
fdivrp |
fldl 8(ebp) |
fyl2x |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_log10f.S |
---|
0,0 → 1,40 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of logf using Intel float instructions. |
float _f_log10f (float x); |
Function calculates the log base 10 of x. |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_log10f) |
SOTYPE_FUNCTION(_f_log10f) |
SYM (_f_log10f): |
pushl ebp |
movl esp,ebp |
fld1 |
fldl2t |
fdivrp |
flds 8(ebp) |
fyl2x |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_logf.S |
---|
0,0 → 1,40 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of logf using Intel float instructions. |
float _f_logf (float x); |
Function calculates the log base e of x. |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_logf) |
SOTYPE_FUNCTION(_f_logf) |
SYM (_f_logf): |
pushl ebp |
movl esp,ebp |
fld1 |
fldl2e |
fdivrp |
flds 8(ebp) |
fyl2x |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_lrint.c |
---|
0,0 → 1,69 |
/* |
* ==================================================== |
* x87 FP implementation contributed to Newlib by |
* Dave Korn, November 2007. This file is placed in the |
* public domain. Permission to use, copy, modify, and |
* distribute this software is freely granted. |
* ==================================================== |
*/ |
#if defined(__GNUC__) && !defined(_SOFT_FLOAT) |
#include <math.h> |
/* |
FUNCTION |
<<lrint>>, <<lrintf>>, <<lrintl>>---round and convert to long integer |
INDEX |
lrint |
INDEX |
lrintf |
INDEX |
lrintl |
ANSI_SYNOPSIS |
#include <math.h> |
long int lrint(double x); |
long int lrintf(float x); |
long int lrintl(long double x); |
TRAD_SYNOPSIS |
ANSI-only. |
DESCRIPTION |
The <<lrint>>, <<lrintf>> and <<lrintl>> functions round <[x]> to the nearest integer value, |
according to the current rounding direction. If the rounded value is outside the |
range of the return type, the numeric result is unspecified. A range error may |
occur if the magnitude of <[x]> is too large. |
RETURNS |
These functions return the rounded integer value of <[x]>. |
<<lrint>>, <<lrintf>> and <<lrintl>> return the result as a long integer. |
PORTABILITY |
<<lrint>>, <<lrintf>>, and <<lrintl>> are ANSI. |
<<lrint>> and <<lrintf>> are available on all platforms. |
<<lrintl>> is only available on i386 platforms when hardware |
floating point support is available and when compiling with GCC. |
*/ |
/* |
* Fast math version of lrint(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using inline x87 asms. |
* Exception: |
* Governed by x87 FPCR. |
*/ |
long int _f_lrint (double x) |
{ |
long int _result; |
asm ("fistpl %0" : "=m" (_result) : "t" (x) : "st"); |
return _result; |
} |
#endif /* !__GNUC__ || _SOFT_FLOAT */ |
/contrib/sdk/sources/libc/math/f_lrintf.c |
---|
0,0 → 1,32 |
/* |
* ==================================================== |
* x87 FP implementation contributed to Newlib by |
* Dave Korn, November 2007. This file is placed in the |
* public domain. Permission to use, copy, modify, and |
* distribute this software is freely granted. |
* ==================================================== |
*/ |
#if defined(__GNUC__) && !defined(_SOFT_FLOAT) |
#include <math.h> |
/* |
* Fast math version of lrintf(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using inline x87 asms. |
* Exception: |
* Governed by x87 FPCR. |
*/ |
long int _f_lrintf (float x) |
{ |
long int _result; |
asm ("fistpl %0" : "=m" (_result) : "t" (x) : "st"); |
return _result; |
} |
#endif /* !__GNUC__ || _SOFT_FLOAT */ |
/contrib/sdk/sources/libc/math/f_lrintl.c |
---|
0,0 → 1,38 |
/* |
* ==================================================== |
* x87 FP implementation contributed to Newlib by |
* Dave Korn, November 2007. This file is placed in the |
* public domain. Permission to use, copy, modify, and |
* distribute this software is freely granted. |
* ==================================================== |
*/ |
#ifdef __GNUC__ |
#if !defined(_SOFT_FLOAT) |
#include <math.h> |
/* |
* Fast math version of lrintl(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using inline x87 asms. |
* Exception: |
* Governed by x87 FPCR. |
*/ |
long int _f_lrintl (long double x) |
{ |
long int _result; |
asm ("fistpl %0" : "=m" (_result) : "t" (x) : "st"); |
return _result; |
} |
/* For now, there is only the fast math version so we use it. */ |
long int lrintl (long double x) { |
return _f_lrintl(x); |
} |
#endif /* !_SOFT_FLOAT */ |
#endif /* __GNUC__ */ |
/contrib/sdk/sources/libc/math/f_math.h |
---|
0,0 → 1,29 |
#ifndef __F_MATH_H__ |
#define __F_MATH_H__ |
#include <_ansi.h> |
#include "fdlibm.h" |
__inline__ |
static |
int |
_DEFUN (check_finite, (x), |
double x) |
{ |
__int32_t hx; |
GET_HIGH_WORD(hx,x); |
return (int)((__uint32_t)((hx&0x7fffffff)-0x7ff00000)>>31); |
} |
__inline__ |
static |
int |
_DEFUN (check_finitef, (x), |
float x) |
{ |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
return (int)((__uint32_t)((ix&0x7fffffff)-0x7f800000)>>31); |
} |
#endif /* __F_MATH_H__ */ |
/contrib/sdk/sources/libc/math/f_pow.c |
---|
0,0 → 1,47 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of pow using Intel float instructions. |
double _f_pow (double x, double y); |
Function calculates x to power of y. |
The function optimizes the case where x is >0.0 and y is finite. |
In such a case, there is no error checking or setting of errno. |
All other cases defer to normal pow() function which will |
set errno as normal. |
*/ |
#include <math.h> |
#include <ieeefp.h> |
#include "f_math.h" |
double _f_pow (double x, double y) |
{ |
/* following sequence handles the majority of cases for pow() */ |
if (x > 0.0 && check_finite(y)) |
{ |
double result; |
/* calculate x ** y as 2 ** (y log2(x)). On Intel, can only |
raise 2 to an integer or a small fraction, thus, we have |
to perform two steps 2**integer portion * 2**fraction. */ |
asm ("fyl2x; fld %%st; frndint; fsub %%st,%%st(1);"\ |
"fxch; fchs; f2xm1; fld1; faddp; fxch; fld1; fscale; fstp %%st(1);"\ |
"fmulp" : "=t" (result) : "0" (x), "u" (y) : "st(1)" ); |
return result; |
} |
else /* all other strange cases, defer to normal pow() */ |
return pow (x,y); |
} |
#endif |
/contrib/sdk/sources/libc/math/f_powf.c |
---|
0,0 → 1,47 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of pow using Intel float instructions. |
float _f_powf (float x, float y); |
Function calculates x to power of y. |
The function optimizes the case where x is >0.0 and y is finite. |
In such a case, there is no error checking or setting of errno. |
All other cases defer to normal powf() function which will |
set errno as normal. |
*/ |
#include <math.h> |
#include <ieeefp.h> |
#include "f_math.h" |
float _f_powf (float x, float y) |
{ |
/* following sequence handles the majority of cases for pow() */ |
if (x > 0.0 && check_finitef(y)) |
{ |
float result; |
/* calculate x ** y as 2 ** (y log2(x)). On Intel, can only |
raise 2 to an integer or a small fraction, thus, we have |
to perform two steps 2**integer portion * 2**fraction. */ |
asm ("fyl2x; fld %%st; frndint; fsub %%st,%%st(1);"\ |
"fxch; fchs; f2xm1; fld1; faddp; fxch; fld1; fscale; fstp %%st(1);"\ |
"fmulp" : "=t" (result) : "0" (x), "u" (y) : "st(1)" ); |
return result; |
} |
else /* all other strange cases, defer to normal pow() */ |
return powf (x,y); |
} |
#endif |
/contrib/sdk/sources/libc/math/f_rint.c |
---|
0,0 → 1,67 |
/* |
* ==================================================== |
* x87 FP implementation contributed to Newlib by |
* Dave Korn, November 2007. This file is placed in the |
* public domain. Permission to use, copy, modify, and |
* distribute this software is freely granted. |
* ==================================================== |
*/ |
#if defined(__GNUC__) && !defined(_SOFT_FLOAT) |
#include <math.h> |
/* |
FUNCTION |
<<rint>>, <<rintf>>, <<rintl>>---round to integer |
INDEX |
rint |
INDEX |
rintf |
INDEX |
rintl |
ANSI_SYNOPSIS |
#include <math.h> |
double rint(double x); |
float rintf(float x); |
long double rintl(long double x); |
TRAD_SYNOPSIS |
ANSI-only. |
DESCRIPTION |
The <<rint>>, <<rintf>> and <<rintl>> functions round <[x]> to an integer value |
in floating-point format, using the current rounding direction. They may |
raise the inexact exception if the result differs in value from the argument. |
RETURNS |
These functions return the rounded integer value of <[x]>. |
PORTABILITY |
<<rint>>, <<rintf>> and <<rintl>> are ANSI. |
<<rint>> and <<rintf>> are available on all platforms. |
<<rintl>> is only available on i386 platforms when hardware |
floating point support is available and when compiling with GCC. |
*/ |
/* |
* Fast math version of rint(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using inline x87 asms. |
* Exception: |
* Governed by x87 FPCR. |
*/ |
double _f_rint (double x) |
{ |
double _result; |
asm ("frndint" : "=t" (_result) : "0" (x)); |
return _result; |
} |
#endif /* !__GNUC__ || _SOFT_FLOAT */ |
/contrib/sdk/sources/libc/math/f_rintf.c |
---|
0,0 → 1,32 |
/* |
* ==================================================== |
* x87 FP implementation contributed to Newlib by |
* Dave Korn, November 2007. This file is placed in the |
* public domain. Permission to use, copy, modify, and |
* distribute this software is freely granted. |
* ==================================================== |
*/ |
#if defined(__GNUC__) && !defined(_SOFT_FLOAT) |
#include <math.h> |
/* |
* Fast math version of rintf(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using inline x87 asms. |
* Exception: |
* Governed by x87 FPCR. |
*/ |
float _f_rintf (float x) |
{ |
float _result; |
asm ("frndint" : "=t" (_result) : "0" (x)); |
return _result; |
} |
#endif /* !__GNUC__ || _SOFT_FLOAT */ |
/contrib/sdk/sources/libc/math/f_rintl.c |
---|
0,0 → 1,38 |
/* |
* ==================================================== |
* x87 FP implementation contributed to Newlib by |
* Dave Korn, November 2007. This file is placed in the |
* public domain. Permission to use, copy, modify, and |
* distribute this software is freely granted. |
* ==================================================== |
*/ |
#ifdef __GNUC__ |
#if !defined(_SOFT_FLOAT) |
#include <math.h> |
/* |
* Fast math version of rintl(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using inline x87 asms. |
* Exception: |
* Governed by x87 FPCR. |
*/ |
long double _f_rintl (long double x) |
{ |
long double _result; |
asm ("frndint" : "=t" (_result) : "0" (x)); |
return _result; |
} |
/* For now, we only have the fast math version. */ |
long double rintl (long double x) { |
return _f_rintl(x); |
} |
#endif /* !_SOFT_FLOAT */ |
#endif /* __GNUC__ */ |
/contrib/sdk/sources/libc/math/f_tan.S |
---|
0,0 → 1,38 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of tan using Intel float instructions. |
double _f_tan (double x); |
Function calculates the tangent of x. |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_tan) |
SOTYPE_FUNCTION(_f_tan) |
SYM (_f_tan): |
pushl ebp |
movl esp,ebp |
fldl 8(ebp) |
fptan |
ffree %st(0) |
fincstp |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/f_tanf.S |
---|
0,0 → 1,38 |
/* |
* ==================================================== |
* Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#if !defined(_SOFT_FLOAT) |
/* |
Fast version of tanf using Intel float instructions. |
float _f_tanf (float x); |
Function calculates the tangent of x. |
There is no error checking or setting of errno. |
*/ |
#include "i386mach.h" |
.global SYM (_f_tanf) |
SOTYPE_FUNCTION(_f_tanf) |
SYM (_f_tanf): |
pushl ebp |
movl esp,ebp |
flds 8(ebp) |
fptan |
ffree %st(0) |
fincstp |
leave |
ret |
#endif |
/contrib/sdk/sources/libc/math/fdlibm.h |
---|
0,0 → 1,404 |
/* @(#)fdlibm.h 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* REDHAT LOCAL: Include files. */ |
#include <math.h> |
#include <sys/types.h> |
#include <machine/ieeefp.h> |
/* REDHAT LOCAL: Default to XOPEN_MODE. */ |
#define _XOPEN_MODE |
/* Most routines need to check whether a float is finite, infinite, or not a |
number, and many need to know whether the result of an operation will |
overflow. These conditions depend on whether the largest exponent is |
used for NaNs & infinities, or whether it's used for finite numbers. The |
macros below wrap up that kind of information: |
FLT_UWORD_IS_FINITE(X) |
True if a positive float with bitmask X is finite. |
FLT_UWORD_IS_NAN(X) |
True if a positive float with bitmask X is not a number. |
FLT_UWORD_IS_INFINITE(X) |
True if a positive float with bitmask X is +infinity. |
FLT_UWORD_MAX |
The bitmask of FLT_MAX. |
FLT_UWORD_HALF_MAX |
The bitmask of FLT_MAX/2. |
FLT_UWORD_EXP_MAX |
The bitmask of the largest finite exponent (129 if the largest |
exponent is used for finite numbers, 128 otherwise). |
FLT_UWORD_LOG_MAX |
The bitmask of log(FLT_MAX), rounded down. This value is the largest |
input that can be passed to exp() without producing overflow. |
FLT_UWORD_LOG_2MAX |
The bitmask of log(2*FLT_MAX), rounded down. This value is the |
largest input than can be passed to cosh() without producing |
overflow. |
FLT_LARGEST_EXP |
The largest biased exponent that can be used for finite numbers |
(255 if the largest exponent is used for finite numbers, 254 |
otherwise) */ |
#ifdef _FLT_LARGEST_EXPONENT_IS_NORMAL |
#define FLT_UWORD_IS_FINITE(x) 1 |
#define FLT_UWORD_IS_NAN(x) 0 |
#define FLT_UWORD_IS_INFINITE(x) 0 |
#define FLT_UWORD_MAX 0x7fffffff |
#define FLT_UWORD_EXP_MAX 0x43010000 |
#define FLT_UWORD_LOG_MAX 0x42b2d4fc |
#define FLT_UWORD_LOG_2MAX 0x42b437e0 |
#define HUGE ((float)0X1.FFFFFEP128) |
#else |
#define FLT_UWORD_IS_FINITE(x) ((x)<0x7f800000L) |
#define FLT_UWORD_IS_NAN(x) ((x)>0x7f800000L) |
#define FLT_UWORD_IS_INFINITE(x) ((x)==0x7f800000L) |
#define FLT_UWORD_MAX 0x7f7fffffL |
#define FLT_UWORD_EXP_MAX 0x43000000 |
#define FLT_UWORD_LOG_MAX 0x42b17217 |
#define FLT_UWORD_LOG_2MAX 0x42b2d4fc |
#define HUGE ((float)3.40282346638528860e+38) |
#endif |
#define FLT_UWORD_HALF_MAX (FLT_UWORD_MAX-(1L<<23)) |
#define FLT_LARGEST_EXP (FLT_UWORD_MAX>>23) |
/* Many routines check for zero and subnormal numbers. Such things depend |
on whether the target supports denormals or not: |
FLT_UWORD_IS_ZERO(X) |
True if a positive float with bitmask X is +0. Without denormals, |
any float with a zero exponent is a +0 representation. With |
denormals, the only +0 representation is a 0 bitmask. |
FLT_UWORD_IS_SUBNORMAL(X) |
True if a non-zero positive float with bitmask X is subnormal. |
(Routines should check for zeros first.) |
FLT_UWORD_MIN |
The bitmask of the smallest float above +0. Call this number |
REAL_FLT_MIN... |
FLT_UWORD_EXP_MIN |
The bitmask of the float representation of REAL_FLT_MIN's exponent. |
FLT_UWORD_LOG_MIN |
The bitmask of |log(REAL_FLT_MIN)|, rounding down. |
FLT_SMALLEST_EXP |
REAL_FLT_MIN's exponent - EXP_BIAS (1 if denormals are not supported, |
-22 if they are). |
*/ |
#ifdef _FLT_NO_DENORMALS |
#define FLT_UWORD_IS_ZERO(x) ((x)<0x00800000L) |
#define FLT_UWORD_IS_SUBNORMAL(x) 0 |
#define FLT_UWORD_MIN 0x00800000 |
#define FLT_UWORD_EXP_MIN 0x42fc0000 |
#define FLT_UWORD_LOG_MIN 0x42aeac50 |
#define FLT_SMALLEST_EXP 1 |
#else |
#define FLT_UWORD_IS_ZERO(x) ((x)==0) |
#define FLT_UWORD_IS_SUBNORMAL(x) ((x)<0x00800000L) |
#define FLT_UWORD_MIN 0x00000001 |
#define FLT_UWORD_EXP_MIN 0x43160000 |
#define FLT_UWORD_LOG_MIN 0x42cff1b5 |
#define FLT_SMALLEST_EXP -22 |
#endif |
#ifdef __STDC__ |
#undef __P |
#define __P(p) p |
#else |
#define __P(p) () |
#endif |
/* |
* set X_TLOSS = pi*2**52, which is possibly defined in <values.h> |
* (one may replace the following line by "#include <values.h>") |
*/ |
#define X_TLOSS 1.41484755040568800000e+16 |
/* Functions that are not documented, and are not in <math.h>. */ |
#ifdef _SCALB_INT |
extern double scalb __P((double, int)); |
#else |
extern double scalb __P((double, double)); |
#endif |
extern double significand __P((double)); |
/* ieee style elementary functions */ |
extern double __ieee754_sqrt __P((double)); |
extern double __ieee754_acos __P((double)); |
extern double __ieee754_acosh __P((double)); |
extern double __ieee754_log __P((double)); |
extern double __ieee754_atanh __P((double)); |
extern double __ieee754_asin __P((double)); |
extern double __ieee754_atan2 __P((double,double)); |
extern double __ieee754_exp __P((double)); |
extern double __ieee754_cosh __P((double)); |
extern double __ieee754_fmod __P((double,double)); |
extern double __ieee754_pow __P((double,double)); |
extern double __ieee754_lgamma_r __P((double,int *)); |
extern double __ieee754_gamma_r __P((double,int *)); |
extern double __ieee754_log10 __P((double)); |
extern double __ieee754_sinh __P((double)); |
extern double __ieee754_hypot __P((double,double)); |
extern double __ieee754_j0 __P((double)); |
extern double __ieee754_j1 __P((double)); |
extern double __ieee754_y0 __P((double)); |
extern double __ieee754_y1 __P((double)); |
extern double __ieee754_jn __P((int,double)); |
extern double __ieee754_yn __P((int,double)); |
extern double __ieee754_remainder __P((double,double)); |
extern __int32_t __ieee754_rem_pio2 __P((double,double*)); |
#ifdef _SCALB_INT |
extern double __ieee754_scalb __P((double,int)); |
#else |
extern double __ieee754_scalb __P((double,double)); |
#endif |
/* fdlibm kernel function */ |
extern double __kernel_standard __P((double,double,int)); |
extern double __kernel_sin __P((double,double,int)); |
extern double __kernel_cos __P((double,double)); |
extern double __kernel_tan __P((double,double,int)); |
extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const __int32_t*)); |
/* Undocumented float functions. */ |
#ifdef _SCALB_INT |
extern float scalbf __P((float, int)); |
#else |
extern float scalbf __P((float, float)); |
#endif |
extern float significandf __P((float)); |
/* ieee style elementary float functions */ |
extern float __ieee754_sqrtf __P((float)); |
extern float __ieee754_acosf __P((float)); |
extern float __ieee754_acoshf __P((float)); |
extern float __ieee754_logf __P((float)); |
extern float __ieee754_atanhf __P((float)); |
extern float __ieee754_asinf __P((float)); |
extern float __ieee754_atan2f __P((float,float)); |
extern float __ieee754_expf __P((float)); |
extern float __ieee754_coshf __P((float)); |
extern float __ieee754_fmodf __P((float,float)); |
extern float __ieee754_powf __P((float,float)); |
extern float __ieee754_lgammaf_r __P((float,int *)); |
extern float __ieee754_gammaf_r __P((float,int *)); |
extern float __ieee754_log10f __P((float)); |
extern float __ieee754_sinhf __P((float)); |
extern float __ieee754_hypotf __P((float,float)); |
extern float __ieee754_j0f __P((float)); |
extern float __ieee754_j1f __P((float)); |
extern float __ieee754_y0f __P((float)); |
extern float __ieee754_y1f __P((float)); |
extern float __ieee754_jnf __P((int,float)); |
extern float __ieee754_ynf __P((int,float)); |
extern float __ieee754_remainderf __P((float,float)); |
extern __int32_t __ieee754_rem_pio2f __P((float,float*)); |
#ifdef _SCALB_INT |
extern float __ieee754_scalbf __P((float,int)); |
#else |
extern float __ieee754_scalbf __P((float,float)); |
#endif |
/* float versions of fdlibm kernel functions */ |
extern float __kernel_sinf __P((float,float,int)); |
extern float __kernel_cosf __P((float,float)); |
extern float __kernel_tanf __P((float,float,int)); |
extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const __int32_t*)); |
/* The original code used statements like |
n0 = ((*(int*)&one)>>29)^1; * index of high word * |
ix0 = *(n0+(int*)&x); * high word of x * |
ix1 = *((1-n0)+(int*)&x); * low word of x * |
to dig two 32 bit words out of the 64 bit IEEE floating point |
value. That is non-ANSI, and, moreover, the gcc instruction |
scheduler gets it wrong. We instead use the following macros. |
Unlike the original code, we determine the endianness at compile |
time, not at run time; I don't see much benefit to selecting |
endianness at run time. */ |
#ifndef __IEEE_BIG_ENDIAN |
#ifndef __IEEE_LITTLE_ENDIAN |
#error Must define endianness |
#endif |
#endif |
/* A union which permits us to convert between a double and two 32 bit |
ints. */ |
#ifdef __IEEE_BIG_ENDIAN |
typedef union |
{ |
double value; |
struct |
{ |
__uint32_t msw; |
__uint32_t lsw; |
} parts; |
} ieee_double_shape_type; |
#endif |
#ifdef __IEEE_LITTLE_ENDIAN |
typedef union |
{ |
double value; |
struct |
{ |
__uint32_t lsw; |
__uint32_t msw; |
} parts; |
} ieee_double_shape_type; |
#endif |
/* Get two 32 bit ints from a double. */ |
#define EXTRACT_WORDS(ix0,ix1,d) \ |
do { \ |
ieee_double_shape_type ew_u; \ |
ew_u.value = (d); \ |
(ix0) = ew_u.parts.msw; \ |
(ix1) = ew_u.parts.lsw; \ |
} while (0) |
/* Get the more significant 32 bit int from a double. */ |
#define GET_HIGH_WORD(i,d) \ |
do { \ |
ieee_double_shape_type gh_u; \ |
gh_u.value = (d); \ |
(i) = gh_u.parts.msw; \ |
} while (0) |
/* Get the less significant 32 bit int from a double. */ |
#define GET_LOW_WORD(i,d) \ |
do { \ |
ieee_double_shape_type gl_u; \ |
gl_u.value = (d); \ |
(i) = gl_u.parts.lsw; \ |
} while (0) |
/* Set a double from two 32 bit ints. */ |
#define INSERT_WORDS(d,ix0,ix1) \ |
do { \ |
ieee_double_shape_type iw_u; \ |
iw_u.parts.msw = (ix0); \ |
iw_u.parts.lsw = (ix1); \ |
(d) = iw_u.value; \ |
} while (0) |
/* Set the more significant 32 bits of a double from an int. */ |
#define SET_HIGH_WORD(d,v) \ |
do { \ |
ieee_double_shape_type sh_u; \ |
sh_u.value = (d); \ |
sh_u.parts.msw = (v); \ |
(d) = sh_u.value; \ |
} while (0) |
/* Set the less significant 32 bits of a double from an int. */ |
#define SET_LOW_WORD(d,v) \ |
do { \ |
ieee_double_shape_type sl_u; \ |
sl_u.value = (d); \ |
sl_u.parts.lsw = (v); \ |
(d) = sl_u.value; \ |
} while (0) |
/* A union which permits us to convert between a float and a 32 bit |
int. */ |
typedef union |
{ |
float value; |
__uint32_t word; |
} ieee_float_shape_type; |
/* Get a 32 bit int from a float. */ |
#define GET_FLOAT_WORD(i,d) \ |
do { \ |
ieee_float_shape_type gf_u; \ |
gf_u.value = (d); \ |
(i) = gf_u.word; \ |
} while (0) |
/* Set a float from a 32 bit int. */ |
#define SET_FLOAT_WORD(d,i) \ |
do { \ |
ieee_float_shape_type sf_u; \ |
sf_u.word = (i); \ |
(d) = sf_u.value; \ |
} while (0) |
/* Macros to avoid undefined behaviour that can arise if the amount |
of a shift is exactly equal to the size of the shifted operand. */ |
#define SAFE_LEFT_SHIFT(op,amt) \ |
(((amt) < 8 * sizeof(op)) ? ((op) << (amt)) : 0) |
#define SAFE_RIGHT_SHIFT(op,amt) \ |
(((amt) < 8 * sizeof(op)) ? ((op) >> (amt)) : 0) |
#ifdef _COMPLEX_H |
/* |
* Quoting from ISO/IEC 9899:TC2: |
* |
* 6.2.5.13 Types |
* Each complex type has the same representation and alignment requirements as |
* an array type containing exactly two elements of the corresponding real type; |
* the first element is equal to the real part, and the second element to the |
* imaginary part, of the complex number. |
*/ |
typedef union { |
float complex z; |
float parts[2]; |
} float_complex; |
typedef union { |
double complex z; |
double parts[2]; |
} double_complex; |
typedef union { |
long double complex z; |
long double parts[2]; |
} long_double_complex; |
#define REAL_PART(z) ((z).parts[0]) |
#define IMAG_PART(z) ((z).parts[1]) |
#endif /* _COMPLEX_H */ |
/contrib/sdk/sources/libc/math/i386mach.h |
---|
0,0 → 1,83 |
/* This file was based on the modified setjmp.S performed by |
* Joel Sherill (joel@OARcorp.com) which specified the use |
* of the __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ macros. |
** |
** This file is distributed WITHOUT ANY WARRANTY; without even the implied |
** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* These are predefined by new versions of GNU cpp. */ |
#ifndef __USER_LABEL_PREFIX__ |
#define __USER_LABEL_PREFIX__ _ |
#endif |
#define __REG_PREFIX__ % |
/* ANSI concatenation macros. */ |
#define CONCAT1(a, b) CONCAT2(a, b) |
#define CONCAT2(a, b) a##b |
/* Use the right prefix for global labels. */ |
#define SYM(x) CONCAT1(__USER_LABEL_PREFIX__, x) |
/* Use the right prefix for registers. */ |
#define REG(x) CONCAT1(__REG_PREFIX__, x) |
#define eax REG(eax) |
#define ebx REG(ebx) |
#define ecx REG(ecx) |
#define edx REG(edx) |
#define esi REG(esi) |
#define edi REG(edi) |
#define ebp REG(ebp) |
#define esp REG(esp) |
#define st0 REG(st) |
#define st1 REG(st(1)) |
#define st2 REG(st(2)) |
#define st3 REG(st(3)) |
#define st4 REG(st(4)) |
#define st5 REG(st(5)) |
#define st6 REG(st(6)) |
#define st7 REG(st(7)) |
#define ax REG(ax) |
#define bx REG(bx) |
#define cx REG(cx) |
#define dx REG(dx) |
#define ah REG(ah) |
#define bh REG(bh) |
#define ch REG(ch) |
#define dh REG(dh) |
#define al REG(al) |
#define bl REG(bl) |
#define cl REG(cl) |
#define dl REG(dl) |
#define mm1 REG(mm1) |
#define mm2 REG(mm2) |
#define mm3 REG(mm3) |
#define mm4 REG(mm4) |
#define mm5 REG(mm5) |
#define mm6 REG(mm6) |
#define mm7 REG(mm7) |
#ifdef _I386MACH_NEED_SOTYPE_FUNCTION |
#define SOTYPE_FUNCTION(sym) .type SYM(sym),@function |
#else |
#define SOTYPE_FUNCTION(sym) |
#endif |
#ifdef _I386MACH_ALLOW_HW_INTERRUPTS |
#define __CLI |
#define __STI |
#else |
#define __CLI cli |
#define __STI sti |
#endif |
/contrib/sdk/sources/libc/math/k_cos.c |
---|
0,0 → 1,96 |
/* @(#)k_cos.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* __kernel_cos( x, y ) |
* kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164 |
* Input x is assumed to be bounded by ~pi/4 in magnitude. |
* Input y is the tail of x. |
* |
* Algorithm |
* 1. Since cos(-x) = cos(x), we need only to consider positive x. |
* 2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0. |
* 3. cos(x) is approximated by a polynomial of degree 14 on |
* [0,pi/4] |
* 4 14 |
* cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x |
* where the remez error is |
* |
* | 2 4 6 8 10 12 14 | -58 |
* |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2 |
* | | |
* |
* 4 6 8 10 12 14 |
* 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then |
* cos(x) = 1 - x*x/2 + r |
* since cos(x+y) ~ cos(x) - sin(x)*y |
* ~ cos(x) - x*y, |
* a correction term is necessary in cos(x) and hence |
* cos(x+y) = 1 - (x*x/2 - (r - x*y)) |
* For better accuracy when x > 0.3, let qx = |x|/4 with |
* the last 32 bits mask off, and if x > 0.78125, let qx = 0.28125. |
* Then |
* cos(x+y) = (1-qx) - ((x*x/2-qx) - (r-x*y)). |
* Note that 1-qx and (x*x/2-qx) is EXACT here, and the |
* magnitude of the latter is at least a quarter of x*x/2, |
* thus, reducing the rounding error in the subtraction. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */ |
C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */ |
C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */ |
C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */ |
C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ |
C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ |
#ifdef __STDC__ |
double __kernel_cos(double x, double y) |
#else |
double __kernel_cos(x, y) |
double x,y; |
#endif |
{ |
double a,hz,z,r,qx; |
__int32_t ix; |
GET_HIGH_WORD(ix,x); |
ix &= 0x7fffffff; /* ix = |x|'s high word*/ |
if(ix<0x3e400000) { /* if x < 2**27 */ |
if(((int)x)==0) return one; /* generate inexact */ |
} |
z = x*x; |
r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6))))); |
if(ix < 0x3FD33333) /* if |x| < 0.3 */ |
return one - (0.5*z - (z*r - x*y)); |
else { |
if(ix > 0x3fe90000) { /* x > 0.78125 */ |
qx = 0.28125; |
} else { |
INSERT_WORDS(qx,ix-0x00200000,0); /* x/4 */ |
} |
hz = 0.5*z-qx; |
a = one-qx; |
return a - (hz - (z*r-x*y)); |
} |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/k_rem_pio2.c |
---|
0,0 → 1,320 |
/* @(#)k_rem_pio2.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) |
* double x[],y[]; int e0,nx,prec; int ipio2[]; |
* |
* __kernel_rem_pio2 return the last three digits of N with |
* y = x - N*pi/2 |
* so that |y| < pi/2. |
* |
* The method is to compute the integer (mod 8) and fraction parts of |
* (2/pi)*x without doing the full multiplication. In general we |
* skip the part of the product that are known to be a huge integer ( |
* more accurately, = 0 mod 8 ). Thus the number of operations are |
* independent of the exponent of the input. |
* |
* (2/pi) is represented by an array of 24-bit integers in ipio2[]. |
* |
* Input parameters: |
* x[] The input value (must be positive) is broken into nx |
* pieces of 24-bit integers in double precision format. |
* x[i] will be the i-th 24 bit of x. The scaled exponent |
* of x[0] is given in input parameter e0 (i.e., x[0]*2^e0 |
* match x's up to 24 bits. |
* |
* Example of breaking a double positive z into x[0]+x[1]+x[2]: |
* e0 = ilogb(z)-23 |
* z = scalbn(z,-e0) |
* for i = 0,1,2 |
* x[i] = floor(z) |
* z = (z-x[i])*2**24 |
* |
* |
* y[] ouput result in an array of double precision numbers. |
* The dimension of y[] is: |
* 24-bit precision 1 |
* 53-bit precision 2 |
* 64-bit precision 2 |
* 113-bit precision 3 |
* The actual value is the sum of them. Thus for 113-bit |
* precison, one may have to do something like: |
* |
* long double t,w,r_head, r_tail; |
* t = (long double)y[2] + (long double)y[1]; |
* w = (long double)y[0]; |
* r_head = t+w; |
* r_tail = w - (r_head - t); |
* |
* e0 The exponent of x[0] |
* |
* nx dimension of x[] |
* |
* prec an integer indicating the precision: |
* 0 24 bits (single) |
* 1 53 bits (double) |
* 2 64 bits (extended) |
* 3 113 bits (quad) |
* |
* ipio2[] |
* integer array, contains the (24*i)-th to (24*i+23)-th |
* bit of 2/pi after binary point. The corresponding |
* floating value is |
* |
* ipio2[i] * 2^(-24(i+1)). |
* |
* External function: |
* double scalbn(), floor(); |
* |
* |
* Here is the description of some local variables: |
* |
* jk jk+1 is the initial number of terms of ipio2[] needed |
* in the computation. The recommended value is 2,3,4, |
* 6 for single, double, extended,and quad. |
* |
* jz local integer variable indicating the number of |
* terms of ipio2[] used. |
* |
* jx nx - 1 |
* |
* jv index for pointing to the suitable ipio2[] for the |
* computation. In general, we want |
* ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8 |
* is an integer. Thus |
* e0-3-24*jv >= 0 or (e0-3)/24 >= jv |
* Hence jv = max(0,(e0-3)/24). |
* |
* jp jp+1 is the number of terms in PIo2[] needed, jp = jk. |
* |
* q[] double array with integral value, representing the |
* 24-bits chunk of the product of x and 2/pi. |
* |
* q0 the corresponding exponent of q[0]. Note that the |
* exponent for q[i] would be q0-24*i. |
* |
* PIo2[] double precision array, obtained by cutting pi/2 |
* into 24 bits chunks. |
* |
* f[] ipio2[] in floating point |
* |
* iq[] integer array by breaking up q[] in 24-bits chunk. |
* |
* fq[] final product of x*(2/pi) in fq[0],..,fq[jk] |
* |
* ih integer. If >0 it indicates q[] is >= 0.5, hence |
* it also indicates the *sign* of the result. |
* |
*/ |
/* |
* Constants: |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const int init_jk[] = {2,3,4,6}; /* initial value for jk */ |
#else |
static int init_jk[] = {2,3,4,6}; |
#endif |
#ifdef __STDC__ |
static const double PIo2[] = { |
#else |
static double PIo2[] = { |
#endif |
1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */ |
7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */ |
5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */ |
3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */ |
1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */ |
1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */ |
2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */ |
2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */ |
}; |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
zero = 0.0, |
one = 1.0, |
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ |
twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */ |
#ifdef __STDC__ |
int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const __int32_t *ipio2) |
#else |
int __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) |
double x[], y[]; int e0,nx,prec; __int32_t ipio2[]; |
#endif |
{ |
__int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; |
double z,fw,f[20],fq[20],q[20]; |
/* initialize jk*/ |
jk = init_jk[prec]; |
jp = jk; |
/* determine jx,jv,q0, note that 3>q0 */ |
jx = nx-1; |
jv = (e0-3)/24; if(jv<0) jv=0; |
q0 = e0-24*(jv+1); |
/* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ |
j = jv-jx; m = jx+jk; |
for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j]; |
/* compute q[0],q[1],...q[jk] */ |
for (i=0;i<=jk;i++) { |
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw; |
} |
jz = jk; |
recompute: |
/* distill q[] into iq[] reversingly */ |
for(i=0,j=jz,z=q[jz];j>0;i++,j--) { |
fw = (double)((__int32_t)(twon24* z)); |
iq[i] = (__int32_t)(z-two24*fw); |
z = q[j-1]+fw; |
} |
/* compute n */ |
z = scalbn(z,(int)q0); /* actual value of z */ |
z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */ |
n = (__int32_t) z; |
z -= (double)n; |
ih = 0; |
if(q0>0) { /* need iq[jz-1] to determine n */ |
i = (iq[jz-1]>>(24-q0)); n += i; |
iq[jz-1] -= i<<(24-q0); |
ih = iq[jz-1]>>(23-q0); |
} |
else if(q0==0) ih = iq[jz-1]>>23; |
else if(z>=0.5) ih=2; |
if(ih>0) { /* q > 0.5 */ |
n += 1; carry = 0; |
for(i=0;i<jz ;i++) { /* compute 1-q */ |
j = iq[i]; |
if(carry==0) { |
if(j!=0) { |
carry = 1; iq[i] = 0x1000000- j; |
} |
} else iq[i] = 0xffffff - j; |
} |
if(q0>0) { /* rare case: chance is 1 in 12 */ |
switch(q0) { |
case 1: |
iq[jz-1] &= 0x7fffff; break; |
case 2: |
iq[jz-1] &= 0x3fffff; break; |
} |
} |
if(ih==2) { |
z = one - z; |
if(carry!=0) z -= scalbn(one,(int)q0); |
} |
} |
/* check if recomputation is needed */ |
if(z==zero) { |
j = 0; |
for (i=jz-1;i>=jk;i--) j |= iq[i]; |
if(j==0) { /* need recomputation */ |
for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */ |
for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */ |
f[jx+i] = (double) ipio2[jv+i]; |
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; |
q[i] = fw; |
} |
jz += k; |
goto recompute; |
} |
} |
/* chop off zero terms */ |
if(z==0.0) { |
jz -= 1; q0 -= 24; |
while(iq[jz]==0) { jz--; q0-=24;} |
} else { /* break z into 24-bit if necessary */ |
z = scalbn(z,-(int)q0); |
if(z>=two24) { |
fw = (double)((__int32_t)(twon24*z)); |
iq[jz] = (__int32_t)(z-two24*fw); |
jz += 1; q0 += 24; |
iq[jz] = (__int32_t) fw; |
} else iq[jz] = (__int32_t) z ; |
} |
/* convert integer "bit" chunk to floating-point value */ |
fw = scalbn(one,(int)q0); |
for(i=jz;i>=0;i--) { |
q[i] = fw*(double)iq[i]; fw*=twon24; |
} |
/* compute PIo2[0,...,jp]*q[jz,...,0] */ |
for(i=jz;i>=0;i--) { |
for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k]; |
fq[jz-i] = fw; |
} |
/* compress fq[] into y[] */ |
switch(prec) { |
case 0: |
fw = 0.0; |
for (i=jz;i>=0;i--) fw += fq[i]; |
y[0] = (ih==0)? fw: -fw; |
break; |
case 1: |
case 2: |
fw = 0.0; |
for (i=jz;i>=0;i--) fw += fq[i]; |
y[0] = (ih==0)? fw: -fw; |
fw = fq[0]-fw; |
for (i=1;i<=jz;i++) fw += fq[i]; |
y[1] = (ih==0)? fw: -fw; |
break; |
case 3: /* painful */ |
for (i=jz;i>0;i--) { |
fw = fq[i-1]+fq[i]; |
fq[i] += fq[i-1]-fw; |
fq[i-1] = fw; |
} |
for (i=jz;i>1;i--) { |
fw = fq[i-1]+fq[i]; |
fq[i] += fq[i-1]-fw; |
fq[i-1] = fw; |
} |
for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; |
if(ih==0) { |
y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; |
} else { |
y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; |
} |
} |
return n&7; |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/k_sin.c |
---|
0,0 → 1,79 |
/* @(#)k_sin.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __kernel_sin( x, y, iy) |
* kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854 |
* Input x is assumed to be bounded by ~pi/4 in magnitude. |
* Input y is the tail of x. |
* Input iy indicates whether y is 0. (if iy=0, y assume to be 0). |
* |
* Algorithm |
* 1. Since sin(-x) = -sin(x), we need only to consider positive x. |
* 2. if x < 2^-27 (hx<0x3e400000 0), return x with inexact if x!=0. |
* 3. sin(x) is approximated by a polynomial of degree 13 on |
* [0,pi/4] |
* 3 13 |
* sin(x) ~ x + S1*x + ... + S6*x |
* where |
* |
* |sin(x) 2 4 6 8 10 12 | -58 |
* |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2 |
* | x | |
* |
* 4. sin(x+y) = sin(x) + sin'(x')*y |
* ~ sin(x) + (1-x*x/2)*y |
* For better accuracy, let |
* 3 2 2 2 2 |
* r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6)))) |
* then 3 2 |
* sin(x) = x + (S1*x + (x *(r-y/2)+y)) |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ |
S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */ |
S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */ |
S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */ |
S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */ |
S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */ |
S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ |
#ifdef __STDC__ |
double __kernel_sin(double x, double y, int iy) |
#else |
double __kernel_sin(x, y, iy) |
double x,y; int iy; /* iy=0 if y is zero */ |
#endif |
{ |
double z,r,v; |
__int32_t ix; |
GET_HIGH_WORD(ix,x); |
ix &= 0x7fffffff; /* high word of x */ |
if(ix<0x3e400000) /* |x| < 2**-27 */ |
{if((int)x==0) return x;} /* generate inexact */ |
z = x*x; |
v = z*x; |
r = S2+z*(S3+z*(S4+z*(S5+z*S6))); |
if(iy==0) return x+v*(S1+z*r); |
else return x-((z*(half*y-v*r)-y)-v*S1); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/k_standard.c |
---|
0,0 → 1,784 |
/* @(#)k_standard.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _USE_WRITE |
#include <stdio.h> /* fputs(), stderr */ |
#define WRITE2(u,v) fputs(u, stderr) |
#else /* !defined(_USE_WRITE) */ |
#include <unistd.h> /* write */ |
#define WRITE2(u,v) write(2, u, v) |
#undef fflush |
#endif /* !defined(_USE_WRITE) */ |
#ifdef __STDC__ |
static const double zero = 0.0; /* used as const */ |
#else |
static double zero = 0.0; /* used as const */ |
#endif |
/* |
* Standard conformance (non-IEEE) on exception cases. |
* Mapping: |
* 1 -- acos(|x|>1) |
* 2 -- asin(|x|>1) |
* 3 -- atan2(+-0,+-0) |
* 4 -- hypot overflow |
* 5 -- cosh overflow |
* 6 -- exp overflow |
* 7 -- exp underflow |
* 8 -- y0(0) |
* 9 -- y0(-ve) |
* 10-- y1(0) |
* 11-- y1(-ve) |
* 12-- yn(0) |
* 13-- yn(-ve) |
* 14-- lgamma(finite) overflow |
* 15-- lgamma(-integer) |
* 16-- log(0) |
* 17-- log(x<0) |
* 18-- log10(0) |
* 19-- log10(x<0) |
* 20-- pow(0.0,0.0) |
* 21-- pow(x,y) overflow |
* 22-- pow(x,y) underflow |
* 23-- pow(0,negative) |
* 24-- pow(neg,non-integral) |
* 25-- sinh(finite) overflow |
* 26-- sqrt(negative) |
* 27-- fmod(x,0) |
* 28-- remainder(x,0) |
* 29-- acosh(x<1) |
* 30-- atanh(|x|>1) |
* 31-- atanh(|x|=1) |
* 32-- scalb overflow |
* 33-- scalb underflow |
* 34-- j0(|x|>X_TLOSS) |
* 35-- y0(x>X_TLOSS) |
* 36-- j1(|x|>X_TLOSS) |
* 37-- y1(x>X_TLOSS) |
* 38-- jn(|x|>X_TLOSS, n) |
* 39-- yn(x>X_TLOSS, n) |
* 40-- gamma(finite) overflow |
* 41-- gamma(-integer) |
* 42-- pow(NaN,0.0) |
*/ |
#ifdef __STDC__ |
double __kernel_standard(double x, double y, int type) |
#else |
double __kernel_standard(x,y,type) |
double x,y; int type; |
#endif |
{ |
struct exception exc; |
#ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */ |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
#ifdef _USE_WRITE |
/* (void) fflush(_stdout_r(p)); */ |
#endif |
exc.arg1 = x; |
exc.arg2 = y; |
exc.err = 0; |
switch(type) { |
case 1: |
case 101: |
/* acos(|x|>1) */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "acos" : "acosf"; |
exc.retval = zero; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if(_LIB_VERSION == _SVID_) { |
(void) WRITE2("acos: DOMAIN error\n", 19); |
} */ |
errno = EDOM; |
} |
break; |
case 2: |
case 102: |
/* asin(|x|>1) */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "asin" : "asinf"; |
exc.retval = zero; |
if(_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if(_LIB_VERSION == _SVID_) { |
(void) WRITE2("asin: DOMAIN error\n", 19); |
} */ |
errno = EDOM; |
} |
break; |
case 3: |
case 103: |
/* atan2(+-0,+-0) */ |
exc.arg1 = y; |
exc.arg2 = x; |
exc.type = DOMAIN; |
exc.name = type < 100 ? "atan2" : "atan2f"; |
exc.retval = zero; |
if(_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if(_LIB_VERSION == _SVID_) { |
(void) WRITE2("atan2: DOMAIN error\n", 20); |
} */ |
errno = EDOM; |
} |
break; |
case 4: |
case 104: |
/* hypot(finite,finite) overflow */ |
exc.type = OVERFLOW; |
exc.name = type < 100 ? "hypot" : "hypotf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 5: |
case 105: |
/* cosh(finite) overflow */ |
exc.type = OVERFLOW; |
exc.name = type < 100 ? "cosh" : "coshf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 6: |
case 106: |
/* exp(finite) overflow */ |
exc.type = OVERFLOW; |
exc.name = type < 100 ? "exp" : "expf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 7: |
case 107: |
/* exp(finite) underflow */ |
exc.type = UNDERFLOW; |
exc.name = type < 100 ? "exp" : "expf"; |
exc.retval = zero; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 8: |
case 108: |
/* y0(0) = -inf */ |
exc.type = DOMAIN; /* should be SING for IEEE */ |
exc.name = type < 100 ? "y0" : "y0f"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("y0: DOMAIN error\n", 17); |
} */ |
errno = EDOM; |
} |
break; |
case 9: |
case 109: |
/* y0(x<0) = NaN */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "y0" : "y0f"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/*if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("y0: DOMAIN error\n", 17); |
} */ |
errno = EDOM; |
} |
break; |
case 10: |
case 110: |
/* y1(0) = -inf */ |
exc.type = DOMAIN; /* should be SING for IEEE */ |
exc.name = type < 100 ? "y1" : "y1f"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("y1: DOMAIN error\n", 17); |
} */ |
errno = EDOM; |
} |
break; |
case 11: |
case 111: |
/* y1(x<0) = NaN */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "y1" : "y1f"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("y1: DOMAIN error\n", 17); |
} */ |
errno = EDOM; |
} |
break; |
case 12: |
case 112: |
/* yn(n,0) = -inf */ |
exc.type = DOMAIN; /* should be SING for IEEE */ |
exc.name = type < 100 ? "yn" : "ynf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("yn: DOMAIN error\n", 17); |
} */ |
errno = EDOM; |
} |
break; |
case 13: |
case 113: |
/* yn(x<0) = NaN */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "yn" : "ynf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("yn: DOMAIN error\n", 17); |
} */ |
errno = EDOM; |
} |
break; |
case 14: |
case 114: |
/* lgamma(finite) overflow */ |
exc.type = OVERFLOW; |
exc.name = type < 100 ? "lgamma" : "lgammaf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 15: |
case 115: |
/* lgamma(-integer) or lgamma(0) */ |
exc.type = SING; |
exc.name = type < 100 ? "lgamma" : "lgammaf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("lgamma: SING error\n", 19); |
} */ |
errno = EDOM; |
} |
break; |
case 16: |
case 116: |
/* log(0) */ |
exc.type = SING; |
exc.name = type < 100 ? "log" : "logf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("log: SING error\n", 16); |
} */ |
errno = EDOM; |
} |
break; |
case 17: |
case 117: |
/* log(x<0) */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "log" : "logf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("log: DOMAIN error\n", 18); |
} */ |
errno = EDOM; |
} |
break; |
case 18: |
case 118: |
/* log10(0) */ |
exc.type = SING; |
exc.name = type < 100 ? "log10" : "log10f"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("log10: SING error\n", 18); |
} */ |
errno = EDOM; |
} |
break; |
case 19: |
case 119: |
/* log10(x<0) */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "log10" : "log10f"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("log10: DOMAIN error\n", 20); |
} */ |
errno = EDOM; |
} |
break; |
case 20: |
case 120: |
/* pow(0.0,0.0) */ |
/* error only if _LIB_VERSION == _SVID_ */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "pow" : "powf"; |
exc.retval = zero; |
if (_LIB_VERSION != _SVID_) exc.retval = 1.0; |
else if (!matherr(&exc)) { |
/* (void) WRITE2("pow(0,0): DOMAIN error\n", 23); */ |
errno = EDOM; |
} |
break; |
case 21: |
case 121: |
/* pow(x,y) overflow */ |
exc.type = OVERFLOW; |
exc.name = type < 100 ? "pow" : "powf"; |
if (_LIB_VERSION == _SVID_) { |
exc.retval = HUGE; |
y *= 0.5; |
if(x<zero&&rint(y)!=y) exc.retval = -HUGE; |
} else { |
exc.retval = HUGE_VAL; |
y *= 0.5; |
if(x<zero&&rint(y)!=y) exc.retval = -HUGE_VAL; |
} |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 22: |
case 122: |
/* pow(x,y) underflow */ |
exc.type = UNDERFLOW; |
exc.name = type < 100 ? "pow" : "powf"; |
exc.retval = zero; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 23: |
case 123: |
/* 0**neg */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "pow" : "powf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = zero; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("pow(0,neg): DOMAIN error\n", 25); |
} */ |
errno = EDOM; |
} |
break; |
case 24: |
case 124: |
/* neg**non-integral */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "pow" : "powf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = zero; |
else |
exc.retval = zero/zero; /* X/Open allow NaN */ |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("neg**non-integral: DOMAIN error\n", 32); |
} */ |
errno = EDOM; |
} |
break; |
case 25: |
case 125: |
/* sinh(finite) overflow */ |
exc.type = OVERFLOW; |
exc.name = type < 100 ? "sinh" : "sinhf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = ( (x>zero) ? HUGE : -HUGE); |
else |
exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL); |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 26: |
case 126: |
/* sqrt(x<0) */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "sqrt" : "sqrtf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = zero; |
else |
exc.retval = zero/zero; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("sqrt: DOMAIN error\n", 19); |
} */ |
errno = EDOM; |
} |
break; |
case 27: |
case 127: |
/* fmod(x,0) */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "fmod" : "fmodf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = x; |
else |
exc.retval = zero/zero; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("fmod: DOMAIN error\n", 20); |
} */ |
errno = EDOM; |
} |
break; |
case 28: |
case 128: |
/* remainder(x,0) */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "remainder" : "remainderf"; |
exc.retval = zero/zero; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("remainder: DOMAIN error\n", 24); |
} */ |
errno = EDOM; |
} |
break; |
case 29: |
case 129: |
/* acosh(x<1) */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "acosh" : "acoshf"; |
exc.retval = zero/zero; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("acosh: DOMAIN error\n", 20); |
} */ |
errno = EDOM; |
} |
break; |
case 30: |
case 130: |
/* atanh(|x|>1) */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "atanh" : "atanhf"; |
exc.retval = zero/zero; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("atanh: DOMAIN error\n", 20); |
} */ |
errno = EDOM; |
} |
break; |
case 31: |
case 131: |
/* atanh(|x|=1) */ |
exc.type = SING; |
exc.name = type < 100 ? "atanh" : "atanhf"; |
exc.retval = x/zero; /* sign(x)*inf */ |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("atanh: SING error\n", 18); |
} */ |
errno = EDOM; |
} |
break; |
case 32: |
case 132: |
/* scalb overflow; SVID also returns +-HUGE_VAL */ |
exc.type = OVERFLOW; |
exc.name = type < 100 ? "scalb" : "scalbf"; |
exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 33: |
case 133: |
/* scalb underflow */ |
exc.type = UNDERFLOW; |
exc.name = type < 100 ? "scalb" : "scalbf"; |
exc.retval = copysign(zero,x); |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 34: |
case 134: |
/* j0(|x|>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = type < 100 ? "j0" : "j0f"; |
exc.retval = zero; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2(exc.name, 2); |
(void) WRITE2(": TLOSS error\n", 14); |
} */ |
errno = ERANGE; |
} |
break; |
case 35: |
case 135: |
/* y0(x>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = type < 100 ? "y0" : "y0f"; |
exc.retval = zero; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2(exc.name, 2); |
(void) WRITE2(": TLOSS error\n", 14); |
} */ |
errno = ERANGE; |
} |
break; |
case 36: |
case 136: |
/* j1(|x|>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = type < 100 ? "j1" : "j1f"; |
exc.retval = zero; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2(exc.name, 2); |
(void) WRITE2(": TLOSS error\n", 14); |
} */ |
errno = ERANGE; |
} |
break; |
case 37: |
case 137: |
/* y1(x>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = type < 100 ? "y1" : "y1f"; |
exc.retval = zero; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2(exc.name, 2); |
(void) WRITE2(": TLOSS error\n", 14); |
} */ |
errno = ERANGE; |
} |
break; |
case 38: |
case 138: |
/* jn(|x|>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = type < 100 ? "jn" : "jnf"; |
exc.retval = zero; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2(exc.name, 2); |
(void) WRITE2(": TLOSS error\n", 14); |
} */ |
errno = ERANGE; |
} |
break; |
case 39: |
case 139: |
/* yn(x>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = type < 100 ? "yn" : "ynf"; |
exc.retval = zero; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2(exc.name, 2); |
(void) WRITE2(": TLOSS error\n", 14); |
} */ |
errno = ERANGE; |
} |
break; |
case 40: |
case 140: |
/* gamma(finite) overflow */ |
exc.type = OVERFLOW; |
exc.name = type < 100 ? "gamma" : "gammaf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
break; |
case 41: |
case 141: |
/* gamma(-integer) or gamma(0) */ |
exc.type = SING; |
exc.name = type < 100 ? "gamma" : "gammaf"; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
/* if (_LIB_VERSION == _SVID_) { |
(void) WRITE2("gamma: SING error\n", 18); |
} */ |
errno = EDOM; |
} |
break; |
case 42: |
case 142: |
/* pow(NaN,0.0) */ |
/* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ |
exc.type = DOMAIN; |
exc.name = type < 100 ? "pow" : "powf"; |
exc.retval = x; |
if (_LIB_VERSION == _IEEE_ || |
_LIB_VERSION == _POSIX_) exc.retval = 1.0; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
break; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
/contrib/sdk/sources/libc/math/k_tan.c |
---|
0,0 → 1,132 |
/* @(#)k_tan.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* __kernel_tan( x, y, k ) |
* kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854 |
* Input x is assumed to be bounded by ~pi/4 in magnitude. |
* Input y is the tail of x. |
* Input k indicates whether tan (if k=1) or |
* -1/tan (if k= -1) is returned. |
* |
* Algorithm |
* 1. Since tan(-x) = -tan(x), we need only to consider positive x. |
* 2. if x < 2^-28 (hx<0x3e300000 0), return x with inexact if x!=0. |
* 3. tan(x) is approximated by a odd polynomial of degree 27 on |
* [0,0.67434] |
* 3 27 |
* tan(x) ~ x + T1*x + ... + T13*x |
* where |
* |
* |tan(x) 2 4 26 | -59.2 |
* |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2 |
* | x | |
* |
* Note: tan(x+y) = tan(x) + tan'(x)*y |
* ~ tan(x) + (1+x*x)*y |
* Therefore, for better accuracy in computing tan(x+y), let |
* 3 2 2 2 2 |
* r = x *(T2+x *(T3+x *(...+x *(T12+x *T13)))) |
* then |
* 3 2 |
* tan(x+y) = x + (T1*x + (x *(r+y)+y)) |
* |
* 4. For x in [0.67434,pi/4], let y = pi/4 - x, then |
* tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y)) |
* = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y))) |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
pio4 = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */ |
pio4lo= 3.06161699786838301793e-17, /* 0x3C81A626, 0x33145C07 */ |
T[] = { |
3.33333333333334091986e-01, /* 0x3FD55555, 0x55555563 */ |
1.33333333333201242699e-01, /* 0x3FC11111, 0x1110FE7A */ |
5.39682539762260521377e-02, /* 0x3FABA1BA, 0x1BB341FE */ |
2.18694882948595424599e-02, /* 0x3F9664F4, 0x8406D637 */ |
8.86323982359930005737e-03, /* 0x3F8226E3, 0xE96E8493 */ |
3.59207910759131235356e-03, /* 0x3F6D6D22, 0xC9560328 */ |
1.45620945432529025516e-03, /* 0x3F57DBC8, 0xFEE08315 */ |
5.88041240820264096874e-04, /* 0x3F4344D8, 0xF2F26501 */ |
2.46463134818469906812e-04, /* 0x3F3026F7, 0x1A8D1068 */ |
7.81794442939557092300e-05, /* 0x3F147E88, 0xA03792A6 */ |
7.14072491382608190305e-05, /* 0x3F12B80F, 0x32F0A7E9 */ |
-1.85586374855275456654e-05, /* 0xBEF375CB, 0xDB605373 */ |
2.59073051863633712884e-05, /* 0x3EFB2A70, 0x74BF7AD4 */ |
}; |
#ifdef __STDC__ |
double __kernel_tan(double x, double y, int iy) |
#else |
double __kernel_tan(x, y, iy) |
double x,y; int iy; |
#endif |
{ |
double z,r,v,w,s; |
__int32_t ix,hx; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; /* high word of |x| */ |
if(ix<0x3e300000) /* x < 2**-28 */ |
{if((int)x==0) { /* generate inexact */ |
__uint32_t low; |
GET_LOW_WORD(low,x); |
if(((ix|low)|(iy+1))==0) return one/fabs(x); |
else return (iy==1)? x: -one/x; |
} |
} |
if(ix>=0x3FE59428) { /* |x|>=0.6744 */ |
if(hx<0) {x = -x; y = -y;} |
z = pio4-x; |
w = pio4lo-y; |
x = z+w; y = 0.0; |
} |
z = x*x; |
w = z*z; |
/* Break x^5*(T[1]+x^2*T[2]+...) into |
* x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + |
* x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) |
*/ |
r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11])))); |
v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12]))))); |
s = z*x; |
r = y + z*(s*(r+v)+y); |
r += T[0]*s; |
w = x+r; |
if(ix>=0x3FE59428) { |
v = (double)iy; |
return (double)(1-((hx>>30)&2))*(v-2.0*(x-(w*w/(w+v)-r))); |
} |
if(iy==1) return w; |
else { /* if allow error up to 2 ulp, |
simply return -1.0/(x+r) here */ |
/* compute -1.0/(x+r) accurately */ |
double a,t; |
z = w; |
SET_LOW_WORD(z,0); |
v = r-(z - x); /* z+v = r+x */ |
t = a = -1.0/w; /* a = -1.0/w */ |
SET_LOW_WORD(t,0); |
s = 1.0+t*z; |
return t+a*(s+t*v); |
} |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/kf_cos.c |
---|
0,0 → 1,59 |
/* kf_cos.c -- float version of k_cos.c |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0000000000e+00, /* 0x3f800000 */ |
C1 = 4.1666667908e-02, /* 0x3d2aaaab */ |
C2 = -1.3888889225e-03, /* 0xbab60b61 */ |
C3 = 2.4801587642e-05, /* 0x37d00d01 */ |
C4 = -2.7557314297e-07, /* 0xb493f27c */ |
C5 = 2.0875723372e-09, /* 0x310f74f6 */ |
C6 = -1.1359647598e-11; /* 0xad47d74e */ |
#ifdef __STDC__ |
float __kernel_cosf(float x, float y) |
#else |
float __kernel_cosf(x, y) |
float x,y; |
#endif |
{ |
float a,hz,z,r,qx; |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; /* ix = |x|'s high word*/ |
if(ix<0x32000000) { /* if x < 2**27 */ |
if(((int)x)==0) return one; /* generate inexact */ |
} |
z = x*x; |
r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6))))); |
if(ix < 0x3e99999a) /* if |x| < 0.3 */ |
return one - ((float)0.5*z - (z*r - x*y)); |
else { |
if(ix > 0x3f480000) { /* x > 0.78125 */ |
qx = (float)0.28125; |
} else { |
SET_FLOAT_WORD(qx,ix-0x01000000); /* x/4 */ |
} |
hz = (float)0.5*z-qx; |
a = one-qx; |
return a - (hz - (z*r-x*y)); |
} |
} |
/contrib/sdk/sources/libc/math/kf_rem_pio2.c |
---|
0,0 → 1,208 |
/* kf_rem_pio2.c -- float version of k_rem_pio2.c |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
/* In the float version, the input parameter x contains 8 bit |
integers, not 24 bit integers. 113 bit precision is not supported. */ |
#ifdef __STDC__ |
static const int init_jk[] = {4,7,9}; /* initial value for jk */ |
#else |
static int init_jk[] = {4,7,9}; |
#endif |
#ifdef __STDC__ |
static const float PIo2[] = { |
#else |
static float PIo2[] = { |
#endif |
1.5703125000e+00, /* 0x3fc90000 */ |
4.5776367188e-04, /* 0x39f00000 */ |
2.5987625122e-05, /* 0x37da0000 */ |
7.5437128544e-08, /* 0x33a20000 */ |
6.0026650317e-11, /* 0x2e840000 */ |
7.3896444519e-13, /* 0x2b500000 */ |
5.3845816694e-15, /* 0x27c20000 */ |
5.6378512969e-18, /* 0x22d00000 */ |
8.3009228831e-20, /* 0x1fc40000 */ |
3.2756352257e-22, /* 0x1bc60000 */ |
6.3331015649e-25, /* 0x17440000 */ |
}; |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
zero = 0.0, |
one = 1.0, |
two8 = 2.5600000000e+02, /* 0x43800000 */ |
twon8 = 3.9062500000e-03; /* 0x3b800000 */ |
#ifdef __STDC__ |
int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const __int32_t *ipio2) |
#else |
int __kernel_rem_pio2f(x,y,e0,nx,prec,ipio2) |
float x[], y[]; int e0,nx,prec; __int32_t ipio2[]; |
#endif |
{ |
__int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; |
float z,fw,f[20],fq[20],q[20]; |
/* initialize jk*/ |
jk = init_jk[prec]; |
jp = jk; |
/* determine jx,jv,q0, note that 3>q0 */ |
jx = nx-1; |
jv = (e0-3)/8; if(jv<0) jv=0; |
q0 = e0-8*(jv+1); |
/* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ |
j = jv-jx; m = jx+jk; |
for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (float) ipio2[j]; |
/* compute q[0],q[1],...q[jk] */ |
for (i=0;i<=jk;i++) { |
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw; |
} |
jz = jk; |
recompute: |
/* distill q[] into iq[] reversingly */ |
for(i=0,j=jz,z=q[jz];j>0;i++,j--) { |
fw = (float)((__int32_t)(twon8* z)); |
iq[i] = (__int32_t)(z-two8*fw); |
z = q[j-1]+fw; |
} |
/* compute n */ |
z = scalbnf(z,(int)q0); /* actual value of z */ |
z -= (float)8.0*floorf(z*(float)0.125); /* trim off integer >= 8 */ |
n = (__int32_t) z; |
z -= (float)n; |
ih = 0; |
if(q0>0) { /* need iq[jz-1] to determine n */ |
i = (iq[jz-1]>>(8-q0)); n += i; |
iq[jz-1] -= i<<(8-q0); |
ih = iq[jz-1]>>(7-q0); |
} |
else if(q0==0) ih = iq[jz-1]>>8; |
else if(z>=(float)0.5) ih=2; |
if(ih>0) { /* q > 0.5 */ |
n += 1; carry = 0; |
for(i=0;i<jz ;i++) { /* compute 1-q */ |
j = iq[i]; |
if(carry==0) { |
if(j!=0) { |
carry = 1; iq[i] = 0x100- j; |
} |
} else iq[i] = 0xff - j; |
} |
if(q0>0) { /* rare case: chance is 1 in 12 */ |
switch(q0) { |
case 1: |
iq[jz-1] &= 0x7f; break; |
case 2: |
iq[jz-1] &= 0x3f; break; |
} |
} |
if(ih==2) { |
z = one - z; |
if(carry!=0) z -= scalbnf(one,(int)q0); |
} |
} |
/* check if recomputation is needed */ |
if(z==zero) { |
j = 0; |
for (i=jz-1;i>=jk;i--) j |= iq[i]; |
if(j==0) { /* need recomputation */ |
for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */ |
for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */ |
f[jx+i] = (float) ipio2[jv+i]; |
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; |
q[i] = fw; |
} |
jz += k; |
goto recompute; |
} |
} |
/* chop off zero terms */ |
if(z==(float)0.0) { |
jz -= 1; q0 -= 8; |
while(iq[jz]==0) { jz--; q0-=8;} |
} else { /* break z into 8-bit if necessary */ |
z = scalbnf(z,-(int)q0); |
if(z>=two8) { |
fw = (float)((__int32_t)(twon8*z)); |
iq[jz] = (__int32_t)(z-two8*fw); |
jz += 1; q0 += 8; |
iq[jz] = (__int32_t) fw; |
} else iq[jz] = (__int32_t) z ; |
} |
/* convert integer "bit" chunk to floating-point value */ |
fw = scalbnf(one,(int)q0); |
for(i=jz;i>=0;i--) { |
q[i] = fw*(float)iq[i]; fw*=twon8; |
} |
/* compute PIo2[0,...,jp]*q[jz,...,0] */ |
for(i=jz;i>=0;i--) { |
for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k]; |
fq[jz-i] = fw; |
} |
/* compress fq[] into y[] */ |
switch(prec) { |
case 0: |
fw = 0.0; |
for (i=jz;i>=0;i--) fw += fq[i]; |
y[0] = (ih==0)? fw: -fw; |
break; |
case 1: |
case 2: |
fw = 0.0; |
for (i=jz;i>=0;i--) fw += fq[i]; |
y[0] = (ih==0)? fw: -fw; |
fw = fq[0]-fw; |
for (i=1;i<=jz;i++) fw += fq[i]; |
y[1] = (ih==0)? fw: -fw; |
break; |
case 3: /* painful */ |
for (i=jz;i>0;i--) { |
fw = fq[i-1]+fq[i]; |
fq[i] += fq[i-1]-fw; |
fq[i-1] = fw; |
} |
for (i=jz;i>1;i--) { |
fw = fq[i-1]+fq[i]; |
fq[i] += fq[i-1]-fw; |
fq[i-1] = fw; |
} |
for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; |
if(ih==0) { |
y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; |
} else { |
y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; |
} |
} |
return n&7; |
} |
/contrib/sdk/sources/libc/math/kf_sin.c |
---|
0,0 → 1,49 |
/* kf_sin.c -- float version of k_sin.c |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
half = 5.0000000000e-01,/* 0x3f000000 */ |
S1 = -1.6666667163e-01, /* 0xbe2aaaab */ |
S2 = 8.3333337680e-03, /* 0x3c088889 */ |
S3 = -1.9841270114e-04, /* 0xb9500d01 */ |
S4 = 2.7557314297e-06, /* 0x3638ef1b */ |
S5 = -2.5050759689e-08, /* 0xb2d72f34 */ |
S6 = 1.5896910177e-10; /* 0x2f2ec9d3 */ |
#ifdef __STDC__ |
float __kernel_sinf(float x, float y, int iy) |
#else |
float __kernel_sinf(x, y, iy) |
float x,y; int iy; /* iy=0 if y is zero */ |
#endif |
{ |
float z,r,v; |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; /* high word of x */ |
if(ix<0x32000000) /* |x| < 2**-27 */ |
{if((int)x==0) return x;} /* generate inexact */ |
z = x*x; |
v = z*x; |
r = S2+z*(S3+z*(S4+z*(S5+z*S6))); |
if(iy==0) return x+v*(S1+z*r); |
else return x-((z*(half*y-v*r)-y)-v*S1); |
} |
/contrib/sdk/sources/libc/math/kf_tan.c |
---|
0,0 → 1,96 |
/* kf_tan.c -- float version of k_tan.c |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0000000000e+00, /* 0x3f800000 */ |
pio4 = 7.8539812565e-01, /* 0x3f490fda */ |
pio4lo= 3.7748947079e-08, /* 0x33222168 */ |
T[] = { |
3.3333334327e-01, /* 0x3eaaaaab */ |
1.3333334029e-01, /* 0x3e088889 */ |
5.3968254477e-02, /* 0x3d5d0dd1 */ |
2.1869488060e-02, /* 0x3cb327a4 */ |
8.8632395491e-03, /* 0x3c11371f */ |
3.5920790397e-03, /* 0x3b6b6916 */ |
1.4562094584e-03, /* 0x3abede48 */ |
5.8804126456e-04, /* 0x3a1a26c8 */ |
2.4646313977e-04, /* 0x398137b9 */ |
7.8179444245e-05, /* 0x38a3f445 */ |
7.1407252108e-05, /* 0x3895c07a */ |
-1.8558637748e-05, /* 0xb79bae5f */ |
2.5907305826e-05, /* 0x37d95384 */ |
}; |
#ifdef __STDC__ |
float __kernel_tanf(float x, float y, int iy) |
#else |
float __kernel_tanf(x, y, iy) |
float x,y; int iy; |
#endif |
{ |
float z,r,v,w,s; |
__int32_t ix,hx; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; /* high word of |x| */ |
if(ix<0x31800000) /* x < 2**-28 */ |
{if((int)x==0) { /* generate inexact */ |
if((ix|(iy+1))==0) return one/fabsf(x); |
else return (iy==1)? x: -one/x; |
} |
} |
if(ix>=0x3f2ca140) { /* |x|>=0.6744 */ |
if(hx<0) {x = -x; y = -y;} |
z = pio4-x; |
w = pio4lo-y; |
x = z+w; y = 0.0; |
} |
z = x*x; |
w = z*z; |
/* Break x^5*(T[1]+x^2*T[2]+...) into |
* x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + |
* x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) |
*/ |
r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11])))); |
v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12]))))); |
s = z*x; |
r = y + z*(s*(r+v)+y); |
r += T[0]*s; |
w = x+r; |
if(ix>=0x3f2ca140) { |
v = (float)iy; |
return (float)(1-((hx>>30)&2))*(v-(float)2.0*(x-(w*w/(w+v)-r))); |
} |
if(iy==1) return w; |
else { /* if allow error up to 2 ulp, |
simply return -1.0/(x+r) here */ |
/* compute -1.0/(x+r) accurately */ |
float a,t; |
__int32_t i; |
z = w; |
GET_FLOAT_WORD(i,z); |
SET_FLOAT_WORD(z,i&0xfffff000); |
v = r-(z - x); /* z+v = r+x */ |
t = a = -(float)1.0/w; /* a = -1.0/w */ |
GET_FLOAT_WORD(i,t); |
SET_FLOAT_WORD(t,i&0xfffff000); |
s = (float)1.0+t*z; |
return t+a*(s+t*v); |
} |
} |
/contrib/sdk/sources/libc/math/local.h |
---|
0,0 → 1,0 |
/* placeholder for future usage. */ |
/contrib/sdk/sources/libc/math/s_asinh.c |
---|
0,0 → 1,107 |
/* @(#)s_asinh.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<asinh>>, <<asinhf>>---inverse hyperbolic sine |
INDEX |
asinh |
INDEX |
asinhf |
ANSI_SYNOPSIS |
#include <math.h> |
double asinh(double <[x]>); |
float asinhf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double asinh(<[x]>) |
double <[x]>; |
float asinhf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<asinh>> calculates the inverse hyperbolic sine of <[x]>. |
<<asinh>> is defined as |
@ifnottex |
. sgn(<[x]>) * log(abs(<[x]>) + sqrt(1+<[x]>*<[x]>)) |
@end ifnottex |
@tex |
$$sign(x) \times ln\Bigl(|x| + \sqrt{1+x^2}\Bigr)$$ |
@end tex |
<<asinhf>> is identical, other than taking and returning floats. |
RETURNS |
<<asinh>> and <<asinhf>> return the calculated value. |
PORTABILITY |
Neither <<asinh>> nor <<asinhf>> are ANSI C. |
*/ |
/* asinh(x) |
* Method : |
* Based on |
* asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ] |
* we have |
* asinh(x) := x if 1+x*x=1, |
* := sign(x)*(log(x)+ln2)) for large |x|, else |
* := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else |
* := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2))) |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ |
huge= 1.00000000000000000000e+300; |
#ifdef __STDC__ |
double asinh(double x) |
#else |
double asinh(x) |
double x; |
#endif |
{ |
double t,w; |
__int32_t hx,ix; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix>=0x7ff00000) return x+x; /* x is inf or NaN */ |
if(ix< 0x3e300000) { /* |x|<2**-28 */ |
if(huge+x>one) return x; /* return x inexact except 0 */ |
} |
if(ix>0x41b00000) { /* |x| > 2**28 */ |
w = __ieee754_log(fabs(x))+ln2; |
} else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */ |
t = fabs(x); |
w = __ieee754_log(2.0*t+one/(__ieee754_sqrt(x*x+one)+t)); |
} else { /* 2.0 > |x| > 2**-28 */ |
t = x*x; |
w =log1p(fabs(x)+t/(one+__ieee754_sqrt(one+t))); |
} |
if(hx>0) return w; else return -w; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_atan.c |
---|
0,0 → 1,181 |
/* @(#)s_atan.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* |
FUNCTION |
<<atan>>, <<atanf>>---arc tangent |
INDEX |
atan |
INDEX |
atanf |
ANSI_SYNOPSIS |
#include <math.h> |
double atan(double <[x]>); |
float atanf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double atan(<[x]>); |
double <[x]>; |
float atanf(<[x]>); |
float <[x]>; |
DESCRIPTION |
<<atan>> computes the inverse tangent (arc tangent) of the input value. |
<<atanf>> is identical to <<atan>>, save that it operates on <<floats>>. |
RETURNS |
@ifnottex |
<<atan>> returns a value in radians, in the range of -pi/2 to pi/2. |
@end ifnottex |
@tex |
<<atan>> returns a value in radians, in the range of $-\pi/2$ to $\pi/2$. |
@end tex |
PORTABILITY |
<<atan>> is ANSI C. <<atanf>> is an extension. |
*/ |
/* atan(x) |
* Method |
* 1. Reduce x to positive by atan(x) = -atan(-x). |
* 2. According to the integer k=4t+0.25 chopped, t=x, the argument |
* is further reduced to one of the following intervals and the |
* arctangent of t is evaluated by the corresponding formula: |
* |
* [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...) |
* [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) ) |
* [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) ) |
* [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) ) |
* [39/16,INF] atan(x) = atan(INF) + atan( -1/t ) |
* |
* Constants: |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double atanhi[] = { |
#else |
static double atanhi[] = { |
#endif |
4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */ |
7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */ |
9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */ |
1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */ |
}; |
#ifdef __STDC__ |
static const double atanlo[] = { |
#else |
static double atanlo[] = { |
#endif |
2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */ |
3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */ |
1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */ |
6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */ |
}; |
#ifdef __STDC__ |
static const double aT[] = { |
#else |
static double aT[] = { |
#endif |
3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */ |
-1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */ |
1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */ |
-1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */ |
9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */ |
-7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */ |
6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */ |
-5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */ |
4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */ |
-3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */ |
1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */ |
}; |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
one = 1.0, |
huge = 1.0e300; |
#ifdef __STDC__ |
double atan(double x) |
#else |
double atan(x) |
double x; |
#endif |
{ |
double w,s1,s2,z; |
__int32_t ix,hx,id; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix>=0x44100000) { /* if |x| >= 2^66 */ |
__uint32_t low; |
GET_LOW_WORD(low,x); |
if(ix>0x7ff00000|| |
(ix==0x7ff00000&&(low!=0))) |
return x+x; /* NaN */ |
if(hx>0) return atanhi[3]+atanlo[3]; |
else return -atanhi[3]-atanlo[3]; |
} if (ix < 0x3fdc0000) { /* |x| < 0.4375 */ |
if (ix < 0x3e200000) { /* |x| < 2^-29 */ |
if(huge+x>one) return x; /* raise inexact */ |
} |
id = -1; |
} else { |
x = fabs(x); |
if (ix < 0x3ff30000) { /* |x| < 1.1875 */ |
if (ix < 0x3fe60000) { /* 7/16 <=|x|<11/16 */ |
id = 0; x = (2.0*x-one)/(2.0+x); |
} else { /* 11/16<=|x|< 19/16 */ |
id = 1; x = (x-one)/(x+one); |
} |
} else { |
if (ix < 0x40038000) { /* |x| < 2.4375 */ |
id = 2; x = (x-1.5)/(one+1.5*x); |
} else { /* 2.4375 <= |x| < 2^66 */ |
id = 3; x = -1.0/x; |
} |
}} |
/* end of argument reduction */ |
z = x*x; |
w = z*z; |
/* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ |
s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10]))))); |
s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9])))); |
if (id<0) return x - x*(s1+s2); |
else { |
z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x); |
return (hx<0)? -z:z; |
} |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_cbrt.c |
---|
0,0 → 1,123 |
/* @(#)s_cbrt.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* |
FUNCTION |
<<cbrt>>, <<cbrtf>>---cube root |
INDEX |
cbrt |
INDEX |
cbrtf |
ANSI_SYNOPSIS |
#include <math.h> |
double cbrt(double <[x]>); |
float cbrtf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double cbrt(<[x]>); |
float cbrtf(<[x]>); |
DESCRIPTION |
<<cbrt>> computes the cube root of the argument. |
RETURNS |
The cube root is returned. |
PORTABILITY |
<<cbrt>> is in System V release 4. <<cbrtf>> is an extension. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
/* cbrt(x) |
* Return cube root of x |
*/ |
#ifdef __STDC__ |
static const __uint32_t |
#else |
static __uint32_t |
#endif |
B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */ |
B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */ |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */ |
D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */ |
E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */ |
F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */ |
G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */ |
#ifdef __STDC__ |
double cbrt(double x) |
#else |
double cbrt(x) |
double x; |
#endif |
{ |
__int32_t hx; |
double r,s,t=0.0,w; |
__uint32_t sign; |
__uint32_t high,low; |
GET_HIGH_WORD(hx,x); |
sign=hx&0x80000000; /* sign= sign(x) */ |
hx ^=sign; |
if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */ |
GET_LOW_WORD(low,x); |
if((hx|low)==0) |
return(x); /* cbrt(0) is itself */ |
SET_HIGH_WORD(x,hx); /* x <- |x| */ |
/* rough cbrt to 5 bits */ |
if(hx<0x00100000) /* subnormal number */ |
{SET_HIGH_WORD(t,0x43500000); /* set t= 2**54 */ |
t*=x; GET_HIGH_WORD(high,t); SET_HIGH_WORD(t,high/3+B2); |
} |
else |
SET_HIGH_WORD(t,hx/3+B1); |
/* new cbrt to 23 bits, may be implemented in single precision */ |
r=t*t/x; |
s=C+r*t; |
t*=G+F/(s+E+D/s); |
/* chopped to 20 bits and make it larger than cbrt(x) */ |
GET_HIGH_WORD(high,t); |
INSERT_WORDS(t,high+0x00000001,0); |
/* one step newton iteration to 53 bits with error less than 0.667 ulps */ |
s=t*t; /* t*t is exact */ |
r=x/s; |
w=t+t; |
r=(r-t)/(w+r); /* r-s is exact */ |
t=t+t*r; |
/* retore the sign bit */ |
GET_HIGH_WORD(high,t); |
SET_HIGH_WORD(t,high|sign); |
return(t); |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_ceil.c |
---|
0,0 → 1,80 |
/* @(#)s_ceil.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* ceil(x) |
* Return x rounded toward -inf to integral value |
* Method: |
* Bit twiddling. |
* Exception: |
* Inexact flag raised if x not equal to ceil(x). |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double huge = 1.0e300; |
#else |
static double huge = 1.0e300; |
#endif |
#ifdef __STDC__ |
double ceil(double x) |
#else |
double ceil(x) |
double x; |
#endif |
{ |
__int32_t i0,i1,j0; |
__uint32_t i,j; |
EXTRACT_WORDS(i0,i1,x); |
j0 = ((i0>>20)&0x7ff)-0x3ff; |
if(j0<20) { |
if(j0<0) { /* raise inexact if x != 0 */ |
if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */ |
if(i0<0) {i0=0x80000000;i1=0;} |
else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;} |
} |
} else { |
i = (0x000fffff)>>j0; |
if(((i0&i)|i1)==0) return x; /* x is integral */ |
if(huge+x>0.0) { /* raise inexact flag */ |
if(i0>0) i0 += (0x00100000)>>j0; |
i0 &= (~i); i1=0; |
} |
} |
} else if (j0>51) { |
if(j0==0x400) return x+x; /* inf or NaN */ |
else return x; /* x is integral */ |
} else { |
i = ((__uint32_t)(0xffffffff))>>(j0-20); |
if((i1&i)==0) return x; /* x is integral */ |
if(huge+x>0.0) { /* raise inexact flag */ |
if(i0>0) { |
if(j0==20) i0+=1; |
else { |
j = i1 + (1<<(52-j0)); |
if(j<i1) i0+=1; /* got a carry */ |
i1 = j; |
} |
} |
i1 &= (~i); |
} |
} |
INSERT_WORDS(x,i0,i1); |
return x; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_copysign.c |
---|
0,0 → 1,82 |
/* @(#)s_copysign.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<copysign>>, <<copysignf>>---sign of <[y]>, magnitude of <[x]> |
INDEX |
copysign |
INDEX |
copysignf |
ANSI_SYNOPSIS |
#include <math.h> |
double copysign (double <[x]>, double <[y]>); |
float copysignf (float <[x]>, float <[y]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double copysign (<[x]>, <[y]>) |
double <[x]>; |
double <[y]>; |
float copysignf (<[x]>, <[y]>) |
float <[x]>; |
float <[y]>; |
DESCRIPTION |
<<copysign>> constructs a number with the magnitude (absolute value) |
of its first argument, <[x]>, and the sign of its second argument, |
<[y]>. |
<<copysignf>> does the same thing; the two functions differ only in |
the type of their arguments and result. |
RETURNS |
<<copysign>> returns a <<double>> with the magnitude of |
<[x]> and the sign of <[y]>. |
<<copysignf>> returns a <<float>> with the magnitude of |
<[x]> and the sign of <[y]>. |
PORTABILITY |
<<copysign>> is not required by either ANSI C or the System V Interface |
Definition (Issue 2). |
*/ |
/* |
* copysign(double x, double y) |
* copysign(x,y) returns a value with the magnitude of x and |
* with the sign bit of y. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double copysign(double x, double y) |
#else |
double copysign(x,y) |
double x,y; |
#endif |
{ |
__uint32_t hx,hy; |
GET_HIGH_WORD(hx,x); |
GET_HIGH_WORD(hy,y); |
SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000)); |
return x; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_cos.c |
---|
0,0 → 1,82 |
/* @(#)s_cos.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* cos(x) |
* Return cosine function of x. |
* |
* kernel function: |
* __kernel_sin ... sine function on [-pi/4,pi/4] |
* __kernel_cos ... cosine function on [-pi/4,pi/4] |
* __ieee754_rem_pio2 ... argument reduction routine |
* |
* Method. |
* Let S,C and T denote the sin, cos and tan respectively on |
* [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 |
* in [-pi/4 , +pi/4], and let n = k mod 4. |
* We have |
* |
* n sin(x) cos(x) tan(x) |
* ---------------------------------------------------------- |
* 0 S C T |
* 1 C -S -1/T |
* 2 -S -C T |
* 3 -C S -1/T |
* ---------------------------------------------------------- |
* |
* Special cases: |
* Let trig be any of sin, cos, or tan. |
* trig(+-INF) is NaN, with signals; |
* trig(NaN) is that NaN; |
* |
* Accuracy: |
* TRIG(x) returns trig(x) nearly rounded |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double cos(double x) |
#else |
double cos(x) |
double x; |
#endif |
{ |
double y[2],z=0.0; |
__int32_t n,ix; |
/* High word of x. */ |
GET_HIGH_WORD(ix,x); |
/* |x| ~< pi/4 */ |
ix &= 0x7fffffff; |
if(ix <= 0x3fe921fb) return __kernel_cos(x,z); |
/* cos(Inf or NaN) is NaN */ |
else if (ix>=0x7ff00000) return x-x; |
/* argument reduction needed */ |
else { |
n = __ieee754_rem_pio2(x,y); |
switch(n&3) { |
case 0: return __kernel_cos(y[0],y[1]); |
case 1: return -__kernel_sin(y[0],y[1],1); |
case 2: return -__kernel_cos(y[0],y[1]); |
default: |
return __kernel_sin(y[0],y[1],1); |
} |
} |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_erf.c |
---|
0,0 → 1,373 |
/* @(#)s_erf.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<erf>>, <<erff>>, <<erfc>>, <<erfcf>>---error function |
INDEX |
erf |
INDEX |
erff |
INDEX |
erfc |
INDEX |
erfcf |
ANSI_SYNOPSIS |
#include <math.h> |
double erf(double <[x]>); |
float erff(float <[x]>); |
double erfc(double <[x]>); |
float erfcf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double erf(<[x]>) |
double <[x]>; |
float erff(<[x]>) |
float <[x]>; |
double erfc(<[x]>) |
double <[x]>; |
float erfcf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<erf>> calculates an approximation to the ``error function'', |
which estimates the probability that an observation will fall within |
<[x]> standard deviations of the mean (assuming a normal |
distribution). |
@tex |
The error function is defined as |
$${2\over\sqrt\pi}\times\int_0^x e^{-t^2}dt$$ |
@end tex |
<<erfc>> calculates the complementary probability; that is, |
<<erfc(<[x]>)>> is <<1 - erf(<[x]>)>>. <<erfc>> is computed directly, |
so that you can use it to avoid the loss of precision that would |
result from subtracting large probabilities (on large <[x]>) from 1. |
<<erff>> and <<erfcf>> differ from <<erf>> and <<erfc>> only in the |
argument and result types. |
RETURNS |
For positive arguments, <<erf>> and all its variants return a |
probability---a number between 0 and 1. |
PORTABILITY |
None of the variants of <<erf>> are ANSI C. |
*/ |
/* double erf(double x) |
* double erfc(double x) |
* x |
* 2 |\ |
* erf(x) = --------- | exp(-t*t)dt |
* sqrt(pi) \| |
* 0 |
* |
* erfc(x) = 1-erf(x) |
* Note that |
* erf(-x) = -erf(x) |
* erfc(-x) = 2 - erfc(x) |
* |
* Method: |
* 1. For |x| in [0, 0.84375] |
* erf(x) = x + x*R(x^2) |
* erfc(x) = 1 - erf(x) if x in [-.84375,0.25] |
* = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375] |
* where R = P/Q where P is an odd poly of degree 8 and |
* Q is an odd poly of degree 10. |
* -57.90 |
* | R - (erf(x)-x)/x | <= 2 |
* |
* |
* Remark. The formula is derived by noting |
* erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) |
* and that |
* 2/sqrt(pi) = 1.128379167095512573896158903121545171688 |
* is close to one. The interval is chosen because the fix |
* point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is |
* near 0.6174), and by some experiment, 0.84375 is chosen to |
* guarantee the error is less than one ulp for erf. |
* |
* 2. For |x| in [0.84375,1.25], let s = |x| - 1, and |
* c = 0.84506291151 rounded to single (24 bits) |
* erf(x) = sign(x) * (c + P1(s)/Q1(s)) |
* erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0 |
* 1+(c+P1(s)/Q1(s)) if x < 0 |
* |P1/Q1 - (erf(|x|)-c)| <= 2**-59.06 |
* Remark: here we use the taylor series expansion at x=1. |
* erf(1+s) = erf(1) + s*Poly(s) |
* = 0.845.. + P1(s)/Q1(s) |
* That is, we use rational approximation to approximate |
* erf(1+s) - (c = (single)0.84506291151) |
* Note that |P1/Q1|< 0.078 for x in [0.84375,1.25] |
* where |
* P1(s) = degree 6 poly in s |
* Q1(s) = degree 6 poly in s |
* |
* 3. For x in [1.25,1/0.35(~2.857143)], |
* erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1) |
* erf(x) = 1 - erfc(x) |
* where |
* R1(z) = degree 7 poly in z, (z=1/x^2) |
* S1(z) = degree 8 poly in z |
* |
* 4. For x in [1/0.35,28] |
* erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0 |
* = 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6<x<0 |
* = 2.0 - tiny (if x <= -6) |
* erf(x) = sign(x)*(1.0 - erfc(x)) if x < 6, else |
* erf(x) = sign(x)*(1.0 - tiny) |
* where |
* R2(z) = degree 6 poly in z, (z=1/x^2) |
* S2(z) = degree 7 poly in z |
* |
* Note1: |
* To compute exp(-x*x-0.5625+R/S), let s be a single |
* precision number and s := x; then |
* -x*x = -s*s + (s-x)*(s+x) |
* exp(-x*x-0.5626+R/S) = |
* exp(-s*s-0.5625)*exp((s-x)*(s+x)+R/S); |
* Note2: |
* Here 4 and 5 make use of the asymptotic series |
* exp(-x*x) |
* erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) ) |
* x*sqrt(pi) |
* We use rational approximation to approximate |
* g(s)=f(1/x^2) = log(erfc(x)*x) - x*x + 0.5625 |
* Here is the error bound for R1/S1 and R2/S2 |
* |R1/S1 - f(x)| < 2**(-62.57) |
* |R2/S2 - f(x)| < 2**(-61.52) |
* |
* 5. For inf > x >= 28 |
* erf(x) = sign(x) *(1 - tiny) (raise inexact) |
* erfc(x) = tiny*tiny (raise underflow) if x > 0 |
* = 2 - tiny if x<0 |
* |
* 7. Special case: |
* erf(0) = 0, erf(inf) = 1, erf(-inf) = -1, |
* erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2, |
* erfc/erf(NaN) is NaN |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
tiny = 1e-300, |
half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ |
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */ |
/* c = (float)0.84506291151 */ |
erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */ |
/* |
* Coefficients for approximation to erf on [0,0.84375] |
*/ |
efx = 1.28379167095512586316e-01, /* 0x3FC06EBA, 0x8214DB69 */ |
efx8= 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */ |
pp0 = 1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */ |
pp1 = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */ |
pp2 = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */ |
pp3 = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */ |
pp4 = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */ |
qq1 = 3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */ |
qq2 = 6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */ |
qq3 = 5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */ |
qq4 = 1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */ |
qq5 = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */ |
/* |
* Coefficients for approximation to erf in [0.84375,1.25] |
*/ |
pa0 = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */ |
pa1 = 4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */ |
pa2 = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */ |
pa3 = 3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */ |
pa4 = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */ |
pa5 = 3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */ |
pa6 = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */ |
qa1 = 1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */ |
qa2 = 5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */ |
qa3 = 7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */ |
qa4 = 1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */ |
qa5 = 1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */ |
qa6 = 1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */ |
/* |
* Coefficients for approximation to erfc in [1.25,1/0.35] |
*/ |
ra0 = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */ |
ra1 = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */ |
ra2 = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */ |
ra3 = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */ |
ra4 = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */ |
ra5 = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */ |
ra6 = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */ |
ra7 = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */ |
sa1 = 1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */ |
sa2 = 1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */ |
sa3 = 4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */ |
sa4 = 6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */ |
sa5 = 4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */ |
sa6 = 1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */ |
sa7 = 6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */ |
sa8 = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */ |
/* |
* Coefficients for approximation to erfc in [1/.35,28] |
*/ |
rb0 = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */ |
rb1 = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */ |
rb2 = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */ |
rb3 = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */ |
rb4 = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */ |
rb5 = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */ |
rb6 = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */ |
sb1 = 3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */ |
sb2 = 3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */ |
sb3 = 1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */ |
sb4 = 3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */ |
sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */ |
sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */ |
sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */ |
#ifdef __STDC__ |
double erf(double x) |
#else |
double erf(x) |
double x; |
#endif |
{ |
__int32_t hx,ix,i; |
double R,S,P,Q,s,y,z,r; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix>=0x7ff00000) { /* erf(nan)=nan */ |
i = ((__uint32_t)hx>>31)<<1; |
return (double)(1-i)+one/x; /* erf(+-inf)=+-1 */ |
} |
if(ix < 0x3feb0000) { /* |x|<0.84375 */ |
if(ix < 0x3e300000) { /* |x|<2**-28 */ |
if (ix < 0x00800000) |
return 0.125*(8.0*x+efx8*x); /*avoid underflow */ |
return x + efx*x; |
} |
z = x*x; |
r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); |
s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); |
y = r/s; |
return x + x*y; |
} |
if(ix < 0x3ff40000) { /* 0.84375 <= |x| < 1.25 */ |
s = fabs(x)-one; |
P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); |
Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); |
if(hx>=0) return erx + P/Q; else return -erx - P/Q; |
} |
if (ix >= 0x40180000) { /* inf>|x|>=6 */ |
if(hx>=0) return one-tiny; else return tiny-one; |
} |
x = fabs(x); |
s = one/(x*x); |
if(ix< 0x4006DB6E) { /* |x| < 1/0.35 */ |
R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( |
ra5+s*(ra6+s*ra7)))))); |
S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( |
sa5+s*(sa6+s*(sa7+s*sa8))))))); |
} else { /* |x| >= 1/0.35 */ |
R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( |
rb5+s*rb6))))); |
S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( |
sb5+s*(sb6+s*sb7)))))); |
} |
z = x; |
SET_LOW_WORD(z,0); |
r = __ieee754_exp(-z*z-0.5625)*__ieee754_exp((z-x)*(z+x)+R/S); |
if(hx>=0) return one-r/x; else return r/x-one; |
} |
#ifdef __STDC__ |
double erfc(double x) |
#else |
double erfc(x) |
double x; |
#endif |
{ |
__int32_t hx,ix; |
double R,S,P,Q,s,y,z,r; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix>=0x7ff00000) { /* erfc(nan)=nan */ |
/* erfc(+-inf)=0,2 */ |
return (double)(((__uint32_t)hx>>31)<<1)+one/x; |
} |
if(ix < 0x3feb0000) { /* |x|<0.84375 */ |
if(ix < 0x3c700000) /* |x|<2**-56 */ |
return one-x; |
z = x*x; |
r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); |
s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); |
y = r/s; |
if(hx < 0x3fd00000) { /* x<1/4 */ |
return one-(x+x*y); |
} else { |
r = x*y; |
r += (x-half); |
return half - r ; |
} |
} |
if(ix < 0x3ff40000) { /* 0.84375 <= |x| < 1.25 */ |
s = fabs(x)-one; |
P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); |
Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); |
if(hx>=0) { |
z = one-erx; return z - P/Q; |
} else { |
z = erx+P/Q; return one+z; |
} |
} |
if (ix < 0x403c0000) { /* |x|<28 */ |
x = fabs(x); |
s = one/(x*x); |
if(ix< 0x4006DB6D) { /* |x| < 1/.35 ~ 2.857143*/ |
R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( |
ra5+s*(ra6+s*ra7)))))); |
S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( |
sa5+s*(sa6+s*(sa7+s*sa8))))))); |
} else { /* |x| >= 1/.35 ~ 2.857143 */ |
if(hx<0&&ix>=0x40180000) return two-tiny;/* x < -6 */ |
R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( |
rb5+s*rb6))))); |
S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( |
sb5+s*(sb6+s*sb7)))))); |
} |
z = x; |
SET_LOW_WORD(z,0); |
r = __ieee754_exp(-z*z-0.5625)* |
__ieee754_exp((z-x)*(z+x)+R/S); |
if(hx>0) return r/x; else return two-r/x; |
} else { |
if(hx>0) return tiny*tiny; else return two-tiny; |
} |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_exp10.c |
---|
0,0 → 1,80 |
/* @(#)s_exp10.c 5.1 93/09/24 */ |
/* Modified from s_exp2.c by Yaakov Selkowitz 2007. */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<exp10>>, <<exp10f>>---exponential |
INDEX |
exp10 |
INDEX |
exp10f |
ANSI_SYNOPSIS |
#include <math.h> |
double exp10(double <[x]>); |
float exp10f(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double exp10(<[x]>); |
double <[x]>; |
float exp10f(<[x]>); |
float <[x]>; |
DESCRIPTION |
<<exp10>> and <<exp10f>> calculate 10 ^ <[x]>, that is, |
@ifnottex |
10 raised to the power <[x]>. |
@end ifnottex |
@tex |
$10^x$ |
@end tex |
You can use the (non-ANSI) function <<matherr>> to specify |
error handling for these functions. |
RETURNS |
On success, <<exp10>> and <<exp10f>> return the calculated value. |
If the result underflows, the returned value is <<0>>. If the |
result overflows, the returned value is <<HUGE_VAL>>. In |
either case, <<errno>> is set to <<ERANGE>>. |
PORTABILITY |
<<exp10>> and <<exp10f>> are GNU extensions. |
*/ |
/* |
* wrapper exp10(x) |
*/ |
#undef exp10 |
#include "fdlibm.h" |
#include <errno.h> |
#include <math.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double exp10(double x) /* wrapper exp10 */ |
#else |
double exp10(x) /* wrapper exp10 */ |
double x; |
#endif |
{ |
return pow(10.0, x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/s_expm1.c |
---|
0,0 → 1,272 |
/* @(#)s_expm1.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<expm1>>, <<expm1f>>---exponential minus 1 |
INDEX |
expm1 |
INDEX |
expm1f |
ANSI_SYNOPSIS |
#include <math.h> |
double expm1(double <[x]>); |
float expm1f(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double expm1(<[x]>); |
double <[x]>; |
float expm1f(<[x]>); |
float <[x]>; |
DESCRIPTION |
<<expm1>> and <<expm1f>> calculate the exponential of <[x]> |
and subtract 1, that is, |
@ifnottex |
e raised to the power <[x]> minus 1 (where e |
@end ifnottex |
@tex |
$e^x - 1$ (where $e$ |
@end tex |
is the base of the natural system of logarithms, approximately |
2.71828). The result is accurate even for small values of |
<[x]>, where using <<exp(<[x]>)-1>> would lose many |
significant digits. |
RETURNS |
e raised to the power <[x]>, minus 1. |
PORTABILITY |
Neither <<expm1>> nor <<expm1f>> is required by ANSI C or by |
the System V Interface Definition (Issue 2). |
*/ |
/* expm1(x) |
* Returns exp(x)-1, the exponential of x minus 1. |
* |
* Method |
* 1. Argument reduction: |
* Given x, find r and integer k such that |
* |
* x = k*ln2 + r, |r| <= 0.5*ln2 ~ 0.34658 |
* |
* Here a correction term c will be computed to compensate |
* the error in r when rounded to a floating-point number. |
* |
* 2. Approximating expm1(r) by a special rational function on |
* the interval [0,0.34658]: |
* Since |
* r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ... |
* we define R1(r*r) by |
* r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r) |
* That is, |
* R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r) |
* = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r)) |
* = 1 - r^2/60 + r^4/2520 - r^6/100800 + ... |
* We use a special Reme algorithm on [0,0.347] to generate |
* a polynomial of degree 5 in r*r to approximate R1. The |
* maximum error of this polynomial approximation is bounded |
* by 2**-61. In other words, |
* R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5 |
* where Q1 = -1.6666666666666567384E-2, |
* Q2 = 3.9682539681370365873E-4, |
* Q3 = -9.9206344733435987357E-6, |
* Q4 = 2.5051361420808517002E-7, |
* Q5 = -6.2843505682382617102E-9; |
* (where z=r*r, and the values of Q1 to Q5 are listed below) |
* with error bounded by |
* | 5 | -61 |
* | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2 |
* | | |
* |
* expm1(r) = exp(r)-1 is then computed by the following |
* specific way which minimize the accumulation rounding error: |
* 2 3 |
* r r [ 3 - (R1 + R1*r/2) ] |
* expm1(r) = r + --- + --- * [--------------------] |
* 2 2 [ 6 - r*(3 - R1*r/2) ] |
* |
* To compensate the error in the argument reduction, we use |
* expm1(r+c) = expm1(r) + c + expm1(r)*c |
* ~ expm1(r) + c + r*c |
* Thus c+r*c will be added in as the correction terms for |
* expm1(r+c). Now rearrange the term to avoid optimization |
* screw up: |
* ( 2 2 ) |
* ({ ( r [ R1 - (3 - R1*r/2) ] ) } r ) |
* expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- ) |
* ({ ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 ) |
* ( ) |
* |
* = r - E |
* 3. Scale back to obtain expm1(x): |
* From step 1, we have |
* expm1(x) = either 2^k*[expm1(r)+1] - 1 |
* = or 2^k*[expm1(r) + (1-2^-k)] |
* 4. Implementation notes: |
* (A). To save one multiplication, we scale the coefficient Qi |
* to Qi*2^i, and replace z by (x^2)/2. |
* (B). To achieve maximum accuracy, we compute expm1(x) by |
* (i) if x < -56*ln2, return -1.0, (raise inexact if x!=inf) |
* (ii) if k=0, return r-E |
* (iii) if k=-1, return 0.5*(r-E)-0.5 |
* (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E) |
* else return 1.0+2.0*(r-E); |
* (v) if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1) |
* (vi) if k <= 20, return 2^k((1-2^-k)-(E-r)), else |
* (vii) return 2^k(1-((E+2^-k)-r)) |
* |
* Special cases: |
* expm1(INF) is INF, expm1(NaN) is NaN; |
* expm1(-INF) is -1, and |
* for finite argument, only expm1(0)=0 is exact. |
* |
* Accuracy: |
* according to an error analysis, the error is always less than |
* 1 ulp (unit in the last place). |
* |
* Misc. info. |
* For IEEE double |
* if x > 7.09782712893383973096e+02 then expm1(x) overflow |
* |
* Constants: |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
one = 1.0, |
huge = 1.0e+300, |
tiny = 1.0e-300, |
o_threshold = 7.09782712893383973096e+02,/* 0x40862E42, 0xFEFA39EF */ |
ln2_hi = 6.93147180369123816490e-01,/* 0x3fe62e42, 0xfee00000 */ |
ln2_lo = 1.90821492927058770002e-10,/* 0x3dea39ef, 0x35793c76 */ |
invln2 = 1.44269504088896338700e+00,/* 0x3ff71547, 0x652b82fe */ |
/* scaled coefficients related to expm1 */ |
Q1 = -3.33333333333331316428e-02, /* BFA11111 111110F4 */ |
Q2 = 1.58730158725481460165e-03, /* 3F5A01A0 19FE5585 */ |
Q3 = -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */ |
Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */ |
Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */ |
#ifdef __STDC__ |
double expm1(double x) |
#else |
double expm1(x) |
double x; |
#endif |
{ |
double y,hi,lo,c,t,e,hxs,hfx,r1; |
__int32_t k,xsb; |
__uint32_t hx; |
GET_HIGH_WORD(hx,x); |
xsb = hx&0x80000000; /* sign bit of x */ |
if(xsb==0) y=x; else y= -x; /* y = |x| */ |
hx &= 0x7fffffff; /* high word of |x| */ |
/* filter out huge and non-finite argument */ |
if(hx >= 0x4043687A) { /* if |x|>=56*ln2 */ |
if(hx >= 0x40862E42) { /* if |x|>=709.78... */ |
if(hx>=0x7ff00000) { |
__uint32_t low; |
GET_LOW_WORD(low,x); |
if(((hx&0xfffff)|low)!=0) |
return x+x; /* NaN */ |
else return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */ |
} |
if(x > o_threshold) return huge*huge; /* overflow */ |
} |
if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */ |
if(x+tiny<0.0) /* raise inexact */ |
return tiny-one; /* return -1 */ |
} |
} |
/* argument reduction */ |
if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */ |
if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */ |
if(xsb==0) |
{hi = x - ln2_hi; lo = ln2_lo; k = 1;} |
else |
{hi = x + ln2_hi; lo = -ln2_lo; k = -1;} |
} else { |
k = invln2*x+((xsb==0)?0.5:-0.5); |
t = k; |
hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ |
lo = t*ln2_lo; |
} |
x = hi - lo; |
c = (hi-x)-lo; |
} |
else if(hx < 0x3c900000) { /* when |x|<2**-54, return x */ |
t = huge+x; /* return x with inexact flags when x!=0 */ |
return x - (t-(huge+x)); |
} |
else k = 0; |
/* x is now in primary range */ |
hfx = 0.5*x; |
hxs = x*hfx; |
r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5)))); |
t = 3.0-r1*hfx; |
e = hxs*((r1-t)/(6.0 - x*t)); |
if(k==0) return x - (x*e-hxs); /* c is 0 */ |
else { |
e = (x*(e-c)-c); |
e -= hxs; |
if(k== -1) return 0.5*(x-e)-0.5; |
if(k==1) { |
if(x < -0.25) return -2.0*(e-(x+0.5)); |
else return one+2.0*(x-e); |
} |
if (k <= -2 || k>56) { /* suffice to return exp(x)-1 */ |
__uint32_t high; |
y = one-(e-x); |
GET_HIGH_WORD(high,y); |
SET_HIGH_WORD(y,high+(k<<20)); /* add k to y's exponent */ |
return y-one; |
} |
t = one; |
if(k<20) { |
__uint32_t high; |
SET_HIGH_WORD(t,0x3ff00000 - (0x200000>>k)); /* t=1-2^-k */ |
y = t-(e-x); |
GET_HIGH_WORD(high,y); |
SET_HIGH_WORD(y,high+(k<<20)); /* add k to y's exponent */ |
} else { |
__uint32_t high; |
SET_HIGH_WORD(t,((0x3ff-k)<<20)); /* 2^-k */ |
y = x-(e+t); |
y += one; |
GET_HIGH_WORD(high,y); |
SET_HIGH_WORD(y,high+(k<<20)); /* add k to y's exponent */ |
} |
} |
return y; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_fabs.c |
---|
0,0 → 1,73 |
/* @(#)s_fabs.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<fabs>>, <<fabsf>>---absolute value (magnitude) |
INDEX |
fabs |
INDEX |
fabsf |
ANSI_SYNOPSIS |
#include <math.h> |
double fabs(double <[x]>); |
float fabsf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double fabs(<[x]>) |
double <[x]>; |
float fabsf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<fabs>> and <<fabsf>> calculate |
@tex |
$|x|$, |
@end tex |
the absolute value (magnitude) of the argument <[x]>, by direct |
manipulation of the bit representation of <[x]>. |
RETURNS |
The calculated value is returned. No errors are detected. |
PORTABILITY |
<<fabs>> is ANSI. |
<<fabsf>> is an extension. |
*/ |
/* |
* fabs(x) returns the absolute value of x. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fabs(double x) |
#else |
double fabs(x) |
double x; |
#endif |
{ |
__uint32_t high; |
GET_HIGH_WORD(high,x); |
SET_HIGH_WORD(x,high&0x7fffffff); |
return x; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_fdim.c |
---|
0,0 → 1,61 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* |
FUNCTION |
<<fdim>>, <<fdimf>>--positive difference |
INDEX |
fdim |
INDEX |
fdimf |
ANSI_SYNOPSIS |
#include <math.h> |
double fdim(double <[x]>, double <[y]>); |
float fdimf(float <[x]>, float <[y]>); |
DESCRIPTION |
The <<fdim>> functions determine the positive difference between their |
arguments, returning: |
. <[x]> - <[y]> if <[x]> > <[y]>, or |
@ifnottex |
. +0 if <[x]> <= <[y]>, or |
@end ifnottex |
@tex |
. +0 if <[x]> $\leq$ <[y]>, or |
@end tex |
. NAN if either argument is NAN. |
A range error may occur. |
RETURNS |
The <<fdim>> functions return the positive difference value. |
PORTABILITY |
ANSI C, POSIX. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fdim(double x, double y) |
#else |
double fdim(x,y) |
double x; |
double y; |
#endif |
{ |
int c = __fpclassifyd(x); |
if (c == FP_NAN) return(x); |
if (__fpclassifyd(y) == FP_NAN) return(y); |
if (c == FP_INFINITE) |
return HUGE_VAL; |
return x > y ? x - y : 0.0; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_finite.c |
---|
0,0 → 1,35 |
/* @(#)s_finite.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* finite(x) returns 1 is x is finite, else 0; |
* no branching! |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
int finite(double x) |
#else |
int finite(x) |
double x; |
#endif |
{ |
__int32_t hx; |
GET_HIGH_WORD(hx,x); |
return (int)((__uint32_t)((hx&0x7fffffff)-0x7ff00000)>>31); |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_floor.c |
---|
0,0 → 1,134 |
/* @(#)s_floor.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<floor>>, <<floorf>>, <<ceil>>, <<ceilf>>---floor and ceiling |
INDEX |
floor |
INDEX |
floorf |
INDEX |
ceil |
INDEX |
ceilf |
ANSI_SYNOPSIS |
#include <math.h> |
double floor(double <[x]>); |
float floorf(float <[x]>); |
double ceil(double <[x]>); |
float ceilf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double floor(<[x]>) |
double <[x]>; |
float floorf(<[x]>) |
float <[x]>; |
double ceil(<[x]>) |
double <[x]>; |
float ceilf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<floor>> and <<floorf>> find |
@tex |
$\lfloor x \rfloor$, |
@end tex |
the nearest integer less than or equal to <[x]>. |
<<ceil>> and <<ceilf>> find |
@tex |
$\lceil x\rceil$, |
@end tex |
the nearest integer greater than or equal to <[x]>. |
RETURNS |
<<floor>> and <<ceil>> return the integer result as a double. |
<<floorf>> and <<ceilf>> return the integer result as a float. |
PORTABILITY |
<<floor>> and <<ceil>> are ANSI. |
<<floorf>> and <<ceilf>> are extensions. |
*/ |
/* |
* floor(x) |
* Return x rounded toward -inf to integral value |
* Method: |
* Bit twiddling. |
* Exception: |
* Inexact flag raised if x not equal to floor(x). |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double huge = 1.0e300; |
#else |
static double huge = 1.0e300; |
#endif |
#ifdef __STDC__ |
double floor(double x) |
#else |
double floor(x) |
double x; |
#endif |
{ |
__int32_t i0,i1,j0; |
__uint32_t i,j; |
EXTRACT_WORDS(i0,i1,x); |
j0 = ((i0>>20)&0x7ff)-0x3ff; |
if(j0<20) { |
if(j0<0) { /* raise inexact if x != 0 */ |
if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */ |
if(i0>=0) {i0=i1=0;} |
else if(((i0&0x7fffffff)|i1)!=0) |
{ i0=0xbff00000;i1=0;} |
} |
} else { |
i = (0x000fffff)>>j0; |
if(((i0&i)|i1)==0) return x; /* x is integral */ |
if(huge+x>0.0) { /* raise inexact flag */ |
if(i0<0) i0 += (0x00100000)>>j0; |
i0 &= (~i); i1=0; |
} |
} |
} else if (j0>51) { |
if(j0==0x400) return x+x; /* inf or NaN */ |
else return x; /* x is integral */ |
} else { |
i = ((__uint32_t)(0xffffffff))>>(j0-20); |
if((i1&i)==0) return x; /* x is integral */ |
if(huge+x>0.0) { /* raise inexact flag */ |
if(i0<0) { |
if(j0==20) i0+=1; |
else { |
j = i1+(1<<(52-j0)); |
if(j<i1) i0 +=1 ; /* got a carry */ |
i1=j; |
} |
} |
i1 &= (~i); |
} |
} |
INSERT_WORDS(x,i0,i1); |
return x; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_fma.c |
---|
0,0 → 1,56 |
/* |
FUNCTION |
<<fma>>, <<fmaf>>--floating multiply add |
INDEX |
fma |
INDEX |
fmaf |
ANSI_SYNOPSIS |
#include <math.h> |
double fma(double <[x]>, double <[y]>, double <[z]>); |
float fmaf(float <[x]>, float <[y]>, float <[z]>); |
DESCRIPTION |
The <<fma>> functions compute (<[x]> * <[y]>) + <[z]>, rounded as one ternary |
operation: they compute the value (as if) to infinite precision and round once |
to the result format, according to the rounding mode characterized by the value |
of FLT_ROUNDS. That is, they are supposed to do this: see below. |
RETURNS |
The <<fma>> functions return (<[x]> * <[y]>) + <[z]>, rounded as one ternary |
operation. |
BUGS |
This implementation does not provide the function that it should, purely |
returning "(<[x]> * <[y]>) + <[z]>;" with no attempt at all to provide the |
simulated infinite precision intermediates which are required. DO NOT USE THEM. |
If double has enough more precision than float, then <<fmaf>> should provide |
the expected numeric results, as it does use double for the calculation. But |
since this is not the case for all platforms, this manual cannot determine |
if it is so for your case. |
PORTABILITY |
ANSI C, POSIX. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fma(double x, double y, double z) |
#else |
double fma(x,y) |
double x; |
double y; |
double z; |
#endif |
{ |
/* Implementation defined. */ |
return (x * y) + z; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_fmax.c |
---|
0,0 → 1,52 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* |
FUNCTION |
<<fmax>>, <<fmaxf>>--maximum |
INDEX |
fmax |
INDEX |
fmaxf |
ANSI_SYNOPSIS |
#include <math.h> |
double fmax(double <[x]>, double <[y]>); |
float fmaxf(float <[x]>, float <[y]>); |
DESCRIPTION |
The <<fmax>> functions determine the maximum numeric value of their arguments. |
NaN arguments are treated as missing data: if one argument is a NaN and the |
other numeric, then the <<fmax>> functions choose the numeric value. |
RETURNS |
The <<fmax>> functions return the maximum numeric value of their arguments. |
PORTABILITY |
ANSI C, POSIX. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fmax(double x, double y) |
#else |
double fmax(x,y) |
double x; |
double y; |
#endif |
{ |
if (__fpclassifyd(x) == FP_NAN) |
return y; |
if (__fpclassifyd(y) == FP_NAN) |
return x; |
return x > y ? x : y; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_fmin.c |
---|
0,0 → 1,52 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* |
FUNCTION |
<<fmin>>, <<fminf>>--minimum |
INDEX |
fmin |
INDEX |
fminf |
ANSI_SYNOPSIS |
#include <math.h> |
double fmin(double <[x]>, double <[y]>); |
float fminf(float <[x]>, float <[y]>); |
DESCRIPTION |
The <<fmin>> functions determine the minimum numeric value of their arguments. |
NaN arguments are treated as missing data: if one argument is a NaN and the |
other numeric, then the <<fmin>> functions choose the numeric value. |
RETURNS |
The <<fmin>> functions return the minimum numeric value of their arguments. |
PORTABILITY |
ANSI C, POSIX. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fmin(double x, double y) |
#else |
double fmin(x,y) |
double x; |
double y; |
#endif |
{ |
if (__fpclassifyd(x) == FP_NAN) |
return y; |
if (__fpclassifyd(y) == FP_NAN) |
return x; |
return x < y ? x : y; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_fpclassify.c |
---|
0,0 → 1,31 |
/* Copyright (C) 2002, 2007 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include "fdlibm.h" |
int |
__fpclassifyd (double x) |
{ |
__uint32_t msw, lsw; |
EXTRACT_WORDS(msw,lsw,x); |
if ((msw == 0x00000000 && lsw == 0x00000000) || |
(msw == 0x80000000 && lsw == 0x00000000)) |
return FP_ZERO; |
else if ((msw >= 0x00100000 && msw <= 0x7fefffff) || |
(msw >= 0x80100000 && msw <= 0xffefffff)) |
return FP_NORMAL; |
else if ((msw >= 0x00000000 && msw <= 0x000fffff) || |
(msw >= 0x80000000 && msw <= 0x800fffff)) |
/* zero is already handled above */ |
return FP_SUBNORMAL; |
else if ((msw == 0x7ff00000 && lsw == 0x00000000) || |
(msw == 0xfff00000 && lsw == 0x00000000)) |
return FP_INFINITE; |
else |
return FP_NAN; |
} |
/contrib/sdk/sources/libc/math/s_frexp.c |
---|
0,0 → 1,114 |
/* @(#)s_frexp.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<frexp>>, <<frexpf>>---split floating-point number |
INDEX |
frexp |
INDEX |
frexpf |
ANSI_SYNOPSIS |
#include <math.h> |
double frexp(double <[val]>, int *<[exp]>); |
float frexpf(float <[val]>, int *<[exp]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double frexp(<[val]>, <[exp]>) |
double <[val]>; |
int *<[exp]>; |
float frexpf(<[val]>, <[exp]>) |
float <[val]>; |
int *<[exp]>; |
DESCRIPTION |
All nonzero, normal numbers can be described as <[m]> * 2**<[p]>. |
<<frexp>> represents the double <[val]> as a mantissa <[m]> |
and a power of two <[p]>. The resulting mantissa will always |
be greater than or equal to <<0.5>>, and less than <<1.0>> (as |
long as <[val]> is nonzero). The power of two will be stored |
in <<*>><[exp]>. |
@ifnottex |
<[m]> and <[p]> are calculated so that |
<[val]> is <[m]> times <<2>> to the power <[p]>. |
@end ifnottex |
@tex |
<[m]> and <[p]> are calculated so that |
$ val = m \times 2^p $. |
@end tex |
<<frexpf>> is identical, other than taking and returning |
floats rather than doubles. |
RETURNS |
<<frexp>> returns the mantissa <[m]>. If <[val]> is <<0>>, infinity, |
or Nan, <<frexp>> will set <<*>><[exp]> to <<0>> and return <[val]>. |
PORTABILITY |
<<frexp>> is ANSI. |
<<frexpf>> is an extension. |
*/ |
/* |
* for non-zero x |
* x = frexp(arg,&exp); |
* return a double fp quantity x such that 0.5 <= |x| <1.0 |
* and the corresponding binary exponent "exp". That is |
* arg = x*2^exp. |
* If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg |
* with *exp=0. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ |
#ifdef __STDC__ |
double frexp(double x, int *eptr) |
#else |
double frexp(x, eptr) |
double x; int *eptr; |
#endif |
{ |
__int32_t hx, ix, lx; |
EXTRACT_WORDS(hx,lx,x); |
ix = 0x7fffffff&hx; |
*eptr = 0; |
if(ix>=0x7ff00000||((ix|lx)==0)) return x; /* 0,inf,nan */ |
if (ix<0x00100000) { /* subnormal */ |
x *= two54; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; |
*eptr = -54; |
} |
*eptr += (ix>>20)-1022; |
hx = (hx&0x800fffff)|0x3fe00000; |
SET_HIGH_WORD(x,hx); |
return x; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_ilogb.c |
---|
0,0 → 1,106 |
/* @(#)s_ilogb.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<ilogb>>, <<ilogbf>>---get exponent of floating-point number |
INDEX |
ilogb |
INDEX |
ilogbf |
ANSI_SYNOPSIS |
#include <math.h> |
int ilogb(double <[val]>); |
int ilogbf(float <[val]>); |
TRAD_SYNOPSIS |
#include <math.h> |
int ilogb(<[val]>) |
double <[val]>; |
int ilogbf(<[val]>) |
float <[val]>; |
DESCRIPTION |
All nonzero, normal numbers can be described as <[m]> * |
2**<[p]>. <<ilogb>> and <<ilogbf>> examine the argument |
<[val]>, and return <[p]>. The functions <<frexp>> and |
<<frexpf>> are similar to <<ilogb>> and <<ilogbf>>, but also |
return <[m]>. |
RETURNS |
<<ilogb>> and <<ilogbf>> return the power of two used to form the |
floating-point argument. |
If <[val]> is <<0>>, they return <<FP_ILOGB0>>. |
If <[val]> is infinite, they return <<INT_MAX>>. |
If <[val]> is NaN, they return <<FP_ILOGBNAN>>. |
(<<FP_ILOGB0>> and <<FP_ILOGBNAN>> are defined in math.h, but in turn are |
defined as INT_MIN or INT_MAX from limits.h. The value of FP_ILOGB0 may be |
either INT_MIN or -INT_MAX. The value of FP_ILOGBNAN may be either INT_MAX or |
INT_MIN.) |
@comment The bugs might not be worth noting, given the mass non-C99/POSIX |
@comment behavior of much of the Newlib math library. |
@comment BUGS |
@comment On errors, errno is not set per C99 and POSIX requirements even if |
@comment (math_errhandling & MATH_ERRNO) is non-zero. |
PORTABILITY |
C99, POSIX |
*/ |
/* ilogb(double x) |
* return the binary exponent of non-zero x |
* ilogb(0) = 0x80000001 |
* ilogb(inf/NaN) = 0x7fffffff (no signal is raised) |
*/ |
#include <limits.h> |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
int ilogb(double x) |
#else |
int ilogb(x) |
double x; |
#endif |
{ |
__int32_t hx,lx,ix; |
EXTRACT_WORDS(hx,lx,x); |
hx &= 0x7fffffff; |
if(hx<0x00100000) { |
if((hx|lx)==0) |
return FP_ILOGB0; /* ilogb(0) = special case error */ |
else /* subnormal x */ |
if(hx==0) { |
for (ix = -1043; lx>0; lx<<=1) ix -=1; |
} else { |
for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1; |
} |
return ix; |
} |
else if (hx<0x7ff00000) return (hx>>20)-1023; |
#if FP_ILOGBNAN != INT_MAX |
else if (hx>0x7ff00000) return FP_ILOGBNAN; /* NAN */ |
#endif |
else return INT_MAX; /* infinite (or, possibly, NAN) */ |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_infconst.c |
---|
0,0 → 1,21 |
/* Infinity as a constant value. This is used for HUGE_VAL. |
* Added by Cygnus Support. |
*/ |
#include <float.h> |
#include <math.h> |
/* These should never actually be used any longer, as their use in math.h was |
* removed, but they are kept here in case a user was pointing to them. |
* FIXME: deprecate these identifiers and then delete them. */ |
/* Float version of infinity. */ |
const union __fmath __infinityf[1] = { { FLT_MAX+FLT_MAX } }; |
/* Double version of infinity. */ |
const union __dmath __infinity[1] = { { DBL_MAX+DBL_MAX } }; |
/* Long double version of infinity. */ |
#if defined(_HAVE_LONG_DOUBLE) |
const union __ldmath __infinityld[1] = { { LDBL_MAX+LDBL_MAX } }; |
#endif |
/contrib/sdk/sources/libc/math/s_infinity.c |
---|
0,0 → 1,49 |
/* |
* infinity () returns the representation of infinity. |
* Added by Cygnus Support. |
*/ |
/* |
FUNCTION |
<<infinity>>, <<infinityf>>--representation of infinity |
INDEX |
infinity |
INDEX |
infinityf |
ANSI_SYNOPSIS |
#include <math.h> |
double infinity(void); |
float infinityf(void); |
DESCRIPTION |
<<infinity>> and <<infinityf>> return the special number IEEE |
infinity in double- and single-precision arithmetic |
respectively. |
PORTABILITY |
<<infinity>> and <<infinityf>> are neither standard C nor POSIX. C and |
POSIX require macros HUGE_VAL and HUGE_VALF to be defined in math.h, which |
Newlib defines to be infinities corresponding to these archaic infinity() |
and infinityf() functions in floating-point implementations which do have |
infinities. |
QUICKREF |
infinity - pure |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
double infinity() |
{ |
double x; |
INSERT_WORDS(x,0x7ff00000,0); |
return x; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_isinf.c |
---|
0,0 → 1,29 |
/* |
* isinf(x) returns 1 if x is infinity, else 0; |
* no branching! |
* |
* isinf is a <math.h> macro in the C99 standard. It was previously |
* implemented as a function by newlib and is declared as such in |
* <ieeefp.h>. Newlib supplies it here as a function if the user |
* chooses to use <ieeefp.h> or needs to link older code compiled with the |
* previous <math.h> declaration. |
*/ |
#include "fdlibm.h" |
#include <ieeefp.h> |
#ifndef _DOUBLE_IS_32BITS |
int |
_DEFUN (isinf, (x), |
double x) |
{ |
__int32_t hx,lx; |
EXTRACT_WORDS(hx,lx,x); |
hx &= 0x7fffffff; |
hx |= (__uint32_t)(lx|(-lx))>>31; |
hx = 0x7ff00000 - hx; |
return 1 - (int)((__uint32_t)(hx|(-hx))>>31); |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_isinfd.c |
---|
0,0 → 1,23 |
/* |
* __isinfd(x) returns 1 if x is infinity, else 0; |
* no branching! |
* Added by Cygnus Support. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
int |
_DEFUN (__isinfd, (x), |
double x) |
{ |
__int32_t hx,lx; |
EXTRACT_WORDS(hx,lx,x); |
hx &= 0x7fffffff; |
hx |= (__uint32_t)(lx|(-lx))>>31; |
hx = 0x7ff00000 - hx; |
return 1 - (int)((__uint32_t)(hx|(-hx))>>31); |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_isnan.c |
---|
0,0 → 1,206 |
/* @(#)s_isnan.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<fpclassify>>, <<isfinite>>, <<isinf>>, <<isnan>>, and <<isnormal>>--floating-point classification macros; <<finite>>, <<finitef>>, <<isinf>>, <<isinff>>, <<isnan>>, <<isnanf>>--test for exceptional numbers |
@c C99 (start |
INDEX |
fpclassify |
INDEX |
isfinite |
INDEX |
isinf |
INDEX |
isnan |
INDEX |
isnormal |
@c C99 end) |
@c SUSv2 (start |
INDEX |
isnan |
INDEX |
isinf |
INDEX |
finite |
INDEX |
isnanf |
INDEX |
isinff |
INDEX |
finitef |
@c SUSv2 end) |
ANSI_SYNOPSIS |
[C99 standard macros:] |
#include <math.h> |
int fpclassify(real-floating <[x]>); |
int isfinite(real-floating <[x]>); |
int isinf(real-floating <[x]>); |
int isnan(real-floating <[x]>); |
int isnormal(real-floating <[x]>); |
[Archaic SUSv2 functions:] |
#include <ieeefp.h> |
int isnan(double <[arg]>); |
int isinf(double <[arg]>); |
int finite(double <[arg]>); |
int isnanf(float <[arg]>); |
int isinff(float <[arg]>); |
int finitef(float <[arg]>); |
DESCRIPTION |
<<fpclassify>>, <<isfinite>>, <<isinf>>, <<isnan>>, and <<isnormal>> are macros |
defined for use in classifying floating-point numbers. This is a help because |
of special "values" like NaN and infinities. In the synopses shown, |
"real-floating" indicates that the argument is an expression of real floating |
type. These function-like macros are C99 and POSIX-compliant, and should be |
used instead of the now-archaic SUSv2 functions. |
The <<fpclassify>> macro classifies its argument value as NaN, infinite, normal, |
subnormal, zero, or into another implementation-defined category. First, an |
argument represented in a format wider than its semantic type is converted to |
its semantic type. Then classification is based on the type of the argument. |
The <<fpclassify>> macro returns the value of the number classification macro |
appropriate to the value of its argument: |
o+ |
o FP_INFINITE |
<[x]> is either plus or minus infinity; |
o FP_NAN |
<[x]> is "Not A Number" (plus or minus); |
o FP_NORMAL |
<[x]> is a "normal" number (i.e. is none of the other special forms); |
o FP_SUBNORMAL |
<[x]> is too small be stored as a regular normalized number (i.e. loss of precision is likely); or |
o FP_ZERO |
<[x]> is 0 (either plus or minus). |
o- |
The "<<is>>" set of macros provide a useful set of shorthand ways for |
classifying floating-point numbers, providing the following equivalent |
relations: |
o+ |
o <<isfinite>>(<[x]>) |
returns non-zero if <[x]> is finite. (It is equivalent to |
(<<fpclassify>>(<[x]>) != FP_INFINITE && <<fpclassify>>(<[x]>) != FP_NAN).) |
o <<isinf>>(<[x]>) |
returns non-zero if <[x]> is infinite. (It is equivalent to |
(<<fpclassify>>(<[x]>) == FP_INFINITE).) |
o <<isnan>>(<[x]>) |
returns non-zero if <[x]> is NaN. (It is equivalent to |
(<<fpclassify>>(<[x]>) == FP_NAN).) |
o <<isnormal>>(<[x]>) |
returns non-zero if <[x]> is normal. (It is equivalent to |
(<<fpclassify>>(<[x]>) == FP_NORMAL).) |
o- |
The archaic SUSv2 functions provide information on the floating-point |
argument supplied. |
There are five major number formats ("exponent" referring to the |
biased exponent in the binary-encoded number): |
o+ |
o zero |
A number which contains all zero bits, excluding the sign bit. |
o subnormal |
A number with a zero exponent but a nonzero fraction. |
o normal |
A number with an exponent and a fraction. |
o infinity |
A number with an all 1's exponent and a zero fraction. |
o NAN |
A number with an all 1's exponent and a nonzero fraction. |
o- |
<<isnan>> returns 1 if the argument is a nan. <<isinf>> |
returns 1 if the argument is infinity. <<finite>> returns 1 if the |
argument is zero, subnormal or normal. |
The <<isnanf>>, <<isinff>> and <<finitef>> functions perform the same |
operations as their <<isnan>>, <<isinf>> and <<finite>> |
counterparts, but on single-precision floating-point numbers. |
It should be noted that the C99 standard dictates that <<isnan>> |
and <<isinf>> are macros that operate on multiple types of |
floating-point. The SUSv2 standard declares <<isnan>> as |
a function taking double. Newlib has decided to declare |
them both as macros in math.h and as functions in ieeefp.h to |
maintain backward compatibility. |
RETURNS |
@comment Formatting note: "$@" forces a new line |
The fpclassify macro returns the value corresponding to the appropriate FP_ macro.@* |
The isfinite macro returns nonzero if <[x]> is finite, else 0.@* |
The isinf macro returns nonzero if <[x]> is infinite, else 0.@* |
The isnan macro returns nonzero if <[x]> is an NaN, else 0.@* |
The isnormal macro returns nonzero if <[x]> has a normal value, else 0. |
PORTABILITY |
math.h macros are C99, POSIX. |
ieeefp.h funtions are outdated and should be avoided. |
QUICKREF |
isnan - pure |
QUICKREF |
isinf - pure |
QUICKREF |
finite - pure |
QUICKREF |
isnan - pure |
QUICKREF |
isinf - pure |
QUICKREF |
finite - pure |
*/ |
/* |
* isnan(x) returns 1 is x is nan, else 0; |
* no branching! |
* |
* The C99 standard dictates that isnan is a macro taking |
* multiple floating-point types while the SUSv2 standard |
* notes it is a function taking a double argument. Newlib |
* has chosen to implement it as a macro in <math.h> and |
* declare it as a function in <ieeefp.h>. |
*/ |
#include "fdlibm.h" |
#include <ieeefp.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
int isnan(double x) |
#else |
int isnan(x) |
double x; |
#endif |
{ |
__int32_t hx,lx; |
EXTRACT_WORDS(hx,lx,x); |
hx &= 0x7fffffff; |
hx |= (__uint32_t)(lx|(-lx))>>31; |
hx = 0x7ff00000 - hx; |
return (int)(((__uint32_t)(hx))>>31); |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_isnand.c |
---|
0,0 → 1,122 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<isnan>>, <<isnanf>>, <<isinf>>, <<isinff>>, <<finite>>, <<finitef>>---test for exceptional numbers |
INDEX |
isnan |
INDEX |
isinf |
INDEX |
finite |
INDEX |
isnanf |
INDEX |
isinff |
INDEX |
finitef |
ANSI_SYNOPSIS |
#include <ieeefp.h> |
int isnan(double <[arg]>); |
int isinf(double <[arg]>); |
int finite(double <[arg]>); |
int isnanf(float <[arg]>); |
int isinff(float <[arg]>); |
int finitef(float <[arg]>); |
TRAD_SYNOPSIS |
#include <ieeefp.h> |
int isnan(<[arg]>) |
double <[arg]>; |
int isinf(<[arg]>) |
double <[arg]>; |
int finite(<[arg]>); |
double <[arg]>; |
int isnanf(<[arg]>); |
float <[arg]>; |
int isinff(<[arg]>); |
float <[arg]>; |
int finitef(<[arg]>); |
float <[arg]>; |
DESCRIPTION |
These functions provide information on the floating-point |
argument supplied. |
There are five major number formats: |
o+ |
o zero |
A number which contains all zero bits. |
o subnormal |
A number with a zero exponent but a nonzero fraction. |
o normal |
A number with an exponent and a fraction. |
o infinity |
A number with an all 1's exponent and a zero fraction. |
o NAN |
A number with an all 1's exponent and a nonzero fraction. |
o- |
<<isnan>> returns 1 if the argument is a nan. <<isinf>> |
returns 1 if the argument is infinity. <<finite>> returns 1 if the |
argument is zero, subnormal or normal. |
Note that by the C99 standard, <<isnan>> and <<isinf>> are macros |
taking any type of floating-point and are declared in |
<<math.h>>. Newlib has chosen to declare these as macros in |
<<math.h>> and as functions in <<ieeefp.h>>. |
The <<isnanf>>, <<isinff>> and <<finitef>> functions perform the same |
operations as their <<isnan>>, <<isinf>> and <<finite>> |
counterparts, but on single-precision floating-point numbers. |
QUICKREF |
isnan - pure |
QUICKREF |
isinf - pure |
QUICKREF |
finite - pure |
QUICKREF |
isnan - pure |
QUICKREF |
isinf - pure |
QUICKREF |
finite - pure |
*/ |
/* |
* __isnand(x) returns 1 is x is nan, else 0; |
* no branching! |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
int |
_DEFUN (__isnand, (x), |
double x) |
{ |
__int32_t hx,lx; |
EXTRACT_WORDS(hx,lx,x); |
hx &= 0x7fffffff; |
hx |= (__uint32_t)(lx|(-lx))>>31; |
hx = 0x7ff00000 - hx; |
return (int)(((__uint32_t)(hx))>>31); |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_ldexp.c |
---|
0,0 → 1,81 |
/* @(#)s_ldexp.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<ldexp>>, <<ldexpf>>---load exponent |
INDEX |
ldexp |
INDEX |
ldexpf |
ANSI_SYNOPSIS |
#include <math.h> |
double ldexp(double <[val]>, int <[exp]>); |
float ldexpf(float <[val]>, int <[exp]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double ldexp(<[val]>, <[exp]>) |
double <[val]>; |
int <[exp]>; |
float ldexpf(<[val]>, <[exp]>) |
float <[val]>; |
int <[exp]>; |
DESCRIPTION |
<<ldexp>> calculates the value |
@ifnottex |
<[val]> times 2 to the power <[exp]>. |
@end ifnottex |
@tex |
$val\times 2^{exp}$. |
@end tex |
<<ldexpf>> is identical, save that it takes and returns <<float>> |
rather than <<double>> values. |
RETURNS |
<<ldexp>> returns the calculated value. |
Underflow and overflow both set <<errno>> to <<ERANGE>>. |
On underflow, <<ldexp>> and <<ldexpf>> return 0.0. |
On overflow, <<ldexp>> returns plus or minus <<HUGE_VAL>>. |
PORTABILITY |
<<ldexp>> is ANSI. <<ldexpf>> is an extension. |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double ldexp(double value, int exp) |
#else |
double ldexp(value, exp) |
double value; int exp; |
#endif |
{ |
if(!finite(value)||value==0.0) return value; |
value = scalbn(value,exp); |
if(!finite(value)||value==0.0) errno = ERANGE; |
return value; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_lib_ver.c |
---|
0,0 → 1,35 |
/* @(#)s_lib_ver.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* MACRO for standards |
*/ |
#include "fdlibm.h" |
/* |
* define and initialize _LIB_VERSION |
*/ |
#ifdef _POSIX_MODE |
_LIB_VERSION_TYPE _LIB_VERSION = _POSIX_; |
#else |
#ifdef _XOPEN_MODE |
_LIB_VERSION_TYPE _LIB_VERSION = _XOPEN_; |
#else |
#ifdef _SVID3_MODE |
_LIB_VERSION_TYPE _LIB_VERSION = _SVID_; |
#else /* default _IEEE_MODE */ |
_LIB_VERSION_TYPE _LIB_VERSION = _IEEE_; |
#endif |
#endif |
#endif |
/contrib/sdk/sources/libc/math/s_llrint.c |
---|
0,0 → 1,124 |
/* lrint adapted to be llrint for Newlib, 2009 by Craig Howland. */ |
/* @(#)s_lrint.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* llrint(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using floating addition. |
* Exception: |
* Inexact flag raised if x not equal to llrint(x). |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
/* Adding a double, x, to 2^52 will cause the result to be rounded based on |
the fractional part of x, according to the implementation's current rounding |
mode. 2^52 is the smallest double that can be represented using all 52 significant |
digits. */ |
TWO52[2]={ |
4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ |
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ |
}; |
long long int |
#ifdef __STDC__ |
llrint(double x) |
#else |
llrint(x) |
double x; |
#endif |
{ |
__int32_t i0,j0,sx; |
__uint32_t i1; |
double t; |
volatile double w; |
long long int result; |
EXTRACT_WORDS(i0,i1,x); |
/* Extract sign bit. */ |
sx = (i0>>31)&1; |
/* Extract exponent field. */ |
j0 = ((i0 & 0x7ff00000) >> 20) - 1023; |
/* j0 in [-1023,1024] */ |
if(j0 < 20) |
{ |
/* j0 in [-1023,19] */ |
if(j0 < -1) |
return 0; |
else |
{ |
/* j0 in [0,19] */ |
/* shift amt in [0,19] */ |
w = TWO52[sx] + x; |
t = w - TWO52[sx]; |
GET_HIGH_WORD(i0, t); |
/* Detect the all-zeros representation of plus and |
minus zero, which fails the calculation below. */ |
if ((i0 & ~((__int32_t)1 << 31)) == 0) |
return 0; |
/* After round: j0 in [0,20] */ |
j0 = ((i0 & 0x7ff00000) >> 20) - 1023; |
i0 &= 0x000fffff; |
i0 |= 0x00100000; |
/* shift amt in [20,0] */ |
result = i0 >> (20 - j0); |
} |
} |
else if (j0 < (int)(8 * sizeof (long long int)) - 1) |
{ |
/* 64bit return: j0 in [20,62] */ |
if (j0 >= 52) |
/* 64bit return: j0 in [52,62] */ |
/* 64bit return: left shift amt in [32,42] */ |
result = ((long long int) ((i0 & 0x000fffff) | 0x0010000) << (j0 - 20)) | |
/* 64bit return: right shift amt in [0,10] */ |
(i1 << (j0 - 52)); |
else |
{ |
/* 64bit return: j0 in [20,51] */ |
w = TWO52[sx] + x; |
t = w - TWO52[sx]; |
EXTRACT_WORDS (i0, i1, t); |
j0 = ((i0 & 0x7ff00000) >> 20) - 1023; |
i0 &= 0x000fffff; |
i0 |= 0x00100000; |
/* After round: |
* 64bit return: j0 in [20,52] */ |
/* 64bit return: left shift amt in [0,32] */ |
/* ***64bit return: right shift amt in [32,0] */ |
result = ((long long int) i0 << (j0 - 20)) |
| SAFE_RIGHT_SHIFT (i1, (52 - j0)); |
} |
} |
else |
{ |
return (long long int) x; |
} |
return sx ? -result : result; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_llround.c |
---|
0,0 → 1,84 |
/* lround adapted to be llround for Newlib, 2009 by Craig Howland. */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
long long int |
llround(double x) |
{ |
__int32_t sign, exponent_less_1023; |
/* Most significant word, least significant word. */ |
__uint32_t msw, lsw; |
long long int result; |
EXTRACT_WORDS(msw, lsw, x); |
/* Extract sign. */ |
sign = ((msw & 0x80000000) ? -1 : 1); |
/* Extract exponent field. */ |
exponent_less_1023 = ((msw & 0x7ff00000) >> 20) - 1023; |
msw &= 0x000fffff; |
msw |= 0x00100000; |
/* exponent_less_1023 in [-1023,1024] */ |
if (exponent_less_1023 < 20) |
{ |
/* exponent_less_1023 in [-1023,19] */ |
if (exponent_less_1023 < 0) |
{ |
if (exponent_less_1023 < -1) |
return 0; |
else |
return sign; |
} |
else |
{ |
/* exponent_less_1023 in [0,19] */ |
/* shift amt in [0,19] */ |
msw += 0x80000 >> exponent_less_1023; |
/* shift amt in [20,1] */ |
result = msw >> (20 - exponent_less_1023); |
} |
} |
else if (exponent_less_1023 < (8 * sizeof (long long int)) - 1) |
{ |
/* 64bit longlong: exponent_less_1023 in [20,62] */ |
if (exponent_less_1023 >= 52) |
/* 64bit longlong: exponent_less_1023 in [52,62] */ |
/* 64bit longlong: shift amt in [32,42] */ |
result = ((long long int) msw << (exponent_less_1023 - 20)) |
/* 64bit longlong: shift amt in [0,10] */ |
| (lsw << (exponent_less_1023 - 52)); |
else |
{ |
/* 64bit longlong: exponent_less_1023 in [20,51] */ |
unsigned int tmp = lsw |
/* 64bit longlong: shift amt in [0,31] */ |
+ (0x80000000 >> (exponent_less_1023 - 20)); |
if (tmp < lsw) |
++msw; |
/* 64bit longlong: shift amt in [0,31] */ |
result = ((long long int) msw << (exponent_less_1023 - 20)) |
/* ***64bit longlong: shift amt in [32,1] */ |
| SAFE_RIGHT_SHIFT (tmp, (52 - exponent_less_1023)); |
} |
} |
else |
/* Result is too large to be represented by a long long int. */ |
return (long long int)x; |
return sign * result; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_log1p.c |
---|
0,0 → 1,217 |
/* @(#)s_log1p.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<log1p>>, <<log1pf>>---log of <<1 + <[x]>>> |
INDEX |
log1p |
INDEX |
log1pf |
ANSI_SYNOPSIS |
#include <math.h> |
double log1p(double <[x]>); |
float log1pf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double log1p(<[x]>) |
double <[x]>; |
float log1pf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<log1p>> calculates |
@tex |
$ln(1+x)$, |
@end tex |
the natural logarithm of <<1+<[x]>>>. You can use <<log1p>> rather |
than `<<log(1+<[x]>)>>' for greater precision when <[x]> is very |
small. |
<<log1pf>> calculates the same thing, but accepts and returns |
<<float>> values rather than <<double>>. |
RETURNS |
<<log1p>> returns a <<double>>, the natural log of <<1+<[x]>>>. |
<<log1pf>> returns a <<float>>, the natural log of <<1+<[x]>>>. |
PORTABILITY |
Neither <<log1p>> nor <<log1pf>> is required by ANSI C or by the System V |
Interface Definition (Issue 2). |
*/ |
/* double log1p(double x) |
* |
* Method : |
* 1. Argument Reduction: find k and f such that |
* 1+x = 2^k * (1+f), |
* where sqrt(2)/2 < 1+f < sqrt(2) . |
* |
* Note. If k=0, then f=x is exact. However, if k!=0, then f |
* may not be representable exactly. In that case, a correction |
* term is need. Let u=1+x rounded. Let c = (1+x)-u, then |
* log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u), |
* and add back the correction term c/u. |
* (Note: when x > 2**53, one can simply return log(x)) |
* |
* 2. Approximation of log1p(f). |
* Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) |
* = 2s + 2/3 s**3 + 2/5 s**5 + ....., |
* = 2s + s*R |
* We use a special Reme algorithm on [0,0.1716] to generate |
* a polynomial of degree 14 to approximate R The maximum error |
* of this polynomial approximation is bounded by 2**-58.45. In |
* other words, |
* 2 4 6 8 10 12 14 |
* R(z) ~ Lp1*s +Lp2*s +Lp3*s +Lp4*s +Lp5*s +Lp6*s +Lp7*s |
* (the values of Lp1 to Lp7 are listed in the program) |
* and |
* | 2 14 | -58.45 |
* | Lp1*s +...+Lp7*s - R(z) | <= 2 |
* | | |
* Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. |
* In order to guarantee error in log below 1ulp, we compute log |
* by |
* log1p(f) = f - (hfsq - s*(hfsq+R)). |
* |
* 3. Finally, log1p(x) = k*ln2 + log1p(f). |
* = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo))) |
* Here ln2 is split into two floating point number: |
* ln2_hi + ln2_lo, |
* where n*ln2_hi is always exact for |n| < 2000. |
* |
* Special cases: |
* log1p(x) is NaN with signal if x < -1 (including -INF) ; |
* log1p(+INF) is +INF; log1p(-1) is -INF with signal; |
* log1p(NaN) is that NaN with no signal. |
* |
* Accuracy: |
* according to an error analysis, the error is always less than |
* 1 ulp (unit in the last place). |
* |
* Constants: |
* The hexadecimal values are the intended ones for the following |
* constants. The decimal values may be used, provided that the |
* compiler will convert from decimal to binary accurately enough |
* to produce the hexadecimal values shown. |
* |
* Note: Assuming log() return accurate answer, the following |
* algorithm can be used to compute log1p(x) to within a few ULP: |
* |
* u = 1+x; |
* if(u==1.0) return x ; else |
* return log(u)*(x/(u-1.0)); |
* |
* See HP-15C Advanced Functions Handbook, p.193. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ |
ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ |
two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ |
Lp1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ |
Lp2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ |
Lp3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ |
Lp4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ |
Lp5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ |
Lp6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ |
Lp7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ |
#ifdef __STDC__ |
static const double zero = 0.0; |
#else |
static double zero = 0.0; |
#endif |
#ifdef __STDC__ |
double log1p(double x) |
#else |
double log1p(x) |
double x; |
#endif |
{ |
double hfsq,f,c,s,z,R,u; |
__int32_t k,hx,hu,ax; |
GET_HIGH_WORD(hx,x); |
ax = hx&0x7fffffff; |
k = 1; |
if (hx < 0x3FDA827A) { /* x < 0.41422 */ |
if(ax>=0x3ff00000) { /* x <= -1.0 */ |
if(x==-1.0) return -two54/zero; /* log1p(-1)=+inf */ |
else return (x-x)/(x-x); /* log1p(x<-1)=NaN */ |
} |
if(ax<0x3e200000) { /* |x| < 2**-29 */ |
if(two54+x>zero /* raise inexact */ |
&&ax<0x3c900000) /* |x| < 2**-54 */ |
return x; |
else |
return x - x*x*0.5; |
} |
if(hx>0||hx<=((__int32_t)0xbfd2bec3)) { |
k=0;f=x;hu=1;} /* -0.2929<x<0.41422 */ |
} |
if (hx >= 0x7ff00000) return x+x; |
if(k!=0) { |
if(hx<0x43400000) { |
u = 1.0+x; |
GET_HIGH_WORD(hu,u); |
k = (hu>>20)-1023; |
c = (k>0)? 1.0-(u-x):x-(u-1.0);/* correction term */ |
c /= u; |
} else { |
u = x; |
GET_HIGH_WORD(hu,u); |
k = (hu>>20)-1023; |
c = 0; |
} |
hu &= 0x000fffff; |
if(hu<0x6a09e) { |
SET_HIGH_WORD(u,hu|0x3ff00000); /* normalize u */ |
} else { |
k += 1; |
SET_HIGH_WORD(u,hu|0x3fe00000); /* normalize u/2 */ |
hu = (0x00100000-hu)>>2; |
} |
f = u-1.0; |
} |
hfsq=0.5*f*f; |
if(hu==0) { /* |f| < 2**-20 */ |
if(f==zero) { if(k==0) return zero; |
else {c += k*ln2_lo; return k*ln2_hi+c;}} |
R = hfsq*(1.0-0.66666666666666666*f); |
if(k==0) return f-R; else |
return k*ln2_hi-((R-(k*ln2_lo+c))-f); |
} |
s = f/(2.0+f); |
z = s*s; |
R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7)))))); |
if(k==0) return f-(hfsq-s*(hfsq+R)); else |
return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f); |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_log2.c |
---|
0,0 → 1,85 |
/* @(#)s_log2.c 5.1 93/09/24 */ |
/* Modification from s_exp10.c Yaakov Selkowitz 2009. */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<log2>>, <<log2f>>--base 2 logarithm |
INDEX |
log2 |
INDEX |
log2f |
ANSI_SYNOPSIS |
#include <math.h> |
double log2(double <[x]>); |
float log2f(float <[x]>); |
DESCRIPTION |
The <<log2>> functions compute the base-2 logarithm of <[x]>. A domain error |
occurs if the argument is less than zero. A range error occurs if the |
argument is zero. |
The Newlib implementations are not full, intrinisic calculations, but |
rather are derivatives based on <<log>>. (Accuracy might be slightly off from |
a direct calculation.) In addition to functions, they are also implemented as |
macros defined in math.h: |
. #define log2(x) (log (x) / _M_LN2) |
. #define log2f(x) (logf (x) / (float) _M_LN2) |
To use the functions instead, just undefine the macros first. |
You can use the (non-ANSI) function <<matherr>> to specify error |
handling for these functions, indirectly through the respective <<log>> |
function. |
RETURNS |
The <<log2>> functions return |
@ifnottex |
<<log base-2(<[x]>)>> |
@end ifnottex |
@tex |
$log_2(x)$ |
@end tex |
on success. |
When <[x]> is zero, the |
returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>. |
When <[x]> is negative, the returned value is NaN (not a number) and |
<<errno>> is set to <<EDOM>>. You can control the error behavior via |
<<matherr>>. |
PORTABILITY |
C99, POSIX, System V Interface Definition (Issue 6). |
*/ |
/* |
* wrapper log2(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#include <math.h> |
#undef log2 |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double log2(double x) /* wrapper log2 */ |
#else |
double log2(x) /* wrapper log2 */ |
double x; |
#endif |
{ |
return (log(x) / M_LN2); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/s_logb.c |
---|
0,0 → 1,110 |
/* 2009 for Newlib: Sun's s_ilogb.c converted to be s_logb.c. */ |
/* @(#)s_ilogb.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<logb>>, <<logbf>>--get exponent of floating-point number |
INDEX |
logb |
INDEX |
logbf |
ANSI_SYNOPSIS |
#include <math.h> |
double logb(double <[x]>); |
float logbf(float <[x]>); |
DESCRIPTION |
The <<logb>> functions extract the exponent of <[x]>, as a signed integer value |
in floating-point format. If <[x]> is subnormal it is treated as though it were |
normalized; thus, for positive finite <[x]>, |
@ifnottex |
1 <= (<[x]> * FLT_RADIX to the power (-logb(<[x]>))) < FLT_RADIX. |
@end ifnottex |
@tex |
$1 \leq ( x \cdot FLT\_RADIX ^ {-logb(x)} ) < FLT\_RADIX$. |
@end tex |
A domain error may occur if the argument is zero. |
In this floating-point implementation, FLT_RADIX is 2. Which also means |
that for finite <[x]>, <<logb>>(<[x]>) = <<floor>>(<<log2>>(<<fabs>>(<[x]>))). |
All nonzero, normal numbers can be described as |
@ifnottex |
<[m]> * 2**<[p]>, where 1.0 <= <[m]> < 2.0. |
@end ifnottex |
@tex |
$m \cdot 2^p$, where $1.0 \leq m < 2.0$. |
@end tex |
The <<logb>> functions examine the argument <[x]>, and return <[p]>. |
The <<frexp>> functions are similar to the <<logb>> functions, but |
returning <[m]> adjusted to the interval [.5, 1) or 0, and <[p]>+1. |
RETURNS |
@comment Formatting note: "$@" forces a new line |
When <[x]> is:@* |
+inf or -inf, +inf is returned;@* |
NaN, NaN is returned;@* |
0, -inf is returned, and the divide-by-zero exception is raised;@* |
otherwise, the <<logb>> functions return the signed exponent of <[x]>. |
PORTABILITY |
ANSI C, POSIX |
SEEALSO |
frexp, ilogb |
*/ |
/* double logb(double x) |
* return the binary exponent of non-zero x |
* logb(0) = -inf, raise divide-by-zero floating point exception |
* logb(+inf|-inf) = +inf (no signal is raised) |
* logb(NaN) = NaN (no signal is raised) |
* Per C99 recommendation, a NaN argument is returned unchanged. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
double |
#ifdef __STDC__ |
logb(double x) |
#else |
logb(x) |
double x; |
#endif |
{ |
__int32_t hx,lx,ix; |
EXTRACT_WORDS(hx,lx,x); |
hx &= 0x7fffffff; /* high |x| */ |
if(hx<0x00100000) { /* 0 or subnormal */ |
if((hx|lx)==0) { |
double xx; |
/* arg==0: return -inf and raise divide-by-zero exception */ |
INSERT_WORDS(xx,hx,lx); /* +0.0 */ |
return -1./xx; /* logb(0) = -inf */ |
} |
else /* subnormal x */ |
if(hx==0) { |
for (ix = -1043; lx>0; lx<<=1) ix -=1; |
} else { |
for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1; |
} |
return (double) ix; |
} |
else if (hx<0x7ff00000) return (hx>>20)-1023; /* normal # */ |
else if (hx>0x7ff00000 || lx) return x; /* x==NaN */ |
else return HUGE_VAL; /* x==inf (+ or -) */ |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_lrint.c |
---|
0,0 → 1,166 |
/* @(#)s_lrint.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<lrint>>, <<lrintf>>, <<llrint>>, <<llrintf>>--round to integer |
INDEX |
lrint |
INDEX |
lrintf |
INDEX |
llrint |
INDEX |
llrintf |
ANSI_SYNOPSIS |
#include <math.h> |
long int lrint(double <[x]>); |
long int lrintf(float <[x]>); |
long long int llrint(double <[x]>); |
long long int llrintf(float <[x]>); |
DESCRIPTION |
The <<lrint>> and <<llrint>> functions round their argument to the nearest |
integer value, using the current rounding direction. If the rounded value is |
outside the range of the return type, the numeric result is unspecified. A |
range error may occur if the magnitude of <[x]> is too large. |
The "inexact" floating-point exception is raised in implementations that |
support it when the result differs in value from the argument (i.e., when |
a fraction actually has been truncated). |
RETURNS |
<[x]> rounded to an integral value, using the current rounding direction. |
SEEALSO |
<<lround>> |
PORTABILITY |
ANSI C, POSIX |
*/ |
/* |
* lrint(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using floating addition. |
* Exception: |
* Inexact flag raised if x not equal to lrint(x). |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
/* Adding a double, x, to 2^52 will cause the result to be rounded based on |
the fractional part of x, according to the implementation's current rounding |
mode. 2^52 is the smallest double that can be represented using all 52 significant |
digits. */ |
TWO52[2]={ |
4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ |
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ |
}; |
#ifdef __STDC__ |
long int lrint(double x) |
#else |
long int lrint(x) |
double x; |
#endif |
{ |
__int32_t i0,j0,sx; |
__uint32_t i1; |
double t; |
volatile double w; |
long int result; |
EXTRACT_WORDS(i0,i1,x); |
/* Extract sign bit. */ |
sx = (i0>>31)&1; |
/* Extract exponent field. */ |
j0 = ((i0 & 0x7ff00000) >> 20) - 1023; |
/* j0 in [-1023,1024] */ |
if(j0 < 20) |
{ |
/* j0 in [-1023,19] */ |
if(j0 < -1) |
return 0; |
else |
{ |
/* j0 in [0,19] */ |
/* shift amt in [0,19] */ |
w = TWO52[sx] + x; |
t = w - TWO52[sx]; |
GET_HIGH_WORD(i0, t); |
/* Detect the all-zeros representation of plus and |
minus zero, which fails the calculation below. */ |
if ((i0 & ~(1L << 31)) == 0) |
return 0; |
/* After round: j0 in [0,20] */ |
j0 = ((i0 & 0x7ff00000) >> 20) - 1023; |
i0 &= 0x000fffff; |
i0 |= 0x00100000; |
/* shift amt in [20,0] */ |
result = i0 >> (20 - j0); |
} |
} |
else if (j0 < (int)(8 * sizeof (long int)) - 1) |
{ |
/* 32bit return: j0 in [20,30] */ |
/* 64bit return: j0 in [20,62] */ |
if (j0 >= 52) |
/* 64bit return: j0 in [52,62] */ |
/* 64bit return: left shift amt in [32,42] */ |
result = ((long int) ((i0 & 0x000fffff) | 0x0010000) << (j0 - 20)) | |
/* 64bit return: right shift amt in [0,10] */ |
(i1 << (j0 - 52)); |
else |
{ |
/* 32bit return: j0 in [20,30] */ |
/* 64bit return: j0 in [20,51] */ |
w = TWO52[sx] + x; |
t = w - TWO52[sx]; |
EXTRACT_WORDS (i0, i1, t); |
j0 = ((i0 & 0x7ff00000) >> 20) - 1023; |
i0 &= 0x000fffff; |
i0 |= 0x00100000; |
/* After round: |
* 32bit return: j0 in [20,31]; |
* 64bit return: j0 in [20,52] */ |
/* 32bit return: left shift amt in [0,11] */ |
/* 64bit return: left shift amt in [0,32] */ |
/* ***32bit return: right shift amt in [32,21] */ |
/* ***64bit return: right shift amt in [32,0] */ |
result = ((long int) i0 << (j0 - 20)) |
| SAFE_RIGHT_SHIFT (i1, (52 - j0)); |
} |
} |
else |
{ |
return (long int) x; |
} |
return sx ? -result : result; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_lround.c |
---|
0,0 → 1,129 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<lround>>, <<lroundf>>, <<llround>>, <<llroundf>>--round to integer, to nearest |
INDEX |
lround |
INDEX |
lroundf |
INDEX |
llround |
INDEX |
llroundf |
ANSI_SYNOPSIS |
#include <math.h> |
long int lround(double <[x]>); |
long int lroundf(float <[x]>); |
long long int llround(double <[x]>); |
long long int llroundf(float <[x]>); |
DESCRIPTION |
The <<lround>> and <<llround>> functions round their argument to the |
nearest integer value, rounding halfway cases away from zero, regardless |
of the current rounding direction. If the rounded value is outside the |
range of the return type, the numeric result is unspecified (depending |
upon the floating-point implementation, not the library). A range |
error may occur if the magnitude of x is too large. |
RETURNS |
<[x]> rounded to an integral value as an integer. |
SEEALSO |
See the <<round>> functions for the return being the same floating-point type |
as the argument. <<lrint>>, <<llrint>>. |
PORTABILITY |
ANSI C, POSIX |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
long int lround(double x) |
#else |
long int lround(x) |
double x; |
#endif |
{ |
__int32_t sign, exponent_less_1023; |
/* Most significant word, least significant word. */ |
__uint32_t msw, lsw; |
long int result; |
EXTRACT_WORDS(msw, lsw, x); |
/* Extract sign. */ |
sign = ((msw & 0x80000000) ? -1 : 1); |
/* Extract exponent field. */ |
exponent_less_1023 = ((msw & 0x7ff00000) >> 20) - 1023; |
msw &= 0x000fffff; |
msw |= 0x00100000; |
/* exponent_less_1023 in [-1023,1024] */ |
if (exponent_less_1023 < 20) |
{ |
/* exponent_less_1023 in [-1023,19] */ |
if (exponent_less_1023 < 0) |
{ |
if (exponent_less_1023 < -1) |
return 0; |
else |
return sign; |
} |
else |
{ |
/* exponent_less_1023 in [0,19] */ |
/* shift amt in [0,19] */ |
msw += 0x80000 >> exponent_less_1023; |
/* shift amt in [20,1] */ |
result = msw >> (20 - exponent_less_1023); |
} |
} |
else if (exponent_less_1023 < (8 * sizeof (long int)) - 1) |
{ |
/* 32bit long: exponent_less_1023 in [20,30] */ |
/* 64bit long: exponent_less_1023 in [20,62] */ |
if (exponent_less_1023 >= 52) |
/* 64bit long: exponent_less_1023 in [52,62] */ |
/* 64bit long: shift amt in [32,42] */ |
result = ((long int) msw << (exponent_less_1023 - 20)) |
/* 64bit long: shift amt in [0,10] */ |
| (lsw << (exponent_less_1023 - 52)); |
else |
{ |
/* 32bit long: exponent_less_1023 in [20,30] */ |
/* 64bit long: exponent_less_1023 in [20,51] */ |
unsigned int tmp = lsw |
/* 32bit long: shift amt in [0,10] */ |
/* 64bit long: shift amt in [0,31] */ |
+ (0x80000000 >> (exponent_less_1023 - 20)); |
if (tmp < lsw) |
++msw; |
/* 32bit long: shift amt in [0,10] */ |
/* 64bit long: shift amt in [0,31] */ |
result = ((long int) msw << (exponent_less_1023 - 20)) |
/* ***32bit long: shift amt in [32,22] */ |
/* ***64bit long: shift amt in [32,1] */ |
| SAFE_RIGHT_SHIFT (tmp, (52 - exponent_less_1023)); |
} |
} |
else |
/* Result is too large to be represented by a long int. */ |
return (long int)x; |
return sign * result; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_matherr.c |
---|
0,0 → 1,123 |
/* @(#)s_matherr.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<matherr>>---modifiable math error handler |
INDEX |
matherr |
ANSI_SYNOPSIS |
#include <math.h> |
int matherr(struct exception *<[e]>); |
TRAD_SYNOPSIS |
#include <math.h> |
int matherr(*<[e]>) |
struct exception *<[e]>; |
DESCRIPTION |
<<matherr>> is called whenever a math library function generates an error. |
You can replace <<matherr>> by your own subroutine to customize |
error treatment. The customized <<matherr>> must return 0 if |
it fails to resolve the error, and non-zero if the error is resolved. |
When <<matherr>> returns a nonzero value, no error message is printed |
and the value of <<errno>> is not modified. You can accomplish either |
or both of these things in your own <<matherr>> using the information |
passed in the structure <<*<[e]>>>. |
This is the <<exception>> structure (defined in `<<math.h>>'): |
. struct exception { |
. int type; |
. char *name; |
. double arg1, arg2, retval; |
. int err; |
. }; |
The members of the exception structure have the following meanings: |
o+ |
o type |
The type of mathematical error that occured; macros encoding error |
types are also defined in `<<math.h>>'. |
o name |
a pointer to a null-terminated string holding the |
name of the math library function where the error occurred. |
o arg1, arg2 |
The arguments which caused the error. |
o retval |
The error return value (what the calling function will return). |
o err |
If set to be non-zero, this is the new value assigned to <<errno>>. |
o- |
The error types defined in `<<math.h>>' represent possible mathematical |
errors as follows: |
o+ |
o DOMAIN |
An argument was not in the domain of the function; e.g. <<log(-1.0)>>. |
o SING |
The requested calculation would result in a singularity; e.g. <<pow(0.0,-2.0)>> |
o OVERFLOW |
A calculation would produce a result too large to represent; e.g. |
<<exp(1000.0)>>. |
o UNDERFLOW |
A calculation would produce a result too small to represent; e.g. |
<<exp(-1000.0)>>. |
o TLOSS |
Total loss of precision. The result would have no significant digits; |
e.g. <<sin(10e70)>>. |
o PLOSS |
Partial loss of precision. |
o- |
RETURNS |
The library definition for <<matherr>> returns <<0>> in all cases. |
You can change the calling function's result from a customized <<matherr>> |
by modifying <<e->retval>>, which propagates backs to the caller. |
If <<matherr>> returns <<0>> (indicating that it was not able to resolve |
the error) the caller sets <<errno>> to an appropriate value, and prints |
an error message. |
PORTABILITY |
<<matherr>> is not ANSI C. |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
int matherr(struct exception *x) |
#else |
int matherr(x) |
struct exception *x; |
#endif |
{ |
int n=0; |
if(x->arg1!=x->arg1) return 0; |
return n; |
} |
/contrib/sdk/sources/libc/math/s_modf.c |
---|
0,0 → 1,131 |
/* @(#)s_modf.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<modf>>, <<modff>>---split fractional and integer parts |
INDEX |
modf |
INDEX |
modff |
ANSI_SYNOPSIS |
#include <math.h> |
double modf(double <[val]>, double *<[ipart]>); |
float modff(float <[val]>, float *<[ipart]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double modf(<[val]>, <[ipart]>) |
double <[val]>; |
double *<[ipart]>; |
float modff(<[val]>, <[ipart]>) |
float <[val]>; |
float *<[ipart]>; |
DESCRIPTION |
<<modf>> splits the double <[val]> apart into an integer part |
and a fractional part, returning the fractional part and |
storing the integer part in <<*<[ipart]>>>. No rounding |
whatsoever is done; the sum of the integer and fractional |
parts is guaranteed to be exactly equal to <[val]>. That |
is, if <[realpart]> = modf(<[val]>, &<[intpart]>); then |
`<<<[realpart]>+<[intpart]>>>' is the same as <[val]>. |
<<modff>> is identical, save that it takes and returns |
<<float>> rather than <<double>> values. |
RETURNS |
The fractional part is returned. Each result has the same |
sign as the supplied argument <[val]>. |
PORTABILITY |
<<modf>> is ANSI C. <<modff>> is an extension. |
QUICKREF |
modf ansi pure |
modff - pure |
*/ |
/* |
* modf(double x, double *iptr) |
* return fraction part of x, and return x's integral part in *iptr. |
* Method: |
* Bit twiddling. |
* |
* Exception: |
* No exception. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double one = 1.0; |
#else |
static double one = 1.0; |
#endif |
#ifdef __STDC__ |
double modf(double x, double *iptr) |
#else |
double modf(x, iptr) |
double x,*iptr; |
#endif |
{ |
__int32_t i0,i1,j0; |
__uint32_t i; |
EXTRACT_WORDS(i0,i1,x); |
j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */ |
if(j0<20) { /* integer part in high x */ |
if(j0<0) { /* |x|<1 */ |
INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */ |
return x; |
} else { |
i = (0x000fffff)>>j0; |
if(((i0&i)|i1)==0) { /* x is integral */ |
__uint32_t high; |
*iptr = x; |
GET_HIGH_WORD(high,x); |
INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ |
return x; |
} else { |
INSERT_WORDS(*iptr,i0&(~i),0); |
return x - *iptr; |
} |
} |
} else if (j0>51) { /* no fraction part */ |
__uint32_t high; |
*iptr = x*one; |
GET_HIGH_WORD(high,x); |
INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ |
return x; |
} else { /* fraction part in low x */ |
i = ((__uint32_t)(0xffffffff))>>(j0-20); |
if((i1&i)==0) { /* x is integral */ |
__uint32_t high; |
*iptr = x; |
GET_HIGH_WORD(high,x); |
INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ |
return x; |
} else { |
INSERT_WORDS(*iptr,i0,i1&(~i)); |
return x - *iptr; |
} |
} |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_nan.c |
---|
0,0 → 1,48 |
/* |
* nan () returns a nan. |
* Added by Cygnus Support. |
*/ |
/* |
FUNCTION |
<<nan>>, <<nanf>>---representation of ``Not a Number'' |
INDEX |
nan |
INDEX |
nanf |
ANSI_SYNOPSIS |
#include <math.h> |
double nan(const char *); |
float nanf(const char *); |
TRAD_SYNOPSIS |
#include <math.h> |
double nan(); |
float nanf(); |
DESCRIPTION |
<<nan>> and <<nanf>> return an IEEE NaN (Not a Number) in |
double- and single-precision arithmetic respectively. The |
argument is currently disregarded. |
QUICKREF |
nan - pure |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
double nan(const char *unused) |
{ |
double x; |
INSERT_WORDS(x,0x7ff80000,0); |
return x; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_nearbyint.c |
---|
0,0 → 1,64 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<nearbyint>>, <<nearbyintf>>--round to integer |
INDEX |
nearbyint |
INDEX |
nearbyintf |
ANSI_SYNOPSIS |
#include <math.h> |
double nearbyint(double <[x]>); |
float nearbyintf(float <[x]>); |
DESCRIPTION |
The <<nearbyint>> functions round their argument to an integer value in |
floating-point format, using the current rounding direction and |
(supposedly) without raising the "inexact" floating-point exception. |
See the <<rint>> functions for the same function with the "inexact" |
floating-point exception being raised when appropriate. |
BUGS |
Newlib does not support the floating-point exception model, so that |
the floating-point exception control is not present and thereby what may |
be seen will be compiler and hardware dependent in this regard. |
The Newlib <<nearbyint>> functions are identical to the <<rint>> |
functions with respect to the floating-point exception behavior, and |
will cause the "inexact" exception to be raised for most targets. |
RETURNS |
<[x]> rounded to an integral value, using the current rounding direction. |
PORTABILITY |
ANSI C, POSIX |
SEEALSO |
<<rint>>, <<round>> |
*/ |
#include <math.h> |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double nearbyint(double x) |
#else |
double nearbyint(x) |
double x; |
#endif |
{ |
return rint(x); |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_nextafter.c |
---|
0,0 → 1,121 |
/* @(#)s_nextafter.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<nextafter>>, <<nextafterf>>---get next number |
INDEX |
nextafter |
INDEX |
nextafterf |
ANSI_SYNOPSIS |
#include <math.h> |
double nextafter(double <[val]>, double <[dir]>); |
float nextafterf(float <[val]>, float <[dir]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double nextafter(<[val]>, <[dir]>) |
double <[val]>; |
double <[exp]>; |
float nextafter(<[val]>, <[dir]>) |
float <[val]>; |
float <[dir]>; |
DESCRIPTION |
<<nextafter>> returns the double-precision floating-point number |
closest to <[val]> in the direction toward <[dir]>. <<nextafterf>> |
performs the same operation in single precision. For example, |
<<nextafter(0.0,1.0)>> returns the smallest positive number which is |
representable in double precision. |
RETURNS |
Returns the next closest number to <[val]> in the direction toward |
<[dir]>. |
PORTABILITY |
Neither <<nextafter>> nor <<nextafterf>> is required by ANSI C |
or by the System V Interface Definition (Issue 2). |
*/ |
/* IEEE functions |
* nextafter(x,y) |
* return the next machine floating-point number of x in the |
* direction toward y. |
* Special cases: |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double nextafter(double x, double y) |
#else |
double nextafter(x,y) |
double x,y; |
#endif |
{ |
__int32_t hx,hy,ix,iy; |
__uint32_t lx,ly; |
EXTRACT_WORDS(hx,lx,x); |
EXTRACT_WORDS(hy,ly,y); |
ix = hx&0x7fffffff; /* |x| */ |
iy = hy&0x7fffffff; /* |y| */ |
if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */ |
((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) /* y is nan */ |
return x+y; |
if(x==y) return x; /* x=y, return x */ |
if((ix|lx)==0) { /* x == 0 */ |
INSERT_WORDS(x,hy&0x80000000,1); /* return +-minsubnormal */ |
y = x*x; |
if(y==x) return y; else return x; /* raise underflow flag */ |
} |
if(hx>=0) { /* x > 0 */ |
if(hx>hy||((hx==hy)&&(lx>ly))) { /* x > y, x -= ulp */ |
if(lx==0) hx -= 1; |
lx -= 1; |
} else { /* x < y, x += ulp */ |
lx += 1; |
if(lx==0) hx += 1; |
} |
} else { /* x < 0 */ |
if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){/* x < y, x -= ulp */ |
if(lx==0) hx -= 1; |
lx -= 1; |
} else { /* x > y, x += ulp */ |
lx += 1; |
if(lx==0) hx += 1; |
} |
} |
hy = hx&0x7ff00000; |
if(hy>=0x7ff00000) return x+x; /* overflow */ |
if(hy<0x00100000) { /* underflow */ |
y = x*x; |
if(y!=x) { /* raise underflow flag */ |
INSERT_WORDS(y,hx,lx); |
return y; |
} |
} |
INSERT_WORDS(x,hx,lx); |
return x; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_pow10.c |
---|
0,0 → 1,79 |
/* @(#)s_pow10.c 5.1 93/09/24 */ |
/* Modification from s_exp10.c Yaakov Selkowitz 2007. */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<pow10>>, <<pow10f>>---exponential |
INDEX |
pow10 |
INDEX |
pow10f |
ANSI_SYNOPSIS |
#include <math.h> |
double pow10(double <[x]>); |
float pow10f(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double pow10(<[x]>); |
double <[x]>; |
float pow10f(<[x]>); |
float <[x]>; |
DESCRIPTION |
<<pow10>> and <<pow10f>> calculate 10 ^ <[x]>, that is, |
@ifnottex |
10 raised to the power <[x]>. |
@end ifnottex |
@tex |
$10^x$ |
@end tex |
You can use the (non-ANSI) function <<matherr>> to specify |
error handling for these functions. |
RETURNS |
On success, <<pow10>> and <<pow10f>> return the calculated value. |
If the result underflows, the returned value is <<0>>. If the |
result overflows, the returned value is <<HUGE_VAL>>. In |
either case, <<errno>> is set to <<ERANGE>>. |
PORTABILITY |
<<pow10>> and <<pow10f>> are GNU extensions. |
*/ |
/* |
* wrapper pow10(x) |
*/ |
#undef pow10 |
#include "fdlibm.h" |
#include <errno.h> |
#include <math.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double pow10(double x) /* wrapper pow10 */ |
#else |
double pow10(x) /* wrapper pow10 */ |
double x; |
#endif |
{ |
return pow(10.0, x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/s_remquo.c |
---|
0,0 → 1,208 |
/* Adapted for Newlib, 2009. (Allow for int < 32 bits; return *quo=0 during |
* errors to make test scripts easier.) */ |
/* @(#)e_fmod.c 1.3 95/01/18 */ |
/*- |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunSoft, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<remquo>>, <<remquof>>--remainder and part of quotient |
INDEX |
remquo |
INDEX |
remquof |
ANSI_SYNOPSIS |
#include <math.h> |
double remquo(double <[x]>, double <[y]>, int *<[quo]>); |
float remquof(float <[x]>, float <[y]>, int *<[quo]>); |
DESCRIPTION |
The <<remquo>> functions compute the same remainder as the <<remainder>> |
functions; this value is in the range -<[y]>/2 ... +<[y]>/2. In the object |
pointed to by <<quo>> they store a value whose sign is the sign of <<x>>/<<y>> |
and whose magnitude is congruent modulo 2**n to the magnitude of the integral |
quotient of <<x>>/<<y>>. (That is, <<quo>> is given the n lsbs of the |
quotient, not counting the sign.) This implementation uses n=31 if int is 32 |
bits or more, otherwise, n is 1 less than the width of int. |
For example: |
. remquo(-29.0, 3.0, &<[quo]>) |
returns -1.0 and sets <[quo]>=10, and |
. remquo(-98307.0, 3.0, &<[quo]>) |
returns -0.0 and sets <[quo]>=-32769, although for 16-bit int, <[quo]>=-1. In |
the latter case, the actual quotient of -(32769=0x8001) is reduced to -1 |
because of the 15-bit limitation for the quotient. |
RETURNS |
When either argument is NaN, NaN is returned. If <[y]> is 0 or <[x]> is |
infinite (and neither is NaN), a domain error occurs (i.e. the "invalid" |
floating point exception is raised or errno is set to EDOM), and NaN is |
returned. |
Otherwise, the <<remquo>> functions return <[x]> REM <[y]>. |
BUGS |
IEEE754-2008 calls for <<remquo>>(subnormal, inf) to cause the "underflow" |
floating-point exception. This implementation does not. |
PORTABILITY |
C99, POSIX. |
*/ |
#include <limits.h> |
#include <math.h> |
#include "fdlibm.h" |
/* For quotient, return either all 31 bits that can from calculation (using |
* int32_t), or as many as can fit into an int that is smaller than 32 bits. */ |
#if INT_MAX > 0x7FFFFFFFL |
#define QUO_MASK 0x7FFFFFFF |
# else |
#define QUO_MASK INT_MAX |
#endif |
static const double Zero[] = {0.0, -0.0,}; |
/* |
* Return the IEEE remainder and set *quo to the last n bits of the |
* quotient, rounded to the nearest integer. We choose n=31--if that many fit-- |
* because we wind up computing all the integer bits of the quotient anyway as |
* a side-effect of computing the remainder by the shift and subtract |
* method. In practice, this is far more bits than are needed to use |
* remquo in reduction algorithms. |
*/ |
double |
remquo(double x, double y, int *quo) |
{ |
__int32_t n,hx,hy,hz,ix,iy,sx,i; |
__uint32_t lx,ly,lz,q,sxy; |
EXTRACT_WORDS(hx,lx,x); |
EXTRACT_WORDS(hy,ly,y); |
sxy = (hx ^ hy) & 0x80000000; |
sx = hx&0x80000000; /* sign of x */ |
hx ^=sx; /* |x| */ |
hy &= 0x7fffffff; /* |y| */ |
/* purge off exception values */ |
if((hy|ly)==0||(hx>=0x7ff00000)|| /* y=0,or x not finite */ |
((hy|((ly|-ly)>>31))>0x7ff00000)) { /* or y is NaN */ |
*quo = 0; /* Not necessary, but return consistent value */ |
return (x*y)/(x*y); |
} |
if(hx<=hy) { |
if((hx<hy)||(lx<ly)) { |
q = 0; |
goto fixup; /* |x|<|y| return x or x-y */ |
} |
if(lx==ly) { |
*quo = (sxy ? -1 : 1); |
return Zero[(__uint32_t)sx>>31]; /* |x|=|y| return x*0 */ |
} |
} |
/* determine ix = ilogb(x) */ |
if(hx<0x00100000) { /* subnormal x */ |
if(hx==0) { |
for (ix = -1043, i=lx; i>0; i<<=1) ix -=1; |
} else { |
for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1; |
} |
} else ix = (hx>>20)-1023; |
/* determine iy = ilogb(y) */ |
if(hy<0x00100000) { /* subnormal y */ |
if(hy==0) { |
for (iy = -1043, i=ly; i>0; i<<=1) iy -=1; |
} else { |
for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1; |
} |
} else iy = (hy>>20)-1023; |
/* set up {hx,lx}, {hy,ly} and align y to x */ |
if(ix >= -1022) |
hx = 0x00100000|(0x000fffff&hx); |
else { /* subnormal x, shift x to normal */ |
n = -1022-ix; |
if(n<=31) { |
hx = (hx<<n)|(lx>>(32-n)); |
lx <<= n; |
} else { |
hx = lx<<(n-32); |
lx = 0; |
} |
} |
if(iy >= -1022) |
hy = 0x00100000|(0x000fffff&hy); |
else { /* subnormal y, shift y to normal */ |
n = -1022-iy; |
if(n<=31) { |
hy = (hy<<n)|(ly>>(32-n)); |
ly <<= n; |
} else { |
hy = ly<<(n-32); |
ly = 0; |
} |
} |
/* fix point fmod */ |
n = ix - iy; |
q = 0; |
while(n--) { |
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1; |
if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;} |
else {hx = hz+hz+(lz>>31); lx = lz+lz; q++;} |
q <<= 1; |
} |
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1; |
if(hz>=0) {hx=hz;lx=lz;q++;} |
/* convert back to floating value and restore the sign */ |
if((hx|lx)==0) { /* return sign(x)*0 */ |
q &= QUO_MASK; |
*quo = (sxy ? -q : q); |
return Zero[(__uint32_t)sx>>31]; |
} |
while(hx<0x00100000) { /* normalize x */ |
hx = hx+hx+(lx>>31); lx = lx+lx; |
iy -= 1; |
} |
if(iy>= -1022) { /* normalize output */ |
hx = ((hx-0x00100000)|((iy+1023)<<20)); |
} else { /* subnormal output */ |
n = -1022 - iy; |
if(n<=20) { |
lx = (lx>>n)|((__uint32_t)hx<<(32-n)); |
hx >>= n; |
} else if (n<=31) { |
lx = (hx<<(32-n))|(lx>>n); hx = sx; |
} else { |
lx = hx>>(n-32); hx = sx; |
} |
} |
fixup: |
INSERT_WORDS(x,hx,lx); |
y = fabs(y); |
if (y < 0x1p-1021) { |
if (x+x>y || (x+x==y && (q & 1))) { |
q++; |
x-=y; |
} |
} else if (x>0.5*y || (x==0.5*y && (q & 1))) { |
q++; |
x-=y; |
} |
GET_HIGH_WORD(hx,x); |
SET_HIGH_WORD(x,hx^sx); |
q &= QUO_MASK; |
*quo = (sxy ? -q : q); |
return x; |
} |
/contrib/sdk/sources/libc/math/s_rint.c |
---|
0,0 → 1,132 |
/* @(#)s_rint.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<rint>>, <<rintf>>--round to integer |
INDEX |
rint |
INDEX |
rintf |
ANSI_SYNOPSIS |
#include <math.h> |
double rint(double <[x]>); |
float rintf(float <[x]>); |
DESCRIPTION |
The <<rint>> functions round their argument to an integer value in |
floating-point format, using the current rounding direction. They |
raise the "inexact" floating-point exception if the result differs |
in value from the argument. See the <<nearbyint>> functions for the |
same function with the "inexact" floating-point exception never being |
raised. Newlib does not directly support floating-point exceptions. |
The <<rint>> functions are written so that the "inexact" exception is |
raised in hardware implementations that support it, even though Newlib |
does not provide access. |
RETURNS |
<[x]> rounded to an integral value, using the current rounding direction. |
PORTABILITY |
ANSI C, POSIX |
SEEALSO |
<<nearbyint>>, <<round>> |
*/ |
/* |
* rint(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using floating addition. |
* Whenever a fraction is present, if the second or any following bit after |
* the radix point is set, limit to the second radix point to avoid |
* possible double rounding in the TWO52 +- steps (in case guard bits are |
* used). Specifically, if have any, chop off bits past the 2nd place and |
* set the second place. |
* (e.g. 2.0625=0b10.0001 => 0b10.01=2.25; |
* 2.3125=0b10.011 => 0b10.01=2.25; |
* 1.5625= 0b1.1001 => 0b1.11=1.75; |
* 1.9375= 0b1.1111 => 0b1.11=1.75. |
* Pseudo-code: if(x.frac & ~0b0.10) x.frac = (x.frac & 0b0.11) | 0b0.01;). |
* Exception: |
* Inexact flag raised if x not equal to rint(x). |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
TWO52[2]={ |
4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ |
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ |
}; |
#ifdef __STDC__ |
double rint(double x) |
#else |
double rint(x) |
double x; |
#endif |
{ |
__int32_t i0,j0,sx; |
__uint32_t i,i1; |
double t; |
volatile double w; |
EXTRACT_WORDS(i0,i1,x); |
sx = (i0>>31)&1; /* sign */ |
j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent */ |
if(j0<20) { /* no integral bits in LS part */ |
if(j0<0) { /* x is fractional or 0 */ |
if(((i0&0x7fffffff)|i1)==0) return x; /* x == 0 */ |
i1 |= (i0&0x0fffff); |
i0 &= 0xfffe0000; |
i0 |= ((i1|-i1)>>12)&0x80000; |
SET_HIGH_WORD(x,i0); |
w = TWO52[sx]+x; |
t = w-TWO52[sx]; |
GET_HIGH_WORD(i0,t); |
SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31)); |
return t; |
} else { /* x has integer and maybe fraction */ |
i = (0x000fffff)>>j0; |
if(((i0&i)|i1)==0) return x; /* x is integral */ |
i>>=1; |
if(((i0&i)|i1)!=0) { |
/* 2nd or any later bit after radix is set */ |
if(j0==19) i1 = 0x80000000; else i1 = 0; |
i0 = (i0&(~i))|((0x40000)>>j0); |
} |
} |
} else if (j0>51) { |
if(j0==0x400) return x+x; /* inf or NaN */ |
else return x; /* x is integral */ |
} else { |
i = ((__uint32_t)(0xffffffff))>>(j0-20); |
if((i1&i)==0) return x; /* x is integral */ |
i>>=1; |
if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20)); |
} |
INSERT_WORDS(x,i0,i1); |
w = TWO52[sx]+x; |
return w-TWO52[sx]; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_round.c |
---|
0,0 → 1,115 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<round>>, <<roundf>>--round to integer, to nearest |
INDEX |
round |
INDEX |
roundf |
ANSI_SYNOPSIS |
#include <math.h> |
double round(double <[x]>); |
float roundf(float <[x]>); |
DESCRIPTION |
The <<round>> functions round their argument to the nearest integer |
value in floating-point format, rounding halfway cases away from zero, |
regardless of the current rounding direction. (While the "inexact" |
floating-point exception behavior is unspecified by the C standard, the |
<<round>> functions are written so that "inexact" is not raised if the |
result does not equal the argument, which behavior is as recommended by |
IEEE 754 for its related functions.) |
RETURNS |
<[x]> rounded to an integral value. |
PORTABILITY |
ANSI C, POSIX |
SEEALSO |
<<nearbyint>>, <<rint>> |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double round(double x) |
#else |
double round(x) |
double x; |
#endif |
{ |
/* Most significant word, least significant word. */ |
__int32_t msw, exponent_less_1023; |
__uint32_t lsw; |
EXTRACT_WORDS(msw, lsw, x); |
/* Extract exponent field. */ |
exponent_less_1023 = ((msw & 0x7ff00000) >> 20) - 1023; |
if (exponent_less_1023 < 20) |
{ |
if (exponent_less_1023 < 0) |
{ |
msw &= 0x80000000; |
if (exponent_less_1023 == -1) |
/* Result is +1.0 or -1.0. */ |
msw |= (1023 << 20); |
lsw = 0; |
} |
else |
{ |
__uint32_t exponent_mask = 0x000fffff >> exponent_less_1023; |
if ((msw & exponent_mask) == 0 && lsw == 0) |
/* x in an integral value. */ |
return x; |
msw += 0x00080000 >> exponent_less_1023; |
msw &= ~exponent_mask; |
lsw = 0; |
} |
} |
else if (exponent_less_1023 > 51) |
{ |
if (exponent_less_1023 == 1024) |
/* x is NaN or infinite. */ |
return x + x; |
else |
return x; |
} |
else |
{ |
__uint32_t exponent_mask = 0xffffffff >> (exponent_less_1023 - 20); |
__uint32_t tmp; |
if ((lsw & exponent_mask) == 0) |
/* x is an integral value. */ |
return x; |
tmp = lsw + (1 << (51 - exponent_less_1023)); |
if (tmp < lsw) |
msw += 1; |
lsw = tmp; |
lsw &= ~exponent_mask; |
} |
INSERT_WORDS(x, msw, lsw); |
return x; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_scalbln.c |
---|
0,0 → 1,64 |
/* @(#)s_scalbn.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* scalbn (double x, int n) |
* scalbn(x,n) returns x* 2**n computed by exponent |
* manipulation rather than by actually performing an |
* exponentiation or a multiplication. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ |
twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ |
huge = 1.0e+300, |
tiny = 1.0e-300; |
#ifdef __STDC__ |
double scalbln (double x, long int n) |
#else |
double scalbln (x,n) |
double x; long int n; |
#endif |
{ |
__int32_t k,hx,lx; |
EXTRACT_WORDS(hx,lx,x); |
k = (hx&0x7ff00000)>>20; /* extract exponent */ |
if (k==0) { /* 0 or subnormal x */ |
if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ |
x *= two54; |
GET_HIGH_WORD(hx,x); |
k = ((hx&0x7ff00000)>>20) - 54; |
} |
if (k==0x7ff) return x+x; /* NaN or Inf */ |
k = k+n; |
if (n> 50000 || k > 0x7fe) |
return huge*copysign(huge,x); /* overflow */ |
if (n< -50000) return tiny*copysign(tiny,x); /*underflow*/ |
if (k > 0) /* normal result */ |
{SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} |
if (k <= -54) |
return tiny*copysign(tiny,x); /*underflow*/ |
k += 54; /* subnormal result */ |
SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); |
return x*twom54; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_scalbn.c |
---|
0,0 → 1,110 |
/* @(#)s_scalbn.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<scalbn>>, <<scalbnf>>, <<scalbln>>, <<scalblnf>>--scale by power of FLT_RADIX (=2) |
INDEX |
scalbn |
INDEX |
scalbnf |
INDEX |
scalbln |
INDEX |
scalblnf |
ANSI_SYNOPSIS |
#include <math.h> |
double scalbn(double <[x]>, int <[n]>); |
float scalbnf(float <[x]>, int <[n]>); |
double scalbln(double <[x]>, long int <[n]>); |
float scalblnf(float <[x]>, long int <[n]>); |
DESCRIPTION |
The <<scalbn>> and <<scalbln>> functions compute |
@ifnottex |
<[x]> times FLT_RADIX to the power <[n]>. |
@end ifnottex |
@tex |
$x \cdot FLT\_RADIX^n$. |
@end tex |
efficiently. The result is computed by manipulating the exponent, rather than |
by actually performing an exponentiation or multiplication. In this |
floating-point implementation FLT_RADIX=2, which makes the <<scalbn>> |
functions equivalent to the <<ldexp>> functions. |
RETURNS |
<[x]> times 2 to the power <[n]>. A range error may occur. |
PORTABILITY |
ANSI C, POSIX |
SEEALSO |
<<ldexp>> |
*/ |
/* |
* scalbn (double x, int n) |
* scalbn(x,n) returns x* 2**n computed by exponent |
* manipulation rather than by actually performing an |
* exponentiation or a multiplication. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ |
twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ |
huge = 1.0e+300, |
tiny = 1.0e-300; |
#ifdef __STDC__ |
double scalbn (double x, int n) |
#else |
double scalbn (x,n) |
double x; int n; |
#endif |
{ |
__int32_t k,hx,lx; |
EXTRACT_WORDS(hx,lx,x); |
k = (hx&0x7ff00000)>>20; /* extract exponent */ |
if (k==0) { /* 0 or subnormal x */ |
if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ |
x *= two54; |
GET_HIGH_WORD(hx,x); |
k = ((hx&0x7ff00000)>>20) - 54; |
if (n< -50000) return tiny*x; /*underflow*/ |
} |
if (k==0x7ff) return x+x; /* NaN or Inf */ |
k = k+n; |
if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */ |
if (k > 0) /* normal result */ |
{SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} |
if (k <= -54) { |
if (n > 50000) /* in case integer overflow in n+k */ |
return huge*copysign(huge,x); /*overflow*/ |
else return tiny*copysign(tiny,x); /*underflow*/ |
} |
k += 54; /* subnormal result */ |
SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); |
return x*twom54; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_signbit.c |
---|
0,0 → 1,59 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* |
FUNCTION |
<<signbit>>--Does floating-point number have negative sign? |
INDEX |
signbit |
ANSI_SYNOPSIS |
#include <math.h> |
int signbit(real-floating <[x]>); |
DESCRIPTION |
The <<signbit>> macro determines whether the sign of its argument value is |
negative. The macro reports the sign of all values, including infinities, |
zeros, and NaNs. If zero is unsigned, it is treated as positive. As shown in |
the synopsis, the argument is "real-floating," meaning that any of the real |
floating-point types (float, double, etc.) may be given to it. |
Note that because of the possibilities of signed 0 and NaNs, the expression |
"<[x]> < 0.0" does not give the same result as <<signbit>> in all cases. |
RETURNS |
The <<signbit>> macro returns a nonzero value if and only if the sign of its |
argument value is negative. |
PORTABILITY |
C99, POSIX. |
*/ |
#include "fdlibm.h" |
int __signbitf (float x); |
int __signbitd (double x); |
int |
__signbitf (float x) |
{ |
unsigned int w; |
GET_FLOAT_WORD(w,x); |
return (w & 0x80000000); |
} |
int |
__signbitd (double x) |
{ |
unsigned int msw; |
GET_HIGH_WORD(msw, x); |
return (msw & 0x80000000); |
} |
/contrib/sdk/sources/libc/math/s_signif.c |
---|
0,0 → 1,34 |
/* @(#)s_signif.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* significand(x) computes just |
* scalb(x, (double) -ilogb(x)), |
* for exercising the fraction-part(F) IEEE 754-1985 test vector. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double significand(double x) |
#else |
double significand(x) |
double x; |
#endif |
{ |
return __ieee754_scalb(x,(double) -ilogb(x)); |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_sin.c |
---|
0,0 → 1,132 |
/* @(#)s_sin.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<sin>>, <<sinf>>, <<cos>>, <<cosf>>---sine or cosine |
INDEX |
sin |
INDEX |
sinf |
INDEX |
cos |
INDEX |
cosf |
ANSI_SYNOPSIS |
#include <math.h> |
double sin(double <[x]>); |
float sinf(float <[x]>); |
double cos(double <[x]>); |
float cosf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double sin(<[x]>) |
double <[x]>; |
float sinf(<[x]>) |
float <[x]>; |
double cos(<[x]>) |
double <[x]>; |
float cosf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<sin>> and <<cos>> compute (respectively) the sine and cosine |
of the argument <[x]>. Angles are specified in radians. |
<<sinf>> and <<cosf>> are identical, save that they take and |
return <<float>> values. |
RETURNS |
The sine or cosine of <[x]> is returned. |
PORTABILITY |
<<sin>> and <<cos>> are ANSI C. |
<<sinf>> and <<cosf>> are extensions. |
QUICKREF |
sin ansi pure |
sinf - pure |
*/ |
/* sin(x) |
* Return sine function of x. |
* |
* kernel function: |
* __kernel_sin ... sine function on [-pi/4,pi/4] |
* __kernel_cos ... cose function on [-pi/4,pi/4] |
* __ieee754_rem_pio2 ... argument reduction routine |
* |
* Method. |
* Let S,C and T denote the sin, cos and tan respectively on |
* [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 |
* in [-pi/4 , +pi/4], and let n = k mod 4. |
* We have |
* |
* n sin(x) cos(x) tan(x) |
* ---------------------------------------------------------- |
* 0 S C T |
* 1 C -S -1/T |
* 2 -S -C T |
* 3 -C S -1/T |
* ---------------------------------------------------------- |
* |
* Special cases: |
* Let trig be any of sin, cos, or tan. |
* trig(+-INF) is NaN, with signals; |
* trig(NaN) is that NaN; |
* |
* Accuracy: |
* TRIG(x) returns trig(x) nearly rounded |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double sin(double x) |
#else |
double sin(x) |
double x; |
#endif |
{ |
double y[2],z=0.0; |
__int32_t n,ix; |
/* High word of x. */ |
GET_HIGH_WORD(ix,x); |
/* |x| ~< pi/4 */ |
ix &= 0x7fffffff; |
if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); |
/* sin(Inf or NaN) is NaN */ |
else if (ix>=0x7ff00000) return x-x; |
/* argument reduction needed */ |
else { |
n = __ieee754_rem_pio2(x,y); |
switch(n&3) { |
case 0: return __kernel_sin(y[0],y[1],1); |
case 1: return __kernel_cos(y[0],y[1]); |
case 2: return -__kernel_sin(y[0],y[1],1); |
default: |
return -__kernel_cos(y[0],y[1]); |
} |
} |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_tan.c |
---|
0,0 → 1,114 |
/* @(#)s_tan.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<tan>>, <<tanf>>---tangent |
INDEX |
tan |
INDEX |
tanf |
ANSI_SYNOPSIS |
#include <math.h> |
double tan(double <[x]>); |
float tanf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double tan(<[x]>) |
double <[x]>; |
float tanf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<tan>> computes the tangent of the argument <[x]>. |
Angles are specified in radians. |
<<tanf>> is identical, save that it takes and returns <<float>> values. |
RETURNS |
The tangent of <[x]> is returned. |
PORTABILITY |
<<tan>> is ANSI. <<tanf>> is an extension. |
*/ |
/* tan(x) |
* Return tangent function of x. |
* |
* kernel function: |
* __kernel_tan ... tangent function on [-pi/4,pi/4] |
* __ieee754_rem_pio2 ... argument reduction routine |
* |
* Method. |
* Let S,C and T denote the sin, cos and tan respectively on |
* [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 |
* in [-pi/4 , +pi/4], and let n = k mod 4. |
* We have |
* |
* n sin(x) cos(x) tan(x) |
* ---------------------------------------------------------- |
* 0 S C T |
* 1 C -S -1/T |
* 2 -S -C T |
* 3 -C S -1/T |
* ---------------------------------------------------------- |
* |
* Special cases: |
* Let trig be any of sin, cos, or tan. |
* trig(+-INF) is NaN, with signals; |
* trig(NaN) is that NaN; |
* |
* Accuracy: |
* TRIG(x) returns trig(x) nearly rounded |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double tan(double x) |
#else |
double tan(x) |
double x; |
#endif |
{ |
double y[2],z=0.0; |
__int32_t n,ix; |
/* High word of x. */ |
GET_HIGH_WORD(ix,x); |
/* |x| ~< pi/4 */ |
ix &= 0x7fffffff; |
if(ix <= 0x3fe921fb) return __kernel_tan(x,z,1); |
/* tan(Inf or NaN) is NaN */ |
else if (ix>=0x7ff00000) return x-x; /* NaN */ |
/* argument reduction needed */ |
else { |
n = __ieee754_rem_pio2(x,y); |
return __kernel_tan(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even |
-1 -- n odd */ |
} |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_tanh.c |
---|
0,0 → 1,128 |
/* @(#)s_tanh.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<tanh>>, <<tanhf>>---hyperbolic tangent |
INDEX |
tanh |
INDEX |
tanhf |
ANSI_SYNOPSIS |
#include <math.h> |
double tanh(double <[x]>); |
float tanhf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double tanh(<[x]>) |
double <[x]>; |
float tanhf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<tanh>> computes the hyperbolic tangent of |
the argument <[x]>. Angles are specified in radians. |
<<tanh(<[x]>)>> is defined as |
. sinh(<[x]>)/cosh(<[x]>) |
<<tanhf>> is identical, save that it takes and returns <<float>> values. |
RETURNS |
The hyperbolic tangent of <[x]> is returned. |
PORTABILITY |
<<tanh>> is ANSI C. <<tanhf>> is an extension. |
*/ |
/* Tanh(x) |
* Return the Hyperbolic Tangent of x |
* |
* Method : |
* x -x |
* e - e |
* 0. tanh(x) is defined to be ----------- |
* x -x |
* e + e |
* 1. reduce x to non-negative by tanh(-x) = -tanh(x). |
* 2. 0 <= x <= 2**-55 : tanh(x) := x*(one+x) |
* -t |
* 2**-55 < x <= 1 : tanh(x) := -----; t = expm1(-2x) |
* t + 2 |
* 2 |
* 1 <= x <= 22.0 : tanh(x) := 1- ----- ; t=expm1(2x) |
* t + 2 |
* 22.0 < x <= INF : tanh(x) := 1. |
* |
* Special cases: |
* tanh(NaN) is NaN; |
* only tanh(0)=0 is exact for finite argument. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double one=1.0, two=2.0, tiny = 1.0e-300; |
#else |
static double one=1.0, two=2.0, tiny = 1.0e-300; |
#endif |
#ifdef __STDC__ |
double tanh(double x) |
#else |
double tanh(x) |
double x; |
#endif |
{ |
double t,z; |
__int32_t jx,ix; |
/* High word of |x|. */ |
GET_HIGH_WORD(jx,x); |
ix = jx&0x7fffffff; |
/* x is INF or NaN */ |
if(ix>=0x7ff00000) { |
if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */ |
else return one/x-one; /* tanh(NaN) = NaN */ |
} |
/* |x| < 22 */ |
if (ix < 0x40360000) { /* |x|<22 */ |
if (ix<0x3c800000) /* |x|<2**-55 */ |
return x*(one+x); /* tanh(small) = small */ |
if (ix>=0x3ff00000) { /* |x|>=1 */ |
t = expm1(two*fabs(x)); |
z = one - two/(t+two); |
} else { |
t = expm1(-two*fabs(x)); |
z= -t/(t+two); |
} |
/* |x| > 22, return +-1 */ |
} else { |
z = one - tiny; /* raised inexact flag */ |
} |
return (jx>=0)? z: -z; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/s_trunc.c |
---|
0,0 → 1,98 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<trunc>>, <<truncf>>--round to integer, towards zero |
INDEX |
trunc |
INDEX |
truncf |
ANSI_SYNOPSIS |
#include <math.h> |
double trunc(double <[x]>); |
float truncf(float <[x]>); |
DESCRIPTION |
The <<trunc>> functions round their argument to the integer value, in |
floating format, nearest to but no larger in magnitude than the |
argument, regardless of the current rounding direction. (While the |
"inexact" floating-point exception behavior is unspecified by the C |
standard, the <<trunc>> functions are written so that "inexact" is not |
raised if the result does not equal the argument, which behavior is as |
recommended by IEEE 754 for its related functions.) |
RETURNS |
<[x]> truncated to an integral value. |
PORTABILITY |
ANSI C, POSIX |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double trunc(double x) |
#else |
double trunc(x) |
double x; |
#endif |
{ |
int signbit; |
/* Most significant word, least significant word. */ |
int msw; |
unsigned int lsw; |
int exponent_less_1023; |
EXTRACT_WORDS(msw, lsw, x); |
/* Extract sign bit. */ |
signbit = msw & 0x80000000; |
/* Extract exponent field. */ |
exponent_less_1023 = ((msw & 0x7ff00000) >> 20) - 1023; |
if (exponent_less_1023 < 20) |
{ |
/* All significant digits are in msw. */ |
if (exponent_less_1023 < 0) |
{ |
/* -1 < x < 1, so result is +0 or -0. */ |
INSERT_WORDS(x, signbit, 0); |
} |
else |
{ |
/* All relevant fraction bits are in msw, so lsw of the result is 0. */ |
INSERT_WORDS(x, signbit | (msw & ~(0x000fffff >> exponent_less_1023)), 0); |
} |
} |
else if (exponent_less_1023 > 51) |
{ |
if (exponent_less_1023 == 1024) |
{ |
/* x is infinite, or not a number, so trigger an exception. */ |
return x + x; |
} |
/* All bits in the fraction fields of the msw and lsw are needed in the result. */ |
} |
else |
{ |
/* All fraction bits in msw are relevant. Truncate irrelevant |
bits from lsw. */ |
INSERT_WORDS(x, msw, lsw & ~(0xffffffffu >> (exponent_less_1023 - 20))); |
} |
return x; |
} |
#endif /* _DOUBLE_IS_32BITS */ |
/contrib/sdk/sources/libc/math/scalblnl.c |
---|
0,0 → 1,42 |
/* |
(C) Copyright IBM Corp. 2009 |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
* Redistributions of source code must retain the above copyright notice, |
this list of conditions and the following disclaimer. |
* Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
* Neither the name of IBM nor the names of its contributors may be |
used to endorse or promote products derived from this software without |
specific prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <math.h> |
#include "local.h" |
/* On platforms where long double is as wide as double. */ |
#ifdef _LDBL_EQ_DBL |
long double |
scalblnl (long double x, long n) |
{ |
return scalbln(x, n); |
} |
#endif |
/contrib/sdk/sources/libc/math/scalbnl.c |
---|
0,0 → 1,42 |
/* |
(C) Copyright IBM Corp. 2009 |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
* Redistributions of source code must retain the above copyright notice, |
this list of conditions and the following disclaimer. |
* Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
* Neither the name of IBM nor the names of its contributors may be |
used to endorse or promote products derived from this software without |
specific prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <math.h> |
#include "local.h" |
/* On platforms where long double is as wide as double. */ |
#ifdef _LDBL_EQ_DBL |
long double |
scalbnl (long double x, int n) |
{ |
return scalbn(x, n); |
} |
#endif |
/contrib/sdk/sources/libc/math/sf_asinh.c |
---|
0,0 → 1,66 |
/* sf_asinh.c -- float version of s_asinh.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0000000000e+00, /* 0x3F800000 */ |
ln2 = 6.9314718246e-01, /* 0x3f317218 */ |
huge= 1.0000000000e+30; |
#ifdef __STDC__ |
float asinhf(float x) |
#else |
float asinhf(x) |
float x; |
#endif |
{ |
float t,w; |
__int32_t hx,ix; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(!FLT_UWORD_IS_FINITE(ix)) return x+x; /* x is inf or NaN */ |
if(ix< 0x31800000) { /* |x|<2**-28 */ |
if(huge+x>one) return x; /* return x inexact except 0 */ |
} |
if(ix>0x4d800000) { /* |x| > 2**28 */ |
w = __ieee754_logf(fabsf(x))+ln2; |
} else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */ |
t = fabsf(x); |
w = __ieee754_logf((float)2.0*t+one/(__ieee754_sqrtf(x*x+one)+t)); |
} else { /* 2.0 > |x| > 2**-28 */ |
t = x*x; |
w =log1pf(fabsf(x)+t/(one+__ieee754_sqrtf(one+t))); |
} |
if(hx>0) return w; else return -w; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double asinh(double x) |
#else |
double asinh(x) |
double x; |
#endif |
{ |
return (double) asinhf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_atan.c |
---|
0,0 → 1,129 |
/* sf_atan.c -- float version of s_atan.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float atanhi[] = { |
#else |
static float atanhi[] = { |
#endif |
4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */ |
7.8539812565e-01, /* atan(1.0)hi 0x3f490fda */ |
9.8279368877e-01, /* atan(1.5)hi 0x3f7b985e */ |
1.5707962513e+00, /* atan(inf)hi 0x3fc90fda */ |
}; |
#ifdef __STDC__ |
static const float atanlo[] = { |
#else |
static float atanlo[] = { |
#endif |
5.0121582440e-09, /* atan(0.5)lo 0x31ac3769 */ |
3.7748947079e-08, /* atan(1.0)lo 0x33222168 */ |
3.4473217170e-08, /* atan(1.5)lo 0x33140fb4 */ |
7.5497894159e-08, /* atan(inf)lo 0x33a22168 */ |
}; |
#ifdef __STDC__ |
static const float aT[] = { |
#else |
static float aT[] = { |
#endif |
3.3333334327e-01, /* 0x3eaaaaaa */ |
-2.0000000298e-01, /* 0xbe4ccccd */ |
1.4285714924e-01, /* 0x3e124925 */ |
-1.1111110449e-01, /* 0xbde38e38 */ |
9.0908870101e-02, /* 0x3dba2e6e */ |
-7.6918758452e-02, /* 0xbd9d8795 */ |
6.6610731184e-02, /* 0x3d886b35 */ |
-5.8335702866e-02, /* 0xbd6ef16b */ |
4.9768779427e-02, /* 0x3d4bda59 */ |
-3.6531571299e-02, /* 0xbd15a221 */ |
1.6285819933e-02, /* 0x3c8569d7 */ |
}; |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0, |
huge = 1.0e30; |
#ifdef __STDC__ |
float atanf(float x) |
#else |
float atanf(x) |
float x; |
#endif |
{ |
float w,s1,s2,z; |
__int32_t ix,hx,id; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix>=0x50800000) { /* if |x| >= 2^34 */ |
if(FLT_UWORD_IS_NAN(ix)) |
return x+x; /* NaN */ |
if(hx>0) return atanhi[3]+atanlo[3]; |
else return -atanhi[3]-atanlo[3]; |
} if (ix < 0x3ee00000) { /* |x| < 0.4375 */ |
if (ix < 0x31000000) { /* |x| < 2^-29 */ |
if(huge+x>one) return x; /* raise inexact */ |
} |
id = -1; |
} else { |
x = fabsf(x); |
if (ix < 0x3f980000) { /* |x| < 1.1875 */ |
if (ix < 0x3f300000) { /* 7/16 <=|x|<11/16 */ |
id = 0; x = ((float)2.0*x-one)/((float)2.0+x); |
} else { /* 11/16<=|x|< 19/16 */ |
id = 1; x = (x-one)/(x+one); |
} |
} else { |
if (ix < 0x401c0000) { /* |x| < 2.4375 */ |
id = 2; x = (x-(float)1.5)/(one+(float)1.5*x); |
} else { /* 2.4375 <= |x| < 2^66 */ |
id = 3; x = -(float)1.0/x; |
} |
}} |
/* end of argument reduction */ |
z = x*x; |
w = z*z; |
/* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ |
s1 = z*(aT[0]+w*(aT[2]+w*(aT[4]+w*(aT[6]+w*(aT[8]+w*aT[10]))))); |
s2 = w*(aT[1]+w*(aT[3]+w*(aT[5]+w*(aT[7]+w*aT[9])))); |
if (id<0) return x - x*(s1+s2); |
else { |
z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x); |
return (hx<0)? -z:z; |
} |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double atan(double x) |
#else |
double atan(x) |
double x; |
#endif |
{ |
return (double) atanf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_cbrt.c |
---|
0,0 → 1,94 |
/* sf_cbrt.c -- float version of s_cbrt.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
#include "fdlibm.h" |
/* cbrtf(x) |
* Return cube root of x |
*/ |
#ifdef __STDC__ |
static const __uint32_t |
#else |
static __uint32_t |
#endif |
B1 = 709958130, /* B1 = (84+2/3-0.03306235651)*2**23 */ |
B2 = 642849266; /* B2 = (76+2/3-0.03306235651)*2**23 */ |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
C = 5.4285717010e-01, /* 19/35 = 0x3f0af8b0 */ |
D = -7.0530611277e-01, /* -864/1225 = 0xbf348ef1 */ |
E = 1.4142856598e+00, /* 99/70 = 0x3fb50750 */ |
F = 1.6071428061e+00, /* 45/28 = 0x3fcdb6db */ |
G = 3.5714286566e-01; /* 5/14 = 0x3eb6db6e */ |
#ifdef __STDC__ |
float cbrtf(float x) |
#else |
float cbrtf(x) |
float x; |
#endif |
{ |
__int32_t hx; |
float r,s,t; |
__uint32_t sign; |
__uint32_t high; |
GET_FLOAT_WORD(hx,x); |
sign=hx&0x80000000; /* sign= sign(x) */ |
hx ^=sign; |
if(!FLT_UWORD_IS_FINITE(hx)) |
return(x+x); /* cbrt(NaN,INF) is itself */ |
if(FLT_UWORD_IS_ZERO(hx)) |
return(x); /* cbrt(0) is itself */ |
SET_FLOAT_WORD(x,hx); /* x <- |x| */ |
/* rough cbrt to 5 bits */ |
if(FLT_UWORD_IS_SUBNORMAL(hx)) /* subnormal number */ |
{SET_FLOAT_WORD(t,0x4b800000); /* set t= 2**24 */ |
t*=x; GET_FLOAT_WORD(high,t); SET_FLOAT_WORD(t,high/3+B2); |
} |
else |
SET_FLOAT_WORD(t,hx/3+B1); |
/* new cbrt to 23 bits */ |
r=t*t/x; |
s=C+r*t; |
t*=G+F/(s+E+D/s); |
/* retore the sign bit */ |
GET_FLOAT_WORD(high,t); |
SET_FLOAT_WORD(t,high|sign); |
return(t); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double cbrt(double x) |
#else |
double cbrt(x) |
double x; |
#endif |
{ |
return (double) cbrtf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_ceil.c |
---|
0,0 → 1,70 |
/* sf_ceil.c -- float version of s_ceil.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float huge = 1.0e30; |
#else |
static float huge = 1.0e30; |
#endif |
#ifdef __STDC__ |
float ceilf(float x) |
#else |
float ceilf(x) |
float x; |
#endif |
{ |
__int32_t i0,j0; |
__uint32_t i,ix; |
GET_FLOAT_WORD(i0,x); |
ix = (i0&0x7fffffff); |
j0 = (ix>>23)-0x7f; |
if(j0<23) { |
if(j0<0) { /* raise inexact if x != 0 */ |
if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ |
if(i0<0) {i0=0x80000000;} |
else if(!FLT_UWORD_IS_ZERO(ix)) { i0=0x3f800000;} |
} |
} else { |
i = (0x007fffff)>>j0; |
if((i0&i)==0) return x; /* x is integral */ |
if(huge+x>(float)0.0) { /* raise inexact flag */ |
if(i0>0) i0 += (0x00800000)>>j0; |
i0 &= (~i); |
} |
} |
} else { |
if(!FLT_UWORD_IS_FINITE(ix)) return x+x; /* inf or NaN */ |
else return x; /* x is integral */ |
} |
SET_FLOAT_WORD(x,i0); |
return x; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double ceil(double x) |
#else |
double ceil(x) |
double x; |
#endif |
{ |
return (double) ceilf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_copysign.c |
---|
0,0 → 1,50 |
/* sf_copysign.c -- float version of s_copysign.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* copysignf(float x, float y) |
* copysignf(x,y) returns a value with the magnitude of x and |
* with the sign bit of y. |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float copysignf(float x, float y) |
#else |
float copysignf(x,y) |
float x,y; |
#endif |
{ |
__uint32_t ix,iy; |
GET_FLOAT_WORD(ix,x); |
GET_FLOAT_WORD(iy,y); |
SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000)); |
return x; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double copysign(double x, double y) |
#else |
double copysign(x,y) |
double x,y; |
#endif |
{ |
return (double) copysignf((float) x, (float) y); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_cos.c |
---|
0,0 → 1,68 |
/* sf_cos.c -- float version of s_cos.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float one=1.0; |
#else |
static float one=1.0; |
#endif |
#ifdef __STDC__ |
float cosf(float x) |
#else |
float cosf(x) |
float x; |
#endif |
{ |
float y[2],z=0.0; |
__int32_t n,ix; |
GET_FLOAT_WORD(ix,x); |
/* |x| ~< pi/4 */ |
ix &= 0x7fffffff; |
if(ix <= 0x3f490fd8) return __kernel_cosf(x,z); |
/* cos(Inf or NaN) is NaN */ |
else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; |
/* argument reduction needed */ |
else { |
n = __ieee754_rem_pio2f(x,y); |
switch(n&3) { |
case 0: return __kernel_cosf(y[0],y[1]); |
case 1: return -__kernel_sinf(y[0],y[1],1); |
case 2: return -__kernel_cosf(y[0],y[1]); |
default: |
return __kernel_sinf(y[0],y[1],1); |
} |
} |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double cos(double x) |
#else |
double cos(x) |
double x; |
#endif |
{ |
return (double) cosf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_erf.c |
---|
0,0 → 1,246 |
/* sf_erf.c -- float version of s_erf.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __v810__ |
#define const |
#endif |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
tiny = 1e-30, |
half= 5.0000000000e-01, /* 0x3F000000 */ |
one = 1.0000000000e+00, /* 0x3F800000 */ |
two = 2.0000000000e+00, /* 0x40000000 */ |
/* c = (subfloat)0.84506291151 */ |
erx = 8.4506291151e-01, /* 0x3f58560b */ |
/* |
* Coefficients for approximation to erf on [0,0.84375] |
*/ |
efx = 1.2837916613e-01, /* 0x3e0375d4 */ |
efx8= 1.0270333290e+00, /* 0x3f8375d4 */ |
pp0 = 1.2837916613e-01, /* 0x3e0375d4 */ |
pp1 = -3.2504209876e-01, /* 0xbea66beb */ |
pp2 = -2.8481749818e-02, /* 0xbce9528f */ |
pp3 = -5.7702702470e-03, /* 0xbbbd1489 */ |
pp4 = -2.3763017452e-05, /* 0xb7c756b1 */ |
qq1 = 3.9791721106e-01, /* 0x3ecbbbce */ |
qq2 = 6.5022252500e-02, /* 0x3d852a63 */ |
qq3 = 5.0813062117e-03, /* 0x3ba68116 */ |
qq4 = 1.3249473704e-04, /* 0x390aee49 */ |
qq5 = -3.9602282413e-06, /* 0xb684e21a */ |
/* |
* Coefficients for approximation to erf in [0.84375,1.25] |
*/ |
pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */ |
pa1 = 4.1485610604e-01, /* 0x3ed46805 */ |
pa2 = -3.7220788002e-01, /* 0xbebe9208 */ |
pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */ |
pa4 = -1.1089469492e-01, /* 0xbde31cc2 */ |
pa5 = 3.5478305072e-02, /* 0x3d1151b3 */ |
pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */ |
qa1 = 1.0642088205e-01, /* 0x3dd9f331 */ |
qa2 = 5.4039794207e-01, /* 0x3f0a5785 */ |
qa3 = 7.1828655899e-02, /* 0x3d931ae7 */ |
qa4 = 1.2617121637e-01, /* 0x3e013307 */ |
qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */ |
qa6 = 1.1984500103e-02, /* 0x3c445aa3 */ |
/* |
* Coefficients for approximation to erfc in [1.25,1/0.35] |
*/ |
ra0 = -9.8649440333e-03, /* 0xbc21a093 */ |
ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */ |
ra2 = -1.0558626175e+01, /* 0xc128f022 */ |
ra3 = -6.2375331879e+01, /* 0xc2798057 */ |
ra4 = -1.6239666748e+02, /* 0xc322658c */ |
ra5 = -1.8460508728e+02, /* 0xc3389ae7 */ |
ra6 = -8.1287437439e+01, /* 0xc2a2932b */ |
ra7 = -9.8143291473e+00, /* 0xc11d077e */ |
sa1 = 1.9651271820e+01, /* 0x419d35ce */ |
sa2 = 1.3765776062e+02, /* 0x4309a863 */ |
sa3 = 4.3456588745e+02, /* 0x43d9486f */ |
sa4 = 6.4538726807e+02, /* 0x442158c9 */ |
sa5 = 4.2900814819e+02, /* 0x43d6810b */ |
sa6 = 1.0863500214e+02, /* 0x42d9451f */ |
sa7 = 6.5702495575e+00, /* 0x40d23f7c */ |
sa8 = -6.0424413532e-02, /* 0xbd777f97 */ |
/* |
* Coefficients for approximation to erfc in [1/.35,28] |
*/ |
rb0 = -9.8649431020e-03, /* 0xbc21a092 */ |
rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */ |
rb2 = -1.7757955551e+01, /* 0xc18e104b */ |
rb3 = -1.6063638306e+02, /* 0xc320a2ea */ |
rb4 = -6.3756646729e+02, /* 0xc41f6441 */ |
rb5 = -1.0250950928e+03, /* 0xc480230b */ |
rb6 = -4.8351919556e+02, /* 0xc3f1c275 */ |
sb1 = 3.0338060379e+01, /* 0x41f2b459 */ |
sb2 = 3.2579251099e+02, /* 0x43a2e571 */ |
sb3 = 1.5367296143e+03, /* 0x44c01759 */ |
sb4 = 3.1998581543e+03, /* 0x4547fdbb */ |
sb5 = 2.5530502930e+03, /* 0x451f90ce */ |
sb6 = 4.7452853394e+02, /* 0x43ed43a7 */ |
sb7 = -2.2440952301e+01; /* 0xc1b38712 */ |
#ifdef __STDC__ |
float erff(float x) |
#else |
float erff(x) |
float x; |
#endif |
{ |
__int32_t hx,ix,i; |
float R,S,P,Q,s,y,z,r; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(!FLT_UWORD_IS_FINITE(ix)) { /* erf(nan)=nan */ |
i = ((__uint32_t)hx>>31)<<1; |
return (float)(1-i)+one/x; /* erf(+-inf)=+-1 */ |
} |
if(ix < 0x3f580000) { /* |x|<0.84375 */ |
if(ix < 0x31800000) { /* |x|<2**-28 */ |
if (ix < 0x04000000) |
/*avoid underflow */ |
return (float)0.125*((float)8.0*x+efx8*x); |
return x + efx*x; |
} |
z = x*x; |
r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); |
s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); |
y = r/s; |
return x + x*y; |
} |
if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */ |
s = fabsf(x)-one; |
P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); |
Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); |
if(hx>=0) return erx + P/Q; else return -erx - P/Q; |
} |
if (ix >= 0x40c00000) { /* inf>|x|>=6 */ |
if(hx>=0) return one-tiny; else return tiny-one; |
} |
x = fabsf(x); |
s = one/(x*x); |
if(ix< 0x4036DB6E) { /* |x| < 1/0.35 */ |
R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( |
ra5+s*(ra6+s*ra7)))))); |
S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( |
sa5+s*(sa6+s*(sa7+s*sa8))))))); |
} else { /* |x| >= 1/0.35 */ |
R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( |
rb5+s*rb6))))); |
S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( |
sb5+s*(sb6+s*sb7)))))); |
} |
GET_FLOAT_WORD(ix,x); |
SET_FLOAT_WORD(z,ix&0xfffff000); |
r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S); |
if(hx>=0) return one-r/x; else return r/x-one; |
} |
#ifdef __STDC__ |
float erfcf(float x) |
#else |
float erfcf(x) |
float x; |
#endif |
{ |
__int32_t hx,ix; |
float R,S,P,Q,s,y,z,r; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(!FLT_UWORD_IS_FINITE(ix)) { /* erfc(nan)=nan */ |
/* erfc(+-inf)=0,2 */ |
return (float)(((__uint32_t)hx>>31)<<1)+one/x; |
} |
if(ix < 0x3f580000) { /* |x|<0.84375 */ |
if(ix < 0x23800000) /* |x|<2**-56 */ |
return one-x; |
z = x*x; |
r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); |
s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); |
y = r/s; |
if(hx < 0x3e800000) { /* x<1/4 */ |
return one-(x+x*y); |
} else { |
r = x*y; |
r += (x-half); |
return half - r ; |
} |
} |
if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */ |
s = fabsf(x)-one; |
P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); |
Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); |
if(hx>=0) { |
z = one-erx; return z - P/Q; |
} else { |
z = erx+P/Q; return one+z; |
} |
} |
if (ix < 0x41e00000) { /* |x|<28 */ |
x = fabsf(x); |
s = one/(x*x); |
if(ix< 0x4036DB6D) { /* |x| < 1/.35 ~ 2.857143*/ |
R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( |
ra5+s*(ra6+s*ra7)))))); |
S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( |
sa5+s*(sa6+s*(sa7+s*sa8))))))); |
} else { /* |x| >= 1/.35 ~ 2.857143 */ |
if(hx<0&&ix>=0x40c00000) return two-tiny;/* x < -6 */ |
R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( |
rb5+s*rb6))))); |
S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( |
sb5+s*(sb6+s*sb7)))))); |
} |
GET_FLOAT_WORD(ix,x); |
SET_FLOAT_WORD(z,ix&0xfffff000); |
r = __ieee754_expf(-z*z-(float)0.5625)* |
__ieee754_expf((z-x)*(z+x)+R/S); |
if(hx>0) return r/x; else return two-r/x; |
} else { |
if(hx>0) return tiny*tiny; else return two-tiny; |
} |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double erf(double x) |
#else |
double erf(x) |
double x; |
#endif |
{ |
return (double) erff((float) x); |
} |
#ifdef __STDC__ |
double erfc(double x) |
#else |
double erfc(x) |
double x; |
#endif |
{ |
return (double) erfcf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_exp10.c |
---|
0,0 → 1,47 |
/* sf_exp10.c -- float version of s_exp10.c. |
* Modification of sf_exp2.c by Yaakov Selkowitz 2007. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper exp10f(x) |
*/ |
#undef exp10f |
#include "fdlibm.h" |
#include <errno.h> |
#include <math.h> |
#ifdef __STDC__ |
float exp10f(float x) /* wrapper exp10f */ |
#else |
float exp10f(x) /* wrapper exp10f */ |
float x; |
#endif |
{ |
return powf(10.0, x); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double exp10(double x) |
#else |
double exp10(x) |
double x; |
#endif |
{ |
return (double) exp10f((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_expm1.c |
---|
0,0 → 1,145 |
/* sf_expm1.c -- float version of s_expm1.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __v810__ |
#define const |
#endif |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0, |
huge = 1.0e+30, |
tiny = 1.0e-30, |
ln2_hi = 6.9313812256e-01,/* 0x3f317180 */ |
ln2_lo = 9.0580006145e-06,/* 0x3717f7d1 */ |
invln2 = 1.4426950216e+00,/* 0x3fb8aa3b */ |
/* scaled coefficients related to expm1 */ |
Q1 = -3.3333335072e-02, /* 0xbd088889 */ |
Q2 = 1.5873016091e-03, /* 0x3ad00d01 */ |
Q3 = -7.9365076090e-05, /* 0xb8a670cd */ |
Q4 = 4.0082177293e-06, /* 0x36867e54 */ |
Q5 = -2.0109921195e-07; /* 0xb457edbb */ |
#ifdef __STDC__ |
float expm1f(float x) |
#else |
float expm1f(x) |
float x; |
#endif |
{ |
float y,hi,lo,c,t,e,hxs,hfx,r1; |
__int32_t k,xsb; |
__uint32_t hx; |
GET_FLOAT_WORD(hx,x); |
xsb = hx&0x80000000; /* sign bit of x */ |
if(xsb==0) y=x; else y= -x; /* y = |x| */ |
hx &= 0x7fffffff; /* high word of |x| */ |
/* filter out huge and non-finite argument */ |
if(hx >= 0x4195b844) { /* if |x|>=27*ln2 */ |
if(FLT_UWORD_IS_NAN(hx)) |
return x+x; |
if(FLT_UWORD_IS_INFINITE(hx)) |
return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */ |
if(xsb == 0 && hx > FLT_UWORD_LOG_MAX) /* if x>=o_threshold */ |
return huge*huge; /* overflow */ |
if(xsb!=0) { /* x < -27*ln2, return -1.0 with inexact */ |
if(x+tiny<(float)0.0) /* raise inexact */ |
return tiny-one; /* return -1 */ |
} |
} |
/* argument reduction */ |
if(hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */ |
if(hx < 0x3F851592) { /* and |x| < 1.5 ln2 */ |
if(xsb==0) |
{hi = x - ln2_hi; lo = ln2_lo; k = 1;} |
else |
{hi = x + ln2_hi; lo = -ln2_lo; k = -1;} |
} else { |
k = invln2*x+((xsb==0)?(float)0.5:(float)-0.5); |
t = k; |
hi = x - t*ln2_hi; /* t*ln2_hi is exact here */ |
lo = t*ln2_lo; |
} |
x = hi - lo; |
c = (hi-x)-lo; |
} |
else if(hx < 0x33000000) { /* when |x|<2**-25, return x */ |
t = huge+x; /* return x with inexact flags when x!=0 */ |
return x - (t-(huge+x)); |
} |
else k = 0; |
/* x is now in primary range */ |
hfx = (float)0.5*x; |
hxs = x*hfx; |
r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5)))); |
t = (float)3.0-r1*hfx; |
e = hxs*((r1-t)/((float)6.0 - x*t)); |
if(k==0) return x - (x*e-hxs); /* c is 0 */ |
else { |
e = (x*(e-c)-c); |
e -= hxs; |
if(k== -1) return (float)0.5*(x-e)-(float)0.5; |
if(k==1) { |
if(x < (float)-0.25) return -(float)2.0*(e-(x+(float)0.5)); |
else return one+(float)2.0*(x-e); |
} |
if (k <= -2 || k>56) { /* suffice to return exp(x)-1 */ |
__int32_t i; |
y = one-(e-x); |
GET_FLOAT_WORD(i,y); |
SET_FLOAT_WORD(y,i+(k<<23)); /* add k to y's exponent */ |
return y-one; |
} |
t = one; |
if(k<23) { |
__int32_t i; |
SET_FLOAT_WORD(t,0x3f800000 - (0x1000000>>k)); /* t=1-2^-k */ |
y = t-(e-x); |
GET_FLOAT_WORD(i,y); |
SET_FLOAT_WORD(y,i+(k<<23)); /* add k to y's exponent */ |
} else { |
__int32_t i; |
SET_FLOAT_WORD(t,((0x7f-k)<<23)); /* 2^-k */ |
y = x-(e+t); |
y += one; |
GET_FLOAT_WORD(i,y); |
SET_FLOAT_WORD(y,i+(k<<23)); /* add k to y's exponent */ |
} |
} |
return y; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double expm1(double x) |
#else |
double expm1(x) |
double x; |
#endif |
{ |
return (double) expm1f((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_fabs.c |
---|
0,0 → 1,47 |
/* sf_fabs.c -- float version of s_fabs.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* fabsf(x) returns the absolute value of x. |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float fabsf(float x) |
#else |
float fabsf(x) |
float x; |
#endif |
{ |
__uint32_t ix; |
GET_FLOAT_WORD(ix,x); |
SET_FLOAT_WORD(x,ix&0x7fffffff); |
return x; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fabs(double x) |
#else |
double fabs(x) |
double x; |
#endif |
{ |
return (double) fabsf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_fdim.c |
---|
0,0 → 1,39 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float fdimf(float x, float y) |
#else |
float fdimf(x,y) |
float x; |
float y; |
#endif |
{ |
int c = __fpclassifyf(x); |
if (c == FP_NAN) return(x); |
if (__fpclassifyf(y) == FP_NAN) return(y); |
if (c == FP_INFINITE) |
return HUGE_VALF; |
return x > y ? x - y : 0.0; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fdim(double x, double y) |
#else |
double fdim(x,y) |
double x; |
double y; |
#endif |
{ |
return (double) fdimf((float) x, (float) y); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_finite.c |
---|
0,0 → 1,48 |
/* sf_finite.c -- float version of s_finite.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* finitef(x) returns 1 is x is finite, else 0; |
* no branching! |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
int finitef(float x) |
#else |
int finitef(x) |
float x; |
#endif |
{ |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
return (FLT_UWORD_IS_FINITE(ix)); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
int finite(double x) |
#else |
int finite(x) |
double x; |
#endif |
{ |
return finitef((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_floor.c |
---|
0,0 → 1,80 |
/* sf_floor.c -- float version of s_floor.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* floorf(x) |
* Return x rounded toward -inf to integral value |
* Method: |
* Bit twiddling. |
* Exception: |
* Inexact flag raised if x not equal to floorf(x). |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float huge = 1.0e30; |
#else |
static float huge = 1.0e30; |
#endif |
#ifdef __STDC__ |
float floorf(float x) |
#else |
float floorf(x) |
float x; |
#endif |
{ |
__int32_t i0,j0; |
__uint32_t i,ix; |
GET_FLOAT_WORD(i0,x); |
ix = (i0&0x7fffffff); |
j0 = (ix>>23)-0x7f; |
if(j0<23) { |
if(j0<0) { /* raise inexact if x != 0 */ |
if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ |
if(i0>=0) {i0=0;} |
else if(!FLT_UWORD_IS_ZERO(ix)) |
{ i0=0xbf800000;} |
} |
} else { |
i = (0x007fffff)>>j0; |
if((i0&i)==0) return x; /* x is integral */ |
if(huge+x>(float)0.0) { /* raise inexact flag */ |
if(i0<0) i0 += (0x00800000)>>j0; |
i0 &= (~i); |
} |
} |
} else { |
if(!FLT_UWORD_IS_FINITE(ix)) return x+x; /* inf or NaN */ |
else return x; /* x is integral */ |
} |
SET_FLOAT_WORD(x,i0); |
return x; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double floor(double x) |
#else |
double floor(x) |
double x; |
#endif |
{ |
return (double) floorf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_fma.c |
---|
0,0 → 1,42 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float fmaf(float x, float y, float z) |
#else |
float fmaf(x,y,z) |
float x; |
float y; |
float z; |
#endif |
{ |
/* NOTE: The floating-point exception behavior of this is not as |
* required. But since the basic function is not really done properly, |
* it is not worth bothering to get the exceptions right, either. */ |
/* Let the implementation handle this. */ /* <= NONSENSE! */ |
/* In floating-point implementations in which double is larger than float, |
* computing as double should provide the desired function. Otherwise, |
* the behavior will not be as specified in the standards. */ |
return (float) (((double) x * (double) y) + (double) z); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fma(double x, double y, double z) |
#else |
double fma(x,y,z) |
double x; |
double y; |
double z; |
#endif |
{ |
return (double) fmaf((float) x, (float) y, (float) z); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_fmax.c |
---|
0,0 → 1,38 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float fmaxf(float x, float y) |
#else |
float fmaxf(x,y) |
float x; |
float y; |
#endif |
{ |
if (__fpclassifyf(x) == FP_NAN) |
return y; |
if (__fpclassifyf(y) == FP_NAN) |
return x; |
return x > y ? x : y; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fmax(double x, double y) |
#else |
double fmax(x,y) |
double x; |
double y; |
#endif |
{ |
return (double) fmaxf((float) x, (float) y); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_fmin.c |
---|
0,0 → 1,38 |
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float fminf(float x, float y) |
#else |
float fminf(x,y) |
float x; |
float y; |
#endif |
{ |
if (__fpclassifyf(x) == FP_NAN) |
return y; |
if (__fpclassifyf(y) == FP_NAN) |
return x; |
return x < y ? x : y; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fmin(double x, double y) |
#else |
double fmin(x,y) |
double x; |
double y; |
#endif |
{ |
return (double) fminf((float) x, (float) y); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_fpclassify.c |
---|
0,0 → 1,29 |
/* Copyright (C) 2002,2007 by Red Hat, Incorporated. All rights reserved. |
* |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
#include "fdlibm.h" |
int |
__fpclassifyf (float x) |
{ |
__uint32_t w; |
GET_FLOAT_WORD(w,x); |
if (w == 0x00000000 || w == 0x80000000) |
return FP_ZERO; |
else if ((w >= 0x00800000 && w <= 0x7f7fffff) || |
(w >= 0x80800000 && w <= 0xff7fffff)) |
return FP_NORMAL; |
else if ((w >= 0x00000001 && w <= 0x007fffff) || |
(w >= 0x80000001 && w <= 0x807fffff)) |
return FP_SUBNORMAL; |
else if (w == 0x7f800000 || w == 0xff800000) |
return FP_INFINITE; |
else |
return FP_NAN; |
} |
/contrib/sdk/sources/libc/math/sf_frexp.c |
---|
0,0 → 1,61 |
/* sf_frexp.c -- float version of s_frexp.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
two25 = 3.3554432000e+07; /* 0x4c000000 */ |
#ifdef __STDC__ |
float frexpf(float x, int *eptr) |
#else |
float frexpf(x, eptr) |
float x; int *eptr; |
#endif |
{ |
__int32_t hx, ix; |
GET_FLOAT_WORD(hx,x); |
ix = 0x7fffffff&hx; |
*eptr = 0; |
if(!FLT_UWORD_IS_FINITE(ix)||FLT_UWORD_IS_ZERO(ix)) return x; /* 0,inf,nan */ |
if (FLT_UWORD_IS_SUBNORMAL(ix)) { /* subnormal */ |
x *= two25; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
*eptr = -25; |
} |
*eptr += (ix>>23)-126; |
hx = (hx&0x807fffff)|0x3f000000; |
SET_FLOAT_WORD(x,hx); |
return x; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double frexp(double x, int *eptr) |
#else |
double frexp(x, eptr) |
double x; int *eptr; |
#endif |
{ |
return (double) frexpf((float) x, eptr); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_ilogb.c |
---|
0,0 → 1,55 |
/* sf_ilogb.c -- float version of s_ilogb.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include <limits.h> |
#include "fdlibm.h" |
#ifdef __STDC__ |
int ilogbf(float x) |
#else |
int ilogbf(x) |
float x; |
#endif |
{ |
__int32_t hx,ix; |
GET_FLOAT_WORD(hx,x); |
hx &= 0x7fffffff; |
if(FLT_UWORD_IS_ZERO(hx)) |
return FP_ILOGB0; /* ilogb(0) = special case error */ |
if(FLT_UWORD_IS_SUBNORMAL(hx)) { |
for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1; |
return ix; |
} |
#if FP_ILOGBNAN != INT_MAX |
else if (FLT_UWORD_IS_NAN(hx)) return FP_ILOGBNAN; /* NAN */ |
#endif |
else if (!FLT_UWORD_IS_FINITE(hx)) return INT_MAX; |
else return (hx>>23)-127; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
int ilogb(double x) |
#else |
int ilogb(x) |
double x; |
#endif |
{ |
return ilogbf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_infinity.c |
---|
0,0 → 1,23 |
/* |
* infinityf () returns the representation of infinity. |
* Added by Cygnus Support. |
*/ |
#include "fdlibm.h" |
float infinityf() |
{ |
float x; |
SET_FLOAT_WORD(x,0x7f800000); |
return x; |
} |
#ifdef _DOUBLE_IS_32BITS |
double infinity() |
{ |
return (double) infinityf(); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_isinf.c |
---|
0,0 → 1,37 |
/* |
* isinff(x) returns 1 if x is +-infinity, else 0; |
* |
* isinf is a <math.h> macro in the C99 standard. It was previously |
* implemented as isinf and isinff functions by newlib and are still declared |
* as such in <ieeefp.h>. Newlib supplies it here as a function if the user |
* chooses to use <ieeefp.h> or needs to link older code compiled with the |
* previous <math.h> declaration. |
*/ |
#include "fdlibm.h" |
#include <ieeefp.h> |
#undef isinff |
int |
_DEFUN (isinff, (x), |
float x) |
{ |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
return FLT_UWORD_IS_INFINITE(ix); |
} |
#ifdef _DOUBLE_IS_32BITS |
#undef isinf |
int |
_DEFUN (isinf, (x), |
double x) |
{ |
return isinff((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_isinff.c |
---|
0,0 → 1,27 |
/* |
* __isinff(x) returns 1 if x is +-infinity, else 0; |
* Added by Cygnus Support. |
*/ |
#include "fdlibm.h" |
int |
_DEFUN (__isinff, (x), |
float x) |
{ |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
return FLT_UWORD_IS_INFINITE(ix); |
} |
#ifdef _DOUBLE_IS_32BITS |
int |
_DEFUN (__isinfd, (x), |
double x) |
{ |
return __isinff((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_isnan.c |
---|
0,0 → 1,47 |
/* sf_c_isnan.c -- float version of s_c_isnan.c. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* isnanf(x) returns 1 is x is nan, else 0; |
* |
* isnanf is an extension declared in <ieeefp.h>. |
*/ |
#include "fdlibm.h" |
#include <ieeefp.h> |
#undef isnanf |
int |
_DEFUN (isnanf, (x), |
float x) |
{ |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
return FLT_UWORD_IS_NAN(ix); |
} |
#ifdef _DOUBLE_IS_32BITS |
#undef isnan |
int |
_DEFUN (isnan, (x), |
double x) |
{ |
return isnanf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_isnanf.c |
---|
0,0 → 1,37 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* __isnanf(x) returns 1 is x is nan, else 0; |
*/ |
#include "fdlibm.h" |
int |
_DEFUN (__isnanf, (x), |
float x) |
{ |
__int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
return FLT_UWORD_IS_NAN(ix); |
} |
#ifdef _DOUBLE_IS_32BITS |
int |
_DEFUN (__isnand, (x), |
double x) |
{ |
return __isnanf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_ldexp.c |
---|
0,0 → 1,44 |
/* sf_ldexp.c -- float version of s_ldexp.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float ldexpf(float value, int exp) |
#else |
float ldexpf(value, exp) |
float value; int exp; |
#endif |
{ |
if(!finitef(value)||value==(float)0.0) return value; |
value = scalbnf(value,exp); |
if(!finitef(value)||value==(float)0.0) errno = ERANGE; |
return value; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double ldexp(double value, int exp) |
#else |
double ldexp(value, exp) |
double value; int exp; |
#endif |
{ |
return (double) ldexpf((float) value, exp); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_llrint.c |
---|
0,0 → 1,101 |
/* lrintf adapted to be llrintf for Newlib, 2009 by Craig Howland. */ |
/* @(#)sf_lrint.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* llrintf(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using floating addition. |
* Exception: |
* Inexact flag raised if x not equal to llrintf(x). |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
/* Adding a float, x, to 2^23 will cause the result to be rounded based on |
the fractional part of x, according to the implementation's current rounding |
mode. 2^23 is the smallest float that can be represented using all 23 significant |
digits. */ |
TWO23[2]={ |
8.3886080000e+06, /* 0x4b000000 */ |
-8.3886080000e+06, /* 0xcb000000 */ |
}; |
#ifdef __STDC__ |
long long int llrintf(float x) |
#else |
long long int llrintf(x) |
float x; |
#endif |
{ |
__int32_t j0,sx; |
__uint32_t i0; |
float t; |
volatile float w; |
long long int result; |
GET_FLOAT_WORD(i0,x); |
/* Extract sign bit. */ |
sx = (i0 >> 31); |
/* Extract exponent field. */ |
j0 = ((i0 & 0x7f800000) >> 23) - 127; |
if (j0 < (int)(sizeof (long long int) * 8) - 1) |
{ |
if (j0 < -1) |
return 0; |
else if (j0 >= 23) |
result = (long long int) ((i0 & 0x7fffff) | 0x800000) << (j0 - 23); |
else |
{ |
w = TWO23[sx] + x; |
t = w - TWO23[sx]; |
GET_FLOAT_WORD (i0, t); |
/* Detect the all-zeros representation of plus and |
minus zero, which fails the calculation below. */ |
if ((i0 & ~((__uint32_t)1 << 31)) == 0) |
return 0; |
j0 = ((i0 >> 23) & 0xff) - 0x7f; |
i0 &= 0x7fffff; |
i0 |= 0x800000; |
result = i0 >> (23 - j0); |
} |
} |
else |
{ |
return (long long int) x; |
} |
return sx ? -result : result; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
long long int llrint(double x) |
#else |
long long int llrint(x) |
double x; |
#endif |
{ |
return llrintf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_llround.c |
---|
0,0 → 1,55 |
/* lroundf adapted to be llroundf for Newlib, 2009 by Craig Howland. */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
long long int |
llroundf(float x) |
{ |
__int32_t exponent_less_127; |
__uint32_t w; |
long long int result; |
__int32_t sign; |
GET_FLOAT_WORD (w, x); |
exponent_less_127 = ((w & 0x7f800000) >> 23) - 127; |
sign = (w & 0x80000000) != 0 ? -1 : 1; |
w &= 0x7fffff; |
w |= 0x800000; |
if (exponent_less_127 < (int)((8 * sizeof (long long int)) - 1)) |
{ |
if (exponent_less_127 < 0) |
return exponent_less_127 < -1 ? 0 : sign; |
else if (exponent_less_127 >= 23) |
result = (long long int) w << (exponent_less_127 - 23); |
else |
{ |
w += 0x400000 >> exponent_less_127; |
result = w >> (23 - exponent_less_127); |
} |
} |
else |
return (long long int) x; |
return sign * result; |
} |
#ifdef _DOUBLE_IS_32BITS |
long long int |
llround(double x) |
{ |
return llroundf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_log1p.c |
---|
0,0 → 1,121 |
/* sf_log1p.c -- float version of s_log1p.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ |
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */ |
two25 = 3.355443200e+07, /* 0x4c000000 */ |
Lp1 = 6.6666668653e-01, /* 3F2AAAAB */ |
Lp2 = 4.0000000596e-01, /* 3ECCCCCD */ |
Lp3 = 2.8571429849e-01, /* 3E924925 */ |
Lp4 = 2.2222198546e-01, /* 3E638E29 */ |
Lp5 = 1.8183572590e-01, /* 3E3A3325 */ |
Lp6 = 1.5313838422e-01, /* 3E1CD04F */ |
Lp7 = 1.4798198640e-01; /* 3E178897 */ |
#ifdef __STDC__ |
static const float zero = 0.0; |
#else |
static float zero = 0.0; |
#endif |
#ifdef __STDC__ |
float log1pf(float x) |
#else |
float log1pf(x) |
float x; |
#endif |
{ |
float hfsq,f,c,s,z,R,u; |
__int32_t k,hx,hu,ax; |
GET_FLOAT_WORD(hx,x); |
ax = hx&0x7fffffff; |
k = 1; |
if (!FLT_UWORD_IS_FINITE(hx)) return x+x; |
if (hx < 0x3ed413d7) { /* x < 0.41422 */ |
if(ax>=0x3f800000) { /* x <= -1.0 */ |
if(x==(float)-1.0) return -two25/zero; /* log1p(-1)=+inf */ |
else return (x-x)/(x-x); /* log1p(x<-1)=NaN */ |
} |
if(ax<0x31000000) { /* |x| < 2**-29 */ |
if(two25+x>zero /* raise inexact */ |
&&ax<0x24800000) /* |x| < 2**-54 */ |
return x; |
else |
return x - x*x*(float)0.5; |
} |
if(hx>0||hx<=((__int32_t)0xbe95f61f)) { |
k=0;f=x;hu=1;} /* -0.2929<x<0.41422 */ |
} |
if(k!=0) { |
if(hx<0x5a000000) { |
u = (float)1.0+x; |
GET_FLOAT_WORD(hu,u); |
k = (hu>>23)-127; |
/* correction term */ |
c = (k>0)? (float)1.0-(u-x):x-(u-(float)1.0); |
c /= u; |
} else { |
u = x; |
GET_FLOAT_WORD(hu,u); |
k = (hu>>23)-127; |
c = 0; |
} |
hu &= 0x007fffff; |
if(hu<0x3504f7) { |
SET_FLOAT_WORD(u,hu|0x3f800000);/* normalize u */ |
} else { |
k += 1; |
SET_FLOAT_WORD(u,hu|0x3f000000); /* normalize u/2 */ |
hu = (0x00800000-hu)>>2; |
} |
f = u-(float)1.0; |
} |
hfsq=(float)0.5*f*f; |
if(hu==0) { /* |f| < 2**-20 */ |
if(f==zero) { if(k==0) return zero; |
else {c += k*ln2_lo; return k*ln2_hi+c;}} |
R = hfsq*((float)1.0-(float)0.66666666666666666*f); |
if(k==0) return f-R; else |
return k*ln2_hi-((R-(k*ln2_lo+c))-f); |
} |
s = f/((float)2.0+f); |
z = s*s; |
R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7)))))); |
if(k==0) return f-(hfsq-s*(hfsq+R)); else |
return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double log1p(double x) |
#else |
double log1p(x) |
double x; |
#endif |
{ |
return (double) log1pf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_log2.c |
---|
0,0 → 1,48 |
/* sf_log2.c -- float version of s_log2.c. |
* Modification of sf_exp10.c by Yaakov Selkowitz 2009. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper log2f(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#include <math.h> |
#undef log2 |
#undef log2f |
#ifdef __STDC__ |
float log2f(float x) /* wrapper log2f */ |
#else |
float log2f(x) /* wrapper log2f */ |
float x; |
#endif |
{ |
return (logf(x) / (float_t) M_LN2); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double log2(double x) |
#else |
double log2(x) |
double x; |
#endif |
{ |
return (double) log2f((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_logb.c |
---|
0,0 → 1,62 |
/* 2009 for Newlib: Sun's sf_ilogb.c converted to be sf_logb.c. */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* float logb(float x) |
* return the binary exponent of non-zero x |
* logbf(0) = -inf, raise divide-by-zero floating point exception |
* logbf(+inf|-inf) = +inf (no signal is raised) |
* logbf(NaN) = NaN (no signal is raised) |
* Per C99 recommendation, a NaN argument is returned unchanged. |
*/ |
#include "fdlibm.h" |
float |
#ifdef __STDC__ |
logbf(float x) |
#else |
logbf(x) |
float x; |
#endif |
{ |
__int32_t hx,ix; |
GET_FLOAT_WORD(hx,x); |
hx &= 0x7fffffff; |
if(FLT_UWORD_IS_ZERO(hx)) { |
float xx; |
/* arg==0: return -inf and raise divide-by-zero exception */ |
SET_FLOAT_WORD(xx,hx); /* +0.0 */ |
return -1./xx; /* logbf(0) = -inf */ |
} |
if(FLT_UWORD_IS_SUBNORMAL(hx)) { |
for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1; |
return (float) ix; |
} |
else if (FLT_UWORD_IS_INFINITE(hx)) return HUGE_VALF; /* x==+|-inf */ |
else if (FLT_UWORD_IS_NAN(hx)) return x; |
else return (float) ((hx>>23)-127); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double logb(double x) |
#else |
double logb(x) |
double x; |
#endif |
{ |
return (double) logbf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_lrint.c |
---|
0,0 → 1,101 |
/* @(#)sf_lrint.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* lrintf(x) |
* Return x rounded to integral value according to the prevailing |
* rounding mode. |
* Method: |
* Using floating addition. |
* Exception: |
* Inexact flag raised if x not equal to lrintf(x). |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
/* Adding a float, x, to 2^23 will cause the result to be rounded based on |
the fractional part of x, according to the implementation's current rounding |
mode. 2^23 is the smallest float that can be represented using all 23 significant |
digits. */ |
TWO23[2]={ |
8.3886080000e+06, /* 0x4b000000 */ |
-8.3886080000e+06, /* 0xcb000000 */ |
}; |
#ifdef __STDC__ |
long int lrintf(float x) |
#else |
long int lrintf(x) |
float x; |
#endif |
{ |
__int32_t j0,sx; |
__uint32_t i0; |
float t; |
volatile float w; |
long int result; |
GET_FLOAT_WORD(i0,x); |
/* Extract sign bit. */ |
sx = (i0 >> 31); |
/* Extract exponent field. */ |
j0 = ((i0 & 0x7f800000) >> 23) - 127; |
if (j0 < (int)(sizeof (long int) * 8) - 1) |
{ |
if (j0 < -1) |
return 0; |
else if (j0 >= 23) |
result = (long int) ((i0 & 0x7fffff) | 0x800000) << (j0 - 23); |
else |
{ |
w = TWO23[sx] + x; |
t = w - TWO23[sx]; |
GET_FLOAT_WORD (i0, t); |
/* Detect the all-zeros representation of plus and |
minus zero, which fails the calculation below. */ |
if ((i0 & ~(1L << 31)) == 0) |
return 0; |
j0 = ((i0 >> 23) & 0xff) - 0x7f; |
i0 &= 0x7fffff; |
i0 |= 0x800000; |
result = i0 >> (23 - j0); |
} |
} |
else |
{ |
return (long int) x; |
} |
return sx ? -result : result; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
long int lrint(double x) |
#else |
long int lrint(x) |
double x; |
#endif |
{ |
return lrintf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_lround.c |
---|
0,0 → 1,62 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
long int lroundf(float x) |
#else |
long int lroundf(x) |
float x; |
#endif |
{ |
__int32_t exponent_less_127; |
__uint32_t w; |
long int result; |
__int32_t sign; |
GET_FLOAT_WORD (w, x); |
exponent_less_127 = ((w & 0x7f800000) >> 23) - 127; |
sign = (w & 0x80000000) != 0 ? -1 : 1; |
w &= 0x7fffff; |
w |= 0x800000; |
if (exponent_less_127 < (int)((8 * sizeof (long int)) - 1)) |
{ |
if (exponent_less_127 < 0) |
return exponent_less_127 < -1 ? 0 : sign; |
else if (exponent_less_127 >= 23) |
result = (long int) w << (exponent_less_127 - 23); |
else |
{ |
w += 0x400000 >> exponent_less_127; |
result = w >> (23 - exponent_less_127); |
} |
} |
else |
return (long int) x; |
return sign * result; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
long int lround(double x) |
#else |
long int lround(x) |
double x; |
#endif |
{ |
return lroundf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_modf.c |
---|
0,0 → 1,73 |
/* sf_modf.c -- float version of s_modf.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float one = 1.0; |
#else |
static float one = 1.0; |
#endif |
#ifdef __STDC__ |
float modff(float x, float *iptr) |
#else |
float modff(x, iptr) |
float x,*iptr; |
#endif |
{ |
__int32_t i0,j0; |
__uint32_t i; |
GET_FLOAT_WORD(i0,x); |
j0 = ((i0>>23)&0xff)-0x7f; /* exponent of x */ |
if(j0<23) { /* integer part in x */ |
if(j0<0) { /* |x|<1 */ |
SET_FLOAT_WORD(*iptr,i0&0x80000000); /* *iptr = +-0 */ |
return x; |
} else { |
i = (0x007fffff)>>j0; |
if((i0&i)==0) { /* x is integral */ |
__uint32_t ix; |
*iptr = x; |
GET_FLOAT_WORD(ix,x); |
SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ |
return x; |
} else { |
SET_FLOAT_WORD(*iptr,i0&(~i)); |
return x - *iptr; |
} |
} |
} else { /* no fraction part */ |
__uint32_t ix; |
*iptr = x*one; |
GET_FLOAT_WORD(ix,x); |
SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ |
return x; |
} |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double modf(double x, double *iptr) |
#else |
double modf(x, iptr) |
double x,*iptr; |
#endif |
{ |
return (double) modff((float) x, (float *) iptr); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_nan.c |
---|
0,0 → 1,24 |
/* |
* nanf () returns a nan. |
* Added by Cygnus Support. |
*/ |
#include "fdlibm.h" |
float nanf(const char *unused) |
{ |
float x; |
SET_FLOAT_WORD(x,0x7fc00000); |
return x; |
} |
#ifdef _DOUBLE_IS_32BITS |
double nan(const char *arg) |
{ |
return (double) nanf(arg); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_nearbyint.c |
---|
0,0 → 1,38 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include <math.h> |
#include "fdlibm.h" |
#ifdef __STDC__ |
float nearbyintf(float x) |
#else |
float nearbyintf(x) |
float x; |
#endif |
{ |
return rintf(x); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double nearbyint(double x) |
#else |
double nearbyint(x) |
double x; |
#endif |
{ |
return (double) nearbyintf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_nextafter.c |
---|
0,0 → 1,79 |
/* sf_nextafter.c -- float version of s_nextafter.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float nextafterf(float x, float y) |
#else |
float nextafterf(x,y) |
float x,y; |
#endif |
{ |
__int32_t hx,hy,ix,iy; |
GET_FLOAT_WORD(hx,x); |
GET_FLOAT_WORD(hy,y); |
ix = hx&0x7fffffff; /* |x| */ |
iy = hy&0x7fffffff; /* |y| */ |
if(FLT_UWORD_IS_NAN(ix) || |
FLT_UWORD_IS_NAN(iy)) |
return x+y; |
if(x==y) return x; /* x=y, return x */ |
if(FLT_UWORD_IS_ZERO(ix)) { /* x == 0 */ |
SET_FLOAT_WORD(x,(hy&0x80000000)|FLT_UWORD_MIN); |
y = x*x; |
if(y==x) return y; else return x; /* raise underflow flag */ |
} |
if(hx>=0) { /* x > 0 */ |
if(hx>hy) { /* x > y, x -= ulp */ |
hx -= 1; |
} else { /* x < y, x += ulp */ |
hx += 1; |
} |
} else { /* x < 0 */ |
if(hy>=0||hx>hy){ /* x < y, x -= ulp */ |
hx -= 1; |
} else { /* x > y, x += ulp */ |
hx += 1; |
} |
} |
hy = hx&0x7f800000; |
if(hy>FLT_UWORD_MAX) return x+x; /* overflow */ |
if(hy<0x00800000) { /* underflow */ |
y = x*x; |
if(y!=x) { /* raise underflow flag */ |
SET_FLOAT_WORD(y,hx); |
return y; |
} |
} |
SET_FLOAT_WORD(x,hx); |
return x; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double nextafter(double x, double y) |
#else |
double nextafter(x,y) |
double x,y; |
#endif |
{ |
return (double) nextafterf((float) x, (float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_pow10.c |
---|
0,0 → 1,47 |
/* sf_pow10.c -- float version of s_pow10.c. |
* Modification of sf_pow10.c by Yaakov Selkowitz 2007. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper pow10f(x) |
*/ |
#undef pow10f |
#include "fdlibm.h" |
#include <errno.h> |
#include <math.h> |
#ifdef __STDC__ |
float pow10f(float x) /* wrapper pow10f */ |
#else |
float pow10f(x) /* wrapper pow10f */ |
float x; |
#endif |
{ |
return powf(10.0, x); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double pow10(double x) |
#else |
double pow10(x) |
double x; |
#endif |
{ |
return (double) pow10f((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_remquo.c |
---|
0,0 → 1,130 |
/* Adapted for Newlib, 2009. (Allow for int < 32 bits; return *quo=0 during |
* errors to make test scripts easier.) */ |
/* @(#)e_fmod.c 1.3 95/01/18 */ |
/*- |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunSoft, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include <math.h> |
#include "fdlibm.h" |
/* For quotient, return either all 31 bits that can from calculation (using |
* int32_t), or as many as can fit into an int that is smaller than 32 bits. */ |
#if INT_MAX > 0x7FFFFFFFL |
#define QUO_MASK 0x7FFFFFFF |
# else |
#define QUO_MASK INT_MAX |
#endif |
static const float Zero[] = {0.0, -0.0,}; |
/* |
* Return the IEEE remainder and set *quo to the last n bits of the |
* quotient, rounded to the nearest integer. We choose n=31--if that many fit-- |
* we wind up computing all the integer bits of the quotient anyway as |
* a side-effect of computing the remainder by the shift and subtract |
* method. In practice, this is far more bits than are needed to use |
* remquo in reduction algorithms. |
*/ |
float |
remquof(float x, float y, int *quo) |
{ |
__int32_t n,hx,hy,hz,ix,iy,sx,i; |
__uint32_t q,sxy; |
GET_FLOAT_WORD(hx,x); |
GET_FLOAT_WORD(hy,y); |
sxy = (hx ^ hy) & 0x80000000; |
sx = hx&0x80000000; /* sign of x */ |
hx ^=sx; /* |x| */ |
hy &= 0x7fffffff; /* |y| */ |
/* purge off exception values */ |
if(hy==0||hx>=0x7f800000||hy>0x7f800000) { /* y=0,NaN;or x not finite */ |
*quo = 0; /* Not necessary, but return consistent value */ |
return (x*y)/(x*y); |
} |
if(hx<hy) { |
q = 0; |
goto fixup; /* |x|<|y| return x or x-y */ |
} else if(hx==hy) { |
*quo = 1; |
return Zero[(__uint32_t)sx>>31]; /* |x|=|y| return x*0*/ |
} |
/* determine ix = ilogb(x) */ |
if(hx<0x00800000) { /* subnormal x */ |
for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1; |
} else ix = (hx>>23)-127; |
/* determine iy = ilogb(y) */ |
if(hy<0x00800000) { /* subnormal y */ |
for (iy = -126,i=(hy<<8); i>0; i<<=1) iy -=1; |
} else iy = (hy>>23)-127; |
/* set up {hx,lx}, {hy,ly} and align y to x */ |
if(ix >= -126) |
hx = 0x00800000|(0x007fffff&hx); |
else { /* subnormal x, shift x to normal */ |
n = -126-ix; |
hx <<= n; |
} |
if(iy >= -126) |
hy = 0x00800000|(0x007fffff&hy); |
else { /* subnormal y, shift y to normal */ |
n = -126-iy; |
hy <<= n; |
} |
/* fix point fmod */ |
n = ix - iy; |
q = 0; |
while(n--) { |
hz=hx-hy; |
if(hz<0) hx = hx << 1; |
else {hx = hz << 1; q++;} |
q <<= 1; |
} |
hz=hx-hy; |
if(hz>=0) {hx=hz;q++;} |
/* convert back to floating value and restore the sign */ |
if(hx==0) { /* return sign(x)*0 */ |
*quo = (sxy ? -q : q); |
return Zero[(__uint32_t)sx>>31]; |
} |
while(hx<0x00800000) { /* normalize x */ |
hx <<= 1; |
iy -= 1; |
} |
if(iy>= -126) { /* normalize output */ |
hx = ((hx-0x00800000)|((iy+127)<<23)); |
} else { /* subnormal output */ |
n = -126 - iy; |
hx >>= n; |
} |
fixup: |
SET_FLOAT_WORD(x,hx); |
y = fabsf(y); |
if (y < 0x1p-125f) { |
if (x+x>y || (x+x==y && (q & 1))) { |
q++; |
x-=y; |
} |
} else if (x>0.5f*y || (x==0.5f*y && (q & 1))) { |
q++; |
x-=y; |
} |
GET_FLOAT_WORD(hx,x); |
SET_FLOAT_WORD(x,hx^sx); |
q &= 0x7fffffff; |
*quo = (sxy ? -q : q); |
return x; |
} |
/contrib/sdk/sources/libc/math/sf_rint.c |
---|
0,0 → 1,84 |
/* sf_rint.c -- float version of s_rint.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
TWO23[2]={ |
8.3886080000e+06, /* 0x4b000000 */ |
-8.3886080000e+06, /* 0xcb000000 */ |
}; |
#ifdef __STDC__ |
float rintf(float x) |
#else |
float rintf(x) |
float x; |
#endif |
{ |
__int32_t i0,j0,sx; |
__uint32_t i,i1,ix; |
float t; |
volatile float w; |
GET_FLOAT_WORD(i0,x); |
sx = (i0>>31)&1; |
ix = (i0&0x7fffffff); |
j0 = (ix>>23)-0x7f; |
if(j0<23) { |
if(FLT_UWORD_IS_ZERO(ix)) |
return x; |
if(j0<0) { |
i1 = (i0&0x07fffff); |
i0 &= 0xfff00000; |
i0 |= ((i1|-i1)>>9)&0x400000; |
SET_FLOAT_WORD(x,i0); |
w = TWO23[sx]+x; |
t = w-TWO23[sx]; |
GET_FLOAT_WORD(i0,t); |
SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31)); |
return t; |
} else { |
i = (0x007fffff)>>j0; |
if((i0&i)==0) return x; /* x is integral */ |
i>>=1; |
if((i0&i)!=0) i0 = (i0&(~i))|((0x200000)>>j0); |
} |
} else { |
if(!FLT_UWORD_IS_FINITE(ix)) return x+x; /* inf or NaN */ |
else |
return x; /* x is integral */ |
} |
SET_FLOAT_WORD(x,i0); |
w = TWO23[sx]+x; |
return w-TWO23[sx]; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double rint(double x) |
#else |
double rint(x) |
double x; |
#endif |
{ |
return (double) rintf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_round.c |
---|
0,0 → 1,74 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float roundf(float x) |
#else |
float roundf(x) |
float x; |
#endif |
{ |
__uint32_t w; |
/* Most significant word, least significant word. */ |
int exponent_less_127; |
GET_FLOAT_WORD(w, x); |
/* Extract exponent field. */ |
exponent_less_127 = (int)((w & 0x7f800000) >> 23) - 127; |
if (exponent_less_127 < 23) |
{ |
if (exponent_less_127 < 0) |
{ |
w &= 0x80000000; |
if (exponent_less_127 == -1) |
/* Result is +1.0 or -1.0. */ |
w |= ((__uint32_t)127 << 23); |
} |
else |
{ |
unsigned int exponent_mask = 0x007fffff >> exponent_less_127; |
if ((w & exponent_mask) == 0) |
/* x has an integral value. */ |
return x; |
w += 0x00400000 >> exponent_less_127; |
w &= ~exponent_mask; |
} |
} |
else |
{ |
if (exponent_less_127 == 128) |
/* x is NaN or infinite. */ |
return x + x; |
else |
return x; |
} |
SET_FLOAT_WORD(x, w); |
return x; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double round(double x) |
#else |
double round(x) |
double x; |
#endif |
{ |
return (double) roundf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_scalbln.c |
---|
0,0 → 1,71 |
/* s_scalbnf.c -- float version of s_scalbn.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
two25 = 3.355443200e+07, /* 0x4c000000 */ |
twom25 = 2.9802322388e-08, /* 0x33000000 */ |
huge = 1.0e+30, |
tiny = 1.0e-30; |
#ifdef __STDC__ |
float scalblnf (float x, long int n) |
#else |
float scalblnf (x,n) |
float x; long int n; |
#endif |
{ |
__int32_t k,ix; |
GET_FLOAT_WORD(ix,x); |
k = (ix&0x7f800000)>>23; /* extract exponent */ |
if (k==0) { /* 0 or subnormal x */ |
if ((ix&0x7fffffff)==0) return x; /* +-0 */ |
x *= two25; |
GET_FLOAT_WORD(ix,x); |
k = ((ix&0x7f800000)>>23) - 25; |
} |
if (k==0xff) return x+x; /* NaN or Inf */ |
k = k+n; |
if (n> 50000 || k > 0xfe) |
return huge*copysignf(huge,x); /* overflow */ |
if (n< -50000) |
return tiny*copysignf(tiny,x); /*underflow*/ |
if (k > 0) /* normal result */ |
{SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;} |
if (k <= -25) |
return tiny*copysignf(tiny,x); /*underflow*/ |
k += 25; /* subnormal result */ |
SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); |
return x*twom25; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double scalbln (double x, long int n) |
#else |
double scalbln (x,n) |
double x; long int n; |
#endif |
{ |
return (double) scalblnf((float) x, n); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_scalbn.c |
---|
0,0 → 1,86 |
/* sf_scalbn.c -- float version of s_scalbn.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#include <limits.h> |
#include <float.h> |
#if INT_MAX > 50000 |
#define OVERFLOW_INT 50000 |
#else |
#define OVERFLOW_INT 30000 |
#endif |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
two25 = 3.355443200e+07, /* 0x4c000000 */ |
twom25 = 2.9802322388e-08, /* 0x33000000 */ |
huge = 1.0e+30, |
tiny = 1.0e-30; |
#ifdef __STDC__ |
float scalbnf (float x, int n) |
#else |
float scalbnf (x,n) |
float x; int n; |
#endif |
{ |
__int32_t k,ix; |
__uint32_t hx; |
GET_FLOAT_WORD(ix,x); |
hx = ix&0x7fffffff; |
k = hx>>23; /* extract exponent */ |
if (FLT_UWORD_IS_ZERO(hx)) |
return x; |
if (!FLT_UWORD_IS_FINITE(hx)) |
return x+x; /* NaN or Inf */ |
if (FLT_UWORD_IS_SUBNORMAL(hx)) { |
x *= two25; |
GET_FLOAT_WORD(ix,x); |
k = ((ix&0x7f800000)>>23) - 25; |
if (n< -50000) return tiny*x; /*underflow*/ |
} |
k = k+n; |
if (k > FLT_LARGEST_EXP) return huge*copysignf(huge,x); /* overflow */ |
if (k > 0) /* normal result */ |
{SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;} |
if (k < FLT_SMALLEST_EXP) { |
if (n > OVERFLOW_INT) /* in case integer overflow in n+k */ |
return huge*copysignf(huge,x); /*overflow*/ |
else return tiny*copysignf(tiny,x); /*underflow*/ |
} |
k += 25; /* subnormal result */ |
SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); |
return x*twom25; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double scalbn(double x, int n) |
#else |
double scalbn(x,n) |
double x; |
int n; |
#endif |
{ |
return (double) scalbnf((float) x, n); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_signif.c |
---|
0,0 → 1,40 |
/* sf_signif.c -- float version of s_signif.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float significandf(float x) |
#else |
float significandf(x) |
float x; |
#endif |
{ |
return __ieee754_scalbf(x,(float) -ilogbf(x)); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double significand(double x) |
#else |
double significand(x) |
double x; |
#endif |
{ |
return (double) significandf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_sin.c |
---|
0,0 → 1,62 |
/* sf_sin.c -- float version of s_sin.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float sinf(float x) |
#else |
float sinf(x) |
float x; |
#endif |
{ |
float y[2],z=0.0; |
__int32_t n,ix; |
GET_FLOAT_WORD(ix,x); |
/* |x| ~< pi/4 */ |
ix &= 0x7fffffff; |
if(ix <= 0x3f490fd8) return __kernel_sinf(x,z,0); |
/* sin(Inf or NaN) is NaN */ |
else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; |
/* argument reduction needed */ |
else { |
n = __ieee754_rem_pio2f(x,y); |
switch(n&3) { |
case 0: return __kernel_sinf(y[0],y[1],1); |
case 1: return __kernel_cosf(y[0],y[1]); |
case 2: return -__kernel_sinf(y[0],y[1],1); |
default: |
return -__kernel_cosf(y[0],y[1]); |
} |
} |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double sin(double x) |
#else |
double sin(x) |
double x; |
#endif |
{ |
return (double) sinf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_tan.c |
---|
0,0 → 1,57 |
/* sf_tan.c -- float version of s_tan.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float tanf(float x) |
#else |
float tanf(x) |
float x; |
#endif |
{ |
float y[2],z=0.0; |
__int32_t n,ix; |
GET_FLOAT_WORD(ix,x); |
/* |x| ~< pi/4 */ |
ix &= 0x7fffffff; |
if(ix <= 0x3f490fda) return __kernel_tanf(x,z,1); |
/* tan(Inf or NaN) is NaN */ |
else if (!FLT_UWORD_IS_FINITE(ix)) return x-x; /* NaN */ |
/* argument reduction needed */ |
else { |
n = __ieee754_rem_pio2f(x,y); |
return __kernel_tanf(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even |
-1 -- n odd */ |
} |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double tan(double x) |
#else |
double tan(x) |
double x; |
#endif |
{ |
return (double) tanf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_tanh.c |
---|
0,0 → 1,73 |
/* sf_tanh.c -- float version of s_tanh.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
static const float one=1.0, two=2.0, tiny = 1.0e-30; |
#else |
static float one=1.0, two=2.0, tiny = 1.0e-30; |
#endif |
#ifdef __STDC__ |
float tanhf(float x) |
#else |
float tanhf(x) |
float x; |
#endif |
{ |
float t,z; |
__int32_t jx,ix; |
GET_FLOAT_WORD(jx,x); |
ix = jx&0x7fffffff; |
/* x is INF or NaN */ |
if(!FLT_UWORD_IS_FINITE(ix)) { |
if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */ |
else return one/x-one; /* tanh(NaN) = NaN */ |
} |
/* |x| < 22 */ |
if (ix < 0x41b00000) { /* |x|<22 */ |
if (ix<0x24000000) /* |x|<2**-55 */ |
return x*(one+x); /* tanh(small) = small */ |
if (ix>=0x3f800000) { /* |x|>=1 */ |
t = expm1f(two*fabsf(x)); |
z = one - two/(t+two); |
} else { |
t = expm1f(-two*fabsf(x)); |
z= -t/(t+two); |
} |
/* |x| > 22, return +-1 */ |
} else { |
z = one - tiny; /* raised inexact flag */ |
} |
return (jx>=0)? z: -z; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double tanh(double x) |
#else |
double tanh(x) |
double x; |
#endif |
{ |
return (double) tanhf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/sf_trunc.c |
---|
0,0 → 1,66 |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#ifdef __STDC__ |
float truncf(float x) |
#else |
float truncf(x) |
float x; |
#endif |
{ |
__int32_t signbit, w, exponent_less_127; |
GET_FLOAT_WORD(w,x); |
/* Extract sign bit. */ |
signbit = w & 0x80000000; |
/* Extract exponent field. */ |
exponent_less_127 = ((w & 0x7f800000) >> 23) - 127; |
if (exponent_less_127 < 23) |
{ |
if (exponent_less_127 < 0) |
{ |
/* -1 < x < 1, so result is +0 or -0. */ |
SET_FLOAT_WORD(x, signbit); |
} |
else |
{ |
SET_FLOAT_WORD(x, signbit | (w & ~(0x007fffff >> exponent_less_127))); |
} |
} |
else |
{ |
if (exponent_less_127 == 255) |
/* x is NaN or infinite. */ |
return x + x; |
/* All bits in the fraction field are relevant. */ |
} |
return x; |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double trunc(double x) |
#else |
double trunc(x) |
double x; |
#endif |
{ |
return (double) truncf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_acos.c |
---|
0,0 → 1,118 |
/* @(#)w_acos.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<acos>>, <<acosf>>---arc cosine |
INDEX |
acos |
INDEX |
acosf |
ANSI_SYNOPSIS |
#include <math.h> |
double acos(double <[x]>); |
float acosf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double acos(<[x]>) |
double <[x]>; |
float acosf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<acos>> computes the inverse cosine (arc cosine) of the input value. |
Arguments to <<acos>> must be in the range @minus{}1 to 1. |
<<acosf>> is identical to <<acos>>, except that it performs |
its calculations on <<floats>>. |
RETURNS |
@ifnottex |
<<acos>> and <<acosf>> return values in radians, in the range of 0 to pi. |
@end ifnottex |
@tex |
<<acos>> and <<acosf>> return values in radians, in the range of <<0>> to $\pi$. |
@end tex |
If <[x]> is not between @minus{}1 and 1, the returned value is NaN |
(not a number) the global variable <<errno>> is set to <<EDOM>>, and a |
<<DOMAIN error>> message is sent as standard error output. |
You can modify error handling for these functions using <<matherr>>. |
QUICKREF ANSI SVID POSIX RENTRANT |
acos y,y,y,m |
acosf n,n,n,m |
MATHREF |
acos, [-1,1], acos(arg),,, |
acos, NAN, arg,DOMAIN,EDOM |
MATHREF |
acosf, [-1,1], acosf(arg),,, |
acosf, NAN, argf,DOMAIN,EDOM |
*/ |
/* |
* wrap_acos(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double acos(double x) /* wrapper acos */ |
#else |
double acos(x) /* wrapper acos */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_acos(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_acos(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabs(x)>1.0) { |
/* acos(|x|>1) */ |
exc.type = DOMAIN; |
exc.name = "acos"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
exc.retval = nan(""); |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_acosh.c |
---|
0,0 → 1,122 |
/* @(#)w_acosh.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* |
FUNCTION |
<<acosh>>, <<acoshf>>---inverse hyperbolic cosine |
INDEX |
acosh |
INDEX |
acoshf |
ANSI_SYNOPSIS |
#include <math.h> |
double acosh(double <[x]>); |
float acoshf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double acosh(<[x]>) |
double <[x]>; |
float acoshf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<acosh>> calculates the inverse hyperbolic cosine of <[x]>. |
<<acosh>> is defined as |
@ifnottex |
. log(<[x]> + sqrt(<[x]>*<[x]>-1)) |
@end ifnottex |
@tex |
$$ln\Bigl(x + \sqrt{x^2-1}\Bigr)$$ |
@end tex |
<[x]> must be a number greater than or equal to 1. |
<<acoshf>> is identical, other than taking and returning floats. |
RETURNS |
<<acosh>> and <<acoshf>> return the calculated value. If <[x]> |
less than 1, the return value is NaN and <<errno>> is set to <<EDOM>>. |
You can change the error-handling behavior with the non-ANSI |
<<matherr>> function. |
PORTABILITY |
Neither <<acosh>> nor <<acoshf>> are ANSI C. They are not recommended |
for portable programs. |
QUICKREF ANSI SVID POSIX RENTRANT |
acos n,n,n,m |
acosf n,n,n,m |
MATHREF |
acosh, NAN, arg,DOMAIN,EDOM |
acosh, < 1.0, NAN,DOMAIN,EDOM |
acosh, >=1.0, acosh(arg),,, |
MATHREF |
acoshf, NAN, arg,DOMAIN,EDOM |
acoshf, < 1.0, NAN,DOMAIN,EDOM |
acoshf, >=1.0, acosh(arg),,, |
*/ |
/* |
* wrapper acosh(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double acosh(double x) /* wrapper acosh */ |
#else |
double acosh(x) /* wrapper acosh */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_acosh(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_acosh(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(x<1.0) { |
/* acosh(x<1) */ |
exc.type = DOMAIN; |
exc.name = "acosh"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
exc.retval = 0.0/0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_asin.c |
---|
0,0 → 1,121 |
/* @(#)w_asin.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* |
FUNCTION |
<<asin>>, <<asinf>>---arc sine |
INDEX |
asin |
INDEX |
asinf |
ANSI_SYNOPSIS |
#include <math.h> |
double asin(double <[x]>); |
float asinf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double asin(<[x]>) |
double <[x]>; |
float asinf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<asin>> computes the inverse sine (arc sine) of the argument <[x]>. |
Arguments to <<asin>> must be in the range @minus{}1 to 1. |
<<asinf>> is identical to <<asin>>, other than taking and |
returning floats. |
You can modify error handling for these routines using <<matherr>>. |
RETURNS |
@ifnottex |
<<asin>> returns values in radians, in the range of -pi/2 to pi/2. |
@end ifnottex |
@tex |
<<asin>> returns values in radians, in the range of $-\pi/2$ to $\pi/2$. |
@end tex |
If <[x]> is not in the range @minus{}1 to 1, <<asin>> and <<asinf>> |
return NaN (not a number), set the global variable <<errno>> to |
<<EDOM>>, and issue a <<DOMAIN error>> message. |
You can change this error treatment using <<matherr>>. |
QUICKREF ANSI SVID POSIX RENTRANT |
asin y,y,y,m |
asinf n,n,n,m |
MATHREF |
asin, -1<=arg<=1, asin(arg),,, |
asin, NAN, arg,EDOM, DOMAIN |
MATHREF |
asinf, -1<=arg<=1, asin(arg),,, |
asinf, NAN, arg,EDOM, DOMAIN |
*/ |
/* |
* wrapper asin(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double asin(double x) /* wrapper asin */ |
#else |
double asin(x) /* wrapper asin */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_asin(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_asin(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabs(x)>1.0) { |
/* asin(|x|>1) */ |
exc.type = DOMAIN; |
exc.name = "asin"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
exc.retval = nan(""); |
if(_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_atan2.c |
---|
0,0 → 1,90 |
/* @(#)w_atan2.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* |
FUNCTION |
<<atan2>>, <<atan2f>>---arc tangent of y/x |
INDEX |
atan2 |
INDEX |
atan2f |
ANSI_SYNOPSIS |
#include <math.h> |
double atan2(double <[y]>,double <[x]>); |
float atan2f(float <[y]>,float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double atan2(<[y]>,<[x]>); |
double <[y]>; |
double <[x]>; |
float atan2f(<[y]>,<[x]>); |
float <[y]>; |
float <[x]>; |
DESCRIPTION |
<<atan2>> computes the inverse tangent (arc tangent) of <[y]>/<[x]>. |
<<atan2>> produces the correct result even for angles near |
@ifnottex |
pi/2 or -pi/2 |
@end ifnottex |
@tex |
$\pi/2$ or $-\pi/2$ |
@end tex |
(that is, when <[x]> is near 0). |
<<atan2f>> is identical to <<atan2>>, save that it takes and returns |
<<float>>. |
RETURNS |
<<atan2>> and <<atan2f>> return a value in radians, in the range of |
@ifnottex |
-pi to pi. |
@end ifnottex |
@tex |
$-\pi$ to $\pi$. |
@end tex |
You can modify error handling for these functions using <<matherr>>. |
PORTABILITY |
<<atan2>> is ANSI C. <<atan2f>> is an extension. |
*/ |
/* |
* wrapper atan2(y,x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double atan2(double y, double x) /* wrapper atan2 */ |
#else |
double atan2(y,x) /* wrapper atan2 */ |
double y,x; |
#endif |
{ |
return __ieee754_atan2(y,x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_atanh.c |
---|
0,0 → 1,140 |
/* @(#)w_atanh.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<atanh>>, <<atanhf>>---inverse hyperbolic tangent |
INDEX |
atanh |
INDEX |
atanhf |
ANSI_SYNOPSIS |
#include <math.h> |
double atanh(double <[x]>); |
float atanhf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double atanh(<[x]>) |
double <[x]>; |
float atanhf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<atanh>> calculates the inverse hyperbolic tangent of <[x]>. |
<<atanhf>> is identical, other than taking and returning |
<<float>> values. |
RETURNS |
<<atanh>> and <<atanhf>> return the calculated value. |
If |
@ifnottex |
|<[x]>| |
@end ifnottex |
@tex |
$|x|$ |
@end tex |
is greater than 1, the global <<errno>> is set to <<EDOM>> and |
the result is a NaN. A <<DOMAIN error>> is reported. |
If |
@ifnottex |
|<[x]>| |
@end ifnottex |
@tex |
$|x|$ |
@end tex |
is 1, the global <<errno>> is set to <<EDOM>>; and the result is |
infinity with the same sign as <<x>>. A <<SING error>> is reported. |
You can modify the error handling for these routines using |
<<matherr>>. |
PORTABILITY |
Neither <<atanh>> nor <<atanhf>> are ANSI C. |
QUICKREF |
atanh - pure |
atanhf - pure |
*/ |
/* |
* wrapper atanh(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double atanh(double x) /* wrapper atanh */ |
#else |
double atanh(x) /* wrapper atanh */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_atanh(x); |
#else |
double z,y; |
struct exception exc; |
z = __ieee754_atanh(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
y = fabs(x); |
if(y>=1.0) { |
if(y>1.0) { |
/* atanh(|x|>1) */ |
exc.type = DOMAIN; |
exc.name = "atanh"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
exc.retval = 0.0/0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} else { |
/* atanh(|x|=1) */ |
exc.type = SING; |
exc.name = "atanh"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
exc.retval = x/0.0; /* sign(x)*inf */ |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_cosh.c |
---|
0,0 → 1,116 |
/* @(#)w_cosh.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<cosh>>, <<coshf>>---hyperbolic cosine |
ANSI_SYNOPSIS |
#include <math.h> |
double cosh(double <[x]>); |
float coshf(float <[x]>) |
TRAD_SYNOPSIS |
#include <math.h> |
double cosh(<[x]>) |
double <[x]>; |
float coshf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<cosh>> computes the hyperbolic cosine of the argument <[x]>. |
<<cosh(<[x]>)>> is defined as |
@ifnottex |
. (exp(x) + exp(-x))/2 |
@end ifnottex |
@tex |
$${(e^x + e^{-x})} \over 2$$ |
@end tex |
Angles are specified in radians. |
<<coshf>> is identical, save that it takes and returns <<float>>. |
RETURNS |
The computed value is returned. When the correct value would create |
an overflow, <<cosh>> returns the value <<HUGE_VAL>> with the |
appropriate sign, and the global value <<errno>> is set to <<ERANGE>>. |
You can modify error handling for these functions using the |
function <<matherr>>. |
PORTABILITY |
<<cosh>> is ANSI. |
<<coshf>> is an extension. |
QUICKREF |
cosh ansi pure |
coshf - pure |
*/ |
/* |
* wrapper cosh(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double cosh(double x) /* wrapper cosh */ |
#else |
double cosh(x) /* wrapper cosh */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_cosh(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_cosh(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabs(x)>7.10475860073943863426e+02) { |
/* cosh(finite) overflow */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = OVERFLOW; |
exc.name = "cosh"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_drem.c |
---|
0,0 → 1,15 |
/* |
* drem() wrapper for remainder(). |
* |
* Written by J.T. Conklin, <jtc@wimsey.com> |
* Placed into the Public Domain, 1994. |
*/ |
#include "fdlibm.h" |
double |
drem(x, y) |
double x, y; |
{ |
return remainder(x, y); |
} |
/contrib/sdk/sources/libc/math/w_exp.c |
---|
0,0 → 1,136 |
/* @(#)w_exp.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<exp>>, <<expf>>---exponential |
INDEX |
exp |
INDEX |
expf |
ANSI_SYNOPSIS |
#include <math.h> |
double exp(double <[x]>); |
float expf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double exp(<[x]>); |
double <[x]>; |
float expf(<[x]>); |
float <[x]>; |
DESCRIPTION |
<<exp>> and <<expf>> calculate the exponential of <[x]>, that is, |
@ifnottex |
e raised to the power <[x]> (where e |
@end ifnottex |
@tex |
$e^x$ (where $e$ |
@end tex |
is the base of the natural system of logarithms, approximately 2.71828). |
You can use the (non-ANSI) function <<matherr>> to specify |
error handling for these functions. |
RETURNS |
On success, <<exp>> and <<expf>> return the calculated value. |
If the result underflows, the returned value is <<0>>. If the |
result overflows, the returned value is <<HUGE_VAL>>. In |
either case, <<errno>> is set to <<ERANGE>>. |
PORTABILITY |
<<exp>> is ANSI C. <<expf>> is an extension. |
*/ |
/* |
* wrapper exp(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
static const double |
#else |
static double |
#endif |
o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ |
u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */ |
#ifdef __STDC__ |
double exp(double x) /* wrapper exp */ |
#else |
double exp(x) /* wrapper exp */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_exp(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_exp(x); |
if(_LIB_VERSION == _IEEE_) return z; |
if(finite(x)) { |
if(x>o_threshold) { |
/* exp(finite) overflow */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = OVERFLOW; |
exc.name = "exp"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else if(x<u_threshold) { |
/* exp(finite) underflow */ |
exc.type = UNDERFLOW; |
exc.name = "exp"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
} |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_exp2.c |
---|
0,0 → 1,70 |
/* @(#)w_exp2.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<exp2>>, <<exp2f>>--exponential, base 2 |
INDEX |
exp2 |
INDEX |
exp2f |
ANSI_SYNOPSIS |
#include <math.h> |
double exp2(double <[x]>); |
float exp2f(float <[x]>); |
DESCRIPTION |
<<exp2>> and <<exp2f>> calculate 2 ^ <[x]>, that is, |
@ifnottex |
2 raised to the power <[x]>. |
@end ifnottex |
@tex |
$2^x$ |
@end tex |
You can use the (non-ANSI) function <<matherr>> to specify |
error handling for these functions. |
RETURNS |
On success, <<exp2>> and <<exp2f>> return the calculated value. |
If the result underflows, the returned value is <<0>>. If the |
result overflows, the returned value is <<HUGE_VAL>>. In |
either case, <<errno>> is set to <<ERANGE>>. |
PORTABILITY |
ANSI C, POSIX. |
*/ |
/* |
* wrapper exp2(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#include <math.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double exp2(double x) /* wrapper exp2 */ |
#else |
double exp2(x) /* wrapper exp2 */ |
double x; |
#endif |
{ |
return pow(2.0, x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_fmod.c |
---|
0,0 → 1,107 |
/* @(#)w_fmod.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<fmod>>, <<fmodf>>---floating-point remainder (modulo) |
INDEX |
fmod |
INDEX |
fmodf |
ANSI_SYNOPSIS |
#include <math.h> |
double fmod(double <[x]>, double <[y]>) |
float fmodf(float <[x]>, float <[y]>) |
TRAD_SYNOPSIS |
#include <math.h> |
double fmod(<[x]>, <[y]>) |
double (<[x]>, <[y]>); |
float fmodf(<[x]>, <[y]>) |
float (<[x]>, <[y]>); |
DESCRIPTION |
The <<fmod>> and <<fmodf>> functions compute the floating-point |
remainder of <[x]>/<[y]> (<[x]> modulo <[y]>). |
RETURNS |
The <<fmod>> function returns the value |
@ifnottex |
<[x]>-<[i]>*<[y]>, |
@end ifnottex |
@tex |
$x-i\times y$, |
@end tex |
for the largest integer <[i]> such that, if <[y]> is nonzero, the |
result has the same sign as <[x]> and magnitude less than the |
magnitude of <[y]>. |
<<fmod(<[x]>,0)>> returns NaN, and sets <<errno>> to <<EDOM>>. |
You can modify error treatment for these functions using <<matherr>>. |
PORTABILITY |
<<fmod>> is ANSI C. <<fmodf>> is an extension. |
*/ |
/* |
* wrapper fmod(x,y) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fmod(double x, double y) /* wrapper fmod */ |
#else |
double fmod(x,y) /* wrapper fmod */ |
double x,y; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_fmod(x,y); |
#else |
double z; |
struct exception exc; |
z = __ieee754_fmod(x,y); |
if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z; |
if(y==0.0) { |
/* fmod(x,0) */ |
exc.type = DOMAIN; |
exc.name = "fmod"; |
exc.arg1 = x; |
exc.arg2 = y; |
exc.err = 0; |
if (_LIB_VERSION == _SVID_) |
exc.retval = x; |
else |
exc.retval = 0.0/0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_gamma.c |
---|
0,0 → 1,226 |
/* @(#)w_gamma.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* BUG: FIXME? |
According to Linux man pages for tgamma, lgamma, and gamma, the gamma |
function was originally defined in BSD as implemented here--the log of the gamma |
function. BSD 4.3 changed the name to lgamma, apparently removing gamma. BSD |
4.4 re-introduced the gamma name with the more intuitive, without logarithm, |
plain gamma function. The C99 standard apparently wanted to avoid a problem |
with the poorly-named earlier gamma and used tgamma when adding a plain |
gamma function. |
So the current gamma is matching an old, bad definition, and not |
matching a newer, better definition. */ |
/* |
FUNCTION |
<<gamma>>, <<gammaf>>, <<lgamma>>, <<lgammaf>>, <<gamma_r>>, <<gammaf_r>>, <<lgamma_r>>, <<lgammaf_r>>, <<tgamma>>, and <<tgammaf>>--logarithmic and plain gamma functions |
INDEX |
gamma |
INDEX |
gammaf |
INDEX |
lgamma |
INDEX |
lgammaf |
INDEX |
gamma_r |
INDEX |
gammaf_r |
INDEX |
lgamma_r |
INDEX |
lgammaf_r |
INDEX |
tgamma |
INDEX |
tgammaf |
ANSI_SYNOPSIS |
#include <math.h> |
double gamma(double <[x]>); |
float gammaf(float <[x]>); |
double lgamma(double <[x]>); |
float lgammaf(float <[x]>); |
double gamma_r(double <[x]>, int *<[signgamp]>); |
float gammaf_r(float <[x]>, int *<[signgamp]>); |
double lgamma_r(double <[x]>, int *<[signgamp]>); |
float lgammaf_r(float <[x]>, int *<[signgamp]>); |
double tgamma(double <[x]>); |
float tgammaf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double gamma(<[x]>) |
double <[x]>; |
float gammaf(<[x]>) |
float <[x]>; |
double lgamma(<[x]>) |
double <[x]>; |
float lgammaf(<[x]>) |
float <[x]>; |
double gamma_r(<[x]>, <[signgamp]>) |
double <[x]>; |
int <[signgamp]>; |
float gammaf_r(<[x]>, <[signgamp]>) |
float <[x]>; |
int <[signgamp]>; |
double lgamma_r(<[x]>, <[signgamp]>) |
double <[x]>; |
int <[signgamp]>; |
float lgammaf_r(<[x]>, <[signgamp]>) |
float <[x]>; |
int <[signgamp]>; |
double tgamma(<[x]>) |
double <[x]>; |
float tgammaf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<gamma>> calculates |
@tex |
$\mit ln\bigl(\Gamma(x)\bigr)$, |
@end tex |
the natural logarithm of the gamma function of <[x]>. The gamma function |
(<<exp(gamma(<[x]>))>>) is a generalization of factorial, and retains |
the property that |
@ifnottex |
<<exp(gamma(N))>> is equivalent to <<N*exp(gamma(N-1))>>. |
@end ifnottex |
@tex |
$\mit \Gamma(N)\equiv N\times\Gamma(N-1)$. |
@end tex |
Accordingly, the results of the gamma function itself grow very |
quickly. <<gamma>> is defined as |
@tex |
$\mit ln\bigl(\Gamma(x)\bigr)$ rather than simply $\mit \Gamma(x)$ |
@end tex |
@ifnottex |
the natural log of the gamma function, rather than the gamma function |
itself, |
@end ifnottex |
to extend the useful range of results representable. |
The sign of the result is returned in the global variable <<signgam>>, |
which is declared in math.h. |
<<gammaf>> performs the same calculation as <<gamma>>, but uses and |
returns <<float>> values. |
<<lgamma>> and <<lgammaf>> are alternate names for <<gamma>> and |
<<gammaf>>. The use of <<lgamma>> instead of <<gamma>> is a reminder |
that these functions compute the log of the gamma function, rather |
than the gamma function itself. |
The functions <<gamma_r>>, <<gammaf_r>>, <<lgamma_r>>, and |
<<lgammaf_r>> are just like <<gamma>>, <<gammaf>>, <<lgamma>>, and |
<<lgammaf>>, respectively, but take an additional argument. This |
additional argument is a pointer to an integer. This additional |
argument is used to return the sign of the result, and the global |
variable <<signgam>> is not used. These functions may be used for |
reentrant calls (but they will still set the global variable <<errno>> |
if an error occurs). |
<<tgamma>> and <<tgammaf>> are the "true gamma" functions, returning |
@tex |
$\mit \Gamma(x)$, |
@end tex |
the gamma function of <[x]>--without a logarithm. |
(They are apparently so named because of the prior existence of the old, |
poorly-named <<gamma>> functions which returned the log of gamma up |
through BSD 4.2.) |
RETURNS |
Normally, the computed result is returned. |
When <[x]> is a nonpositive integer, <<gamma>> returns <<HUGE_VAL>> |
and <<errno>> is set to <<EDOM>>. If the result overflows, <<gamma>> |
returns <<HUGE_VAL>> and <<errno>> is set to <<ERANGE>>. |
You can modify this error treatment using <<matherr>>. |
PORTABILITY |
Neither <<gamma>> nor <<gammaf>> is ANSI C. It is better not to use either |
of these; use <<lgamma>> or <<tgamma>> instead.@* |
<<lgamma>>, <<lgammaf>>, <<tgamma>>, and <<tgammaf>> are nominally C standard |
in terms of the base return values, although the <<matherr>> error-handling |
is not standard, nor is the <[signgam]> global for <<lgamma>>. |
*/ |
/* double gamma(double x) |
* Return the logarithm of the Gamma function of x. |
* |
* Method: call gamma_r |
*/ |
#include "fdlibm.h" |
#include <reent.h> |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double gamma(double x) |
#else |
double gamma(x) |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_gamma_r(x,&(_REENT_SIGNGAM(_REENT))); |
#else |
double y; |
struct exception exc; |
y = __ieee754_gamma_r(x,&(_REENT_SIGNGAM(_REENT))); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finite(y)&&finite(x)) { |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "gamma"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if(floor(x)==x&&x<=0.0) { |
/* gamma(-integer) or gamma(0) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} else { |
/* gamma(finite) overflow */ |
exc.type = OVERFLOW; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return y; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_hypot.c |
---|
0,0 → 1,109 |
/* @(#)w_hypot.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<hypot>>, <<hypotf>>---distance from origin |
INDEX |
hypot |
INDEX |
hypotf |
ANSI_SYNOPSIS |
#include <math.h> |
double hypot(double <[x]>, double <[y]>); |
float hypotf(float <[x]>, float <[y]>); |
TRAD_SYNOPSIS |
double hypot(<[x]>, <[y]>) |
double <[x]>, <[y]>; |
float hypotf(<[x]>, <[y]>) |
float <[x]>, <[y]>; |
DESCRIPTION |
<<hypot>> calculates the Euclidean distance |
@tex |
$\sqrt{x^2+y^2}$ |
@end tex |
@ifnottex |
<<sqrt(<[x]>*<[x]> + <[y]>*<[y]>)>> |
@end ifnottex |
between the origin (0,0) and a point represented by the |
Cartesian coordinates (<[x]>,<[y]>). <<hypotf>> differs only |
in the type of its arguments and result. |
RETURNS |
Normally, the distance value is returned. On overflow, |
<<hypot>> returns <<HUGE_VAL>> and sets <<errno>> to |
<<ERANGE>>. |
You can change the error treatment with <<matherr>>. |
PORTABILITY |
<<hypot>> and <<hypotf>> are not ANSI C. */ |
/* |
* wrapper hypot(x,y) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double hypot(double x, double y)/* wrapper hypot */ |
#else |
double hypot(x,y) /* wrapper hypot */ |
double x,y; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_hypot(x,y); |
#else |
double z; |
struct exception exc; |
z = __ieee754_hypot(x,y); |
if(_LIB_VERSION == _IEEE_) return z; |
if((!finite(z))&&finite(x)&&finite(y)) { |
/* hypot(finite,finite) overflow */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = OVERFLOW; |
exc.name = "hypot"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = y; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_j0.c |
---|
0,0 → 1,229 |
/* @(#)w_j0.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<jN>>, <<jNf>>, <<yN>>, <<yNf>>---Bessel functions |
INDEX |
j0 |
INDEX |
j0f |
INDEX |
j1 |
INDEX |
j1f |
INDEX |
jn |
INDEX |
jnf |
INDEX |
y0 |
INDEX |
y0f |
INDEX |
y1 |
INDEX |
y1f |
INDEX |
yn |
INDEX |
ynf |
ANSI_SYNOPSIS |
#include <math.h> |
double j0(double <[x]>); |
float j0f(float <[x]>); |
double j1(double <[x]>); |
float j1f(float <[x]>); |
double jn(int <[n]>, double <[x]>); |
float jnf(int <[n]>, float <[x]>); |
double y0(double <[x]>); |
float y0f(float <[x]>); |
double y1(double <[x]>); |
float y1f(float <[x]>); |
double yn(int <[n]>, double <[x]>); |
float ynf(int <[n]>, float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double j0(<[x]>) |
double <[x]>; |
float j0f(<[x]>) |
float <[x]>; |
double j1(<[x]>) |
double <[x]>; |
float j1f(<[x]>) |
float <[x]>; |
double jn(<[n]>, <[x]>) |
int <[n]>; |
double <[x]>; |
float jnf(<[n]>, <[x]>) |
int <[n]>; |
float <[x]>; |
double y0(<[x]>) |
double <[x]>; |
float y0f(<[x]>) |
float <[x]>; |
double y1(<[x]>) |
double <[x]>; |
float y1f(<[x]>) |
float <[x]>; |
double yn(<[n]>, <[x]>) |
int <[n]>; |
double <[x]>; |
float ynf(<[n]>, <[x]>) |
int <[n]>; |
float <[x]>; |
DESCRIPTION |
The Bessel functions are a family of functions that solve the |
differential equation |
@ifnottex |
. 2 2 2 |
. x y'' + xy' + (x - p )y = 0 |
@end ifnottex |
@tex |
$$x^2{d^2y\over dx^2} + x{dy\over dx} + (x^2-p^2)y = 0$$ |
@end tex |
These functions have many applications in engineering and physics. |
<<jn>> calculates the Bessel function of the first kind of order |
<[n]>. <<j0>> and <<j1>> are special cases for order 0 and order |
1 respectively. |
Similarly, <<yn>> calculates the Bessel function of the second kind of |
order <[n]>, and <<y0>> and <<y1>> are special cases for order 0 and |
1. |
<<jnf>>, <<j0f>>, <<j1f>>, <<ynf>>, <<y0f>>, and <<y1f>> perform the |
same calculations, but on <<float>> rather than <<double>> values. |
RETURNS |
The value of each Bessel function at <[x]> is returned. |
PORTABILITY |
None of the Bessel functions are in ANSI C. |
*/ |
/* |
* wrapper j0(double x), y0(double x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double j0(double x) /* wrapper j0 */ |
#else |
double j0(x) /* wrapper j0 */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_j0(x); |
#else |
struct exception exc; |
double z = __ieee754_j0(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabs(x)>X_TLOSS) { |
/* j0(|x|>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "j0"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef __STDC__ |
double y0(double x) /* wrapper y0 */ |
#else |
double y0(x) /* wrapper y0 */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_y0(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_y0(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(x <= 0.0){ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
/* y0(0) = -inf or y0(x<0) = NaN */ |
exc.type = DOMAIN; /* should be SING for IEEE y0(0) */ |
exc.name = "y0"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
if(x>X_TLOSS) { |
/* y0(x>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "y0"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_j1.c |
---|
0,0 → 1,121 |
/* @(#)w_j1.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper of j1,y1 |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double j1(double x) /* wrapper j1 */ |
#else |
double j1(x) /* wrapper j1 */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_j1(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_j1(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(fabs(x)>X_TLOSS) { |
/* j1(|x|>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "j1"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef __STDC__ |
double y1(double x) /* wrapper y1 */ |
#else |
double y1(x) /* wrapper y1 */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_y1(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_y1(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(x <= 0.0){ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
/* y1(0) = -inf or y1(x<0) = NaN */ |
exc.type = DOMAIN; /* should be SING for IEEE */ |
exc.name = "y1"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
if(x>X_TLOSS) { |
/* y1(x>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "y1"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_jn.c |
---|
0,0 → 1,141 |
/* @(#)w_jn.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper jn(int n, double x), yn(int n, double x) |
* floating point Bessel's function of the 1st and 2nd kind |
* of order n |
* |
* Special cases: |
* y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; |
* y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. |
* Note 2. About jn(n,x), yn(n,x) |
* For n=0, j0(x) is called, |
* for n=1, j1(x) is called, |
* for n<x, forward recursion us used starting |
* from values of j0(x) and j1(x). |
* for n>x, a continued fraction approximation to |
* j(n,x)/j(n-1,x) is evaluated and then backward |
* recursion is used starting from a supposed value |
* for j(n,x). The resulting value of j(0,x) is |
* compared with the actual value to correct the |
* supposed value of j(n,x). |
* |
* yn(n,x) is similar in all respects, except |
* that forward recursion is used for all |
* values of n>1. |
* |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double jn(int n, double x) /* wrapper jn */ |
#else |
double jn(n,x) /* wrapper jn */ |
double x; int n; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_jn(n,x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_jn(n,x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(fabs(x)>X_TLOSS) { |
/* jn(|x|>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "jn"; |
exc.err = 0; |
exc.arg1 = n; |
exc.arg2 = x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef __STDC__ |
double yn(int n, double x) /* wrapper yn */ |
#else |
double yn(n,x) /* wrapper yn */ |
double x; int n; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_yn(n,x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_yn(n,x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(x <= 0.0){ |
/* yn(n,0) = -inf or yn(x<0) = NaN */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = DOMAIN; /* should be SING for IEEE */ |
exc.name = "yn"; |
exc.err = 0; |
exc.arg1 = n; |
exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
if(x>X_TLOSS) { |
/* yn(x>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "yn"; |
exc.err = 0; |
exc.arg1 = n; |
exc.arg2 = x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_lgamma.c |
---|
0,0 → 1,89 |
/* @(#)w_lgamma.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* double lgamma(double x) |
* Return the logarithm of the Gamma function of x. |
* |
* Method: call __ieee754_lgamma_r |
*/ |
#include "fdlibm.h" |
#include <reent.h> |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double lgamma(double x) |
#else |
double lgamma(x) |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_lgamma_r(x,&(_REENT_SIGNGAM(_REENT))); |
#else |
double y; |
struct exception exc; |
y = __ieee754_lgamma_r(x,&(_REENT_SIGNGAM(_REENT))); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finite(y)&&finite(x)) { |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "lgamma"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if(floor(x)==x&&x<=0.0) { |
/* lgamma(-integer) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} else { |
/* lgamma(finite) overflow */ |
exc.type = OVERFLOW; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return y; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_log.c |
---|
0,0 → 1,116 |
/* @(#)w_log.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<log>>, <<logf>>---natural logarithms |
INDEX |
log |
INDEX |
logf |
ANSI_SYNOPSIS |
#include <math.h> |
double log(double <[x]>); |
float logf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double log(<[x]>); |
double <[x]>; |
float logf(<[x]>); |
float <[x]>; |
DESCRIPTION |
Return the natural logarithm of <[x]>, that is, its logarithm base e |
(where e is the base of the natural system of logarithms, 2.71828@dots{}). |
<<log>> and <<logf>> are identical save for the return and argument types. |
You can use the (non-ANSI) function <<matherr>> to specify error |
handling for these functions. |
RETURNS |
Normally, returns the calculated value. When <[x]> is zero, the |
returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>. |
When <[x]> is negative, the returned value is NaN (not a number) and |
<<errno>> is set to <<EDOM>>. You can control the error behavior via |
<<matherr>>. |
PORTABILITY |
<<log>> is ANSI. <<logf>> is an extension. |
*/ |
/* |
* wrapper log(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double log(double x) /* wrapper log */ |
#else |
double log(x) /* wrapper log */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_log(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_log(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) || x > 0.0) return z; |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "log"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if(x==0.0) { |
/* log(0) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} else { |
/* log(x<0) */ |
exc.type = DOMAIN; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
exc.retval = nan(""); |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_log10.c |
---|
0,0 → 1,116 |
/* @(#)w_log10.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<log10>>, <<log10f>>---base 10 logarithms |
INDEX |
log10 |
INDEX |
log10f |
ANSI_SYNOPSIS |
#include <math.h> |
double log10(double <[x]>); |
float log10f(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double log10(<[x]>) |
double <[x]>; |
float log10f(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<log10>> returns the base 10 logarithm of <[x]>. |
It is implemented as <<log(<[x]>) / log(10)>>. |
<<log10f>> is identical, save that it takes and returns <<float>> values. |
RETURNS |
<<log10>> and <<log10f>> return the calculated value. |
See the description of <<log>> for information on errors. |
PORTABILITY |
<<log10>> is ANSI C. <<log10f>> is an extension. |
*/ |
/* |
* wrapper log10(X) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double log10(double x) /* wrapper log10 */ |
#else |
double log10(x) /* wrapper log10 */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_log10(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_log10(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(x<=0.0) { |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "log10"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if(x==0.0) { |
/* log10(0) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} else { |
/* log10(x<0) */ |
exc.type = DOMAIN; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
exc.retval = nan(""); |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_pow.c |
---|
0,0 → 1,231 |
/* @(#)w_pow.c 5.2 93/10/01 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<pow>>, <<powf>>---x to the power y |
INDEX |
pow |
INDEX |
powf |
ANSI_SYNOPSIS |
#include <math.h> |
double pow(double <[x]>, double <[y]>); |
float powf(float <[x]>, float <[y]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double pow(<[x]>, <[y]>); |
double <[x]>, <[y]>; |
float powf(<[x]>, <[y]>); |
float <[x]>, <[y]>; |
DESCRIPTION |
<<pow>> and <<powf>> calculate <[x]> raised to the exponent <[y]>. |
@tex |
(That is, $x^y$.) |
@end tex |
RETURNS |
On success, <<pow>> and <<powf>> return the value calculated. |
When the argument values would produce overflow, <<pow>> |
returns <<HUGE_VAL>> and set <<errno>> to <<ERANGE>>. If the |
argument <[x]> passed to <<pow>> or <<powf>> is a negative |
noninteger, and <[y]> is also not an integer, then <<errno>> |
is set to <<EDOM>>. If <[x]> and <[y]> are both 0, then |
<<pow>> and <<powf>> return <<1>>. |
You can modify error handling for these functions using <<matherr>>. |
PORTABILITY |
<<pow>> is ANSI C. <<powf>> is an extension. */ |
/* |
* wrapper pow(x,y) return x**y |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double pow(double x, double y) /* wrapper pow */ |
#else |
double pow(x,y) /* wrapper pow */ |
double x,y; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_pow(x,y); |
#else |
double z; |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
struct exception exc; |
z=__ieee754_pow(x,y); |
if(_LIB_VERSION == _IEEE_|| isnan(y)) return z; |
if(isnan(x)) { |
if(y==0.0) { |
/* pow(NaN,0.0) */ |
/* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ |
exc.type = DOMAIN; |
exc.name = "pow"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = y; |
exc.retval = 1.0; |
if (_LIB_VERSION == _IEEE_ || |
_LIB_VERSION == _POSIX_) exc.retval = 1.0; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
} |
if(x==0.0){ |
if(y==0.0) { |
/* pow(0.0,0.0) */ |
/* error only if _LIB_VERSION == _SVID_ */ |
exc.type = DOMAIN; |
exc.name = "pow"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = y; |
exc.retval = 0.0; |
if (_LIB_VERSION != _SVID_) exc.retval = 1.0; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
if(finite(y)&&y<0.0) { |
/* 0**neg */ |
exc.type = DOMAIN; |
exc.name = "pow"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = y; |
if (_LIB_VERSION == _SVID_) |
exc.retval = 0.0; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
return z; |
} |
if(!finite(z)) { |
if(finite(x)&&finite(y)) { |
if(isnan(z)) { |
/* neg**non-integral */ |
exc.type = DOMAIN; |
exc.name = "pow"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = y; |
if (_LIB_VERSION == _SVID_) |
exc.retval = 0.0; |
else |
exc.retval = 0.0/0.0; /* X/Open allow NaN */ |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else { |
/* pow(x,y) overflow */ |
exc.type = OVERFLOW; |
exc.name = "pow"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = y; |
if (_LIB_VERSION == _SVID_) { |
exc.retval = HUGE; |
y *= 0.5; |
if(x<0.0&&rint(y)!=y) exc.retval = -HUGE; |
} else { |
exc.retval = HUGE_VAL; |
y *= 0.5; |
if(x<0.0&&rint(y)!=y) exc.retval = -HUGE_VAL; |
} |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
} |
} |
if(z==0.0&&finite(x)&&finite(y)) { |
/* pow(x,y) underflow */ |
exc.type = UNDERFLOW; |
exc.name = "pow"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = y; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_remainder.c |
---|
0,0 → 1,108 |
/* @(#)w_remainder.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<remainder>>, <<remainderf>>---round and remainder |
INDEX |
remainder |
INDEX |
remainderf |
ANSI_SYNOPSIS |
#include <math.h> |
double remainder(double <[x]>, double <[y]>); |
float remainderf(float <[x]>, float <[y]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double remainder(<[x]>,<[y]>) |
double <[x]>, <[y]>; |
float remainderf(<[x]>,<[y]>) |
float <[x]>, <[y]>; |
DESCRIPTION |
<<remainder>> and <<remainderf>> find the remainder of |
<[x]>/<[y]>; this value is in the range -<[y]>/2 .. +<[y]>/2. |
RETURNS |
<<remainder>> returns the integer result as a double. |
PORTABILITY |
<<remainder>> is a System V release 4. |
<<remainderf>> is an extension. |
*/ |
/* |
* wrapper remainder(x,p) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double remainder(double x, double y) /* wrapper remainder */ |
#else |
double remainder(x,y) /* wrapper remainder */ |
double x,y; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_remainder(x,y); |
#else |
double z; |
struct exception exc; |
z = __ieee754_remainder(x,y); |
if(_LIB_VERSION == _IEEE_ || isnan(y)) return z; |
if(y==0.0) { |
/* remainder(x,0) */ |
exc.type = DOMAIN; |
exc.name = "remainder"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = y; |
exc.retval = 0.0/0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_scalb.c |
---|
0,0 → 1,94 |
/* @(#)w_scalb.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper scalb(double x, double fn) is provide for |
* passing various standard test suite. One |
* should use scalbn() instead. |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
#ifdef _SCALB_INT |
double scalb(double x, int fn) /* wrapper scalb */ |
#else |
double scalb(double x, double fn) /* wrapper scalb */ |
#endif |
#else |
double scalb(x,fn) /* wrapper scalb */ |
#ifdef _SCALB_INT |
double x; int fn; |
#else |
double x,fn; |
#endif |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_scalb(x,fn); |
#else |
double z; |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
struct exception exc; |
z = __ieee754_scalb(x,fn); |
if(_LIB_VERSION == _IEEE_) return z; |
if(!(finite(z)||isnan(z))&&finite(x)) { |
/* scalb overflow; SVID also returns +-HUGE_VAL */ |
exc.type = OVERFLOW; |
exc.name = "scalb"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = fn; |
exc.retval = x > 0.0 ? HUGE_VAL : -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
if(z==0.0&&z!=x) { |
/* scalb underflow */ |
exc.type = UNDERFLOW; |
exc.name = "scalb"; |
exc.err = 0; |
exc.arg1 = x; |
exc.arg2 = fn; |
exc.retval = copysign(0.0,x); |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
#ifndef _SCALB_INT |
if(!finite(fn)) errno = ERANGE; |
#endif |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_sincos.c |
---|
0,0 → 1,22 |
/* sincos -- currently no more efficient than two separate calls to |
sin and cos. */ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
void sincos(double x, double *sinx, double *cosx) |
#else |
void sincos(x, sinx, cosx) |
double x; |
double *sinx; |
double *cosx; |
#endif |
{ |
*sinx = sin (x); |
*cosx = cos (x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_sinh.c |
---|
0,0 → 1,120 |
/* @(#)w_sinh.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<sinh>>, <<sinhf>>---hyperbolic sine |
INDEX |
sinh |
INDEX |
sinhf |
ANSI_SYNOPSIS |
#include <math.h> |
double sinh(double <[x]>); |
float sinhf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double sinh(<[x]>) |
double <[x]>; |
float sinhf(<[x]>) |
float <[x]>; |
DESCRIPTION |
<<sinh>> computes the hyperbolic sine of the argument <[x]>. |
Angles are specified in radians. <<sinh>>(<[x]>) is defined as |
@ifnottex |
. (exp(<[x]>) - exp(-<[x]>))/2 |
@end ifnottex |
@tex |
$${e^x - e^{-x}}\over 2$$ |
@end tex |
<<sinhf>> is identical, save that it takes and returns <<float>> values. |
RETURNS |
The hyperbolic sine of <[x]> is returned. |
When the correct result is too large to be representable (an |
overflow), <<sinh>> returns <<HUGE_VAL>> with the |
appropriate sign, and sets the global value <<errno>> to |
<<ERANGE>>. |
You can modify error handling for these functions with <<matherr>>. |
PORTABILITY |
<<sinh>> is ANSI C. |
<<sinhf>> is an extension. |
QUICKREF |
sinh ansi pure |
sinhf - pure |
*/ |
/* |
* wrapper sinh(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double sinh(double x) /* wrapper sinh */ |
#else |
double sinh(x) /* wrapper sinh */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_sinh(x); |
#else |
double z; |
struct exception exc; |
z = __ieee754_sinh(x); |
if(_LIB_VERSION == _IEEE_) return z; |
if(!finite(z)&&finite(x)) { |
/* sinh(finite) overflow */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = OVERFLOW; |
exc.name = "sinh"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = ( (x>0.0) ? HUGE : -HUGE); |
else |
exc.retval = ( (x>0.0) ? HUGE_VAL : -HUGE_VAL); |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_sqrt.c |
---|
0,0 → 1,93 |
/* @(#)w_sqrt.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
FUNCTION |
<<sqrt>>, <<sqrtf>>---positive square root |
INDEX |
sqrt |
INDEX |
sqrtf |
ANSI_SYNOPSIS |
#include <math.h> |
double sqrt(double <[x]>); |
float sqrtf(float <[x]>); |
TRAD_SYNOPSIS |
#include <math.h> |
double sqrt(<[x]>); |
float sqrtf(<[x]>); |
DESCRIPTION |
<<sqrt>> computes the positive square root of the argument. |
You can modify error handling for this function with |
<<matherr>>. |
RETURNS |
On success, the square root is returned. If <[x]> is real and |
positive, then the result is positive. If <[x]> is real and |
negative, the global value <<errno>> is set to <<EDOM>> (domain error). |
PORTABILITY |
<<sqrt>> is ANSI C. <<sqrtf>> is an extension. |
*/ |
/* |
* wrapper sqrt(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double sqrt(double x) /* wrapper sqrt */ |
#else |
double sqrt(x) /* wrapper sqrt */ |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_sqrt(x); |
#else |
struct exception exc; |
double z; |
z = __ieee754_sqrt(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(x<0.0) { |
exc.type = DOMAIN; |
exc.name = "sqrt"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = 0.0; |
else |
exc.retval = 0.0/0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/w_tgamma.c |
---|
0,0 → 1,48 |
/* @(#)w_gamma.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* double gamma(double x) |
* Return the logarithm of the Gamma function of x or the Gamma function of x, |
* depending on the library mode. |
*/ |
#include "fdlibm.h" |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double tgamma(double x) |
#else |
double tgamma(x) |
double x; |
#endif |
{ |
double y; |
int local_signgam; |
y = __ieee754_gamma_r(x,&local_signgam); |
if (local_signgam < 0) y = -y; |
#ifdef _IEEE_LIBM |
return y; |
#else |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finite(y)&&finite(x)) { |
if(floor(x)==x&&x<=0.0) |
return __kernel_standard(x,x,41); /* tgamma pole */ |
else |
return __kernel_standard(x,x,40); /* tgamma overflow */ |
} |
return y; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_acos.c |
---|
0,0 → 1,69 |
/* wf_acos.c -- float version of w_acos.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrap_acosf(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef _HAVE_STDC |
float acosf(float x) /* wrapper acosf */ |
#else |
float acosf(x) /* wrapper acosf */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_acosf(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_acosf(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabsf(x)>(float)1.0) { |
/* acosf(|x|>1) */ |
exc.type = DOMAIN; |
exc.name = "acosf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
exc.retval = nan(""); |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double acos(double x) |
#else |
double acos(x) |
double x; |
#endif |
{ |
return (double) acosf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_acosh.c |
---|
0,0 → 1,70 |
/* wf_acosh.c -- float version of w_acosh.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* |
* wrapper acoshf(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float acoshf(float x) /* wrapper acoshf */ |
#else |
float acoshf(x) /* wrapper acoshf */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_acoshf(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_acoshf(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(x<(float)1.0) { |
/* acoshf(x<1) */ |
exc.type = DOMAIN; |
exc.name = "acoshf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
exc.retval = 0.0/0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double acosh(double x) |
#else |
double acosh(x) |
double x; |
#endif |
{ |
return (double) acoshf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_asin.c |
---|
0,0 → 1,71 |
/* wf_asin.c -- float version of w_asin.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* |
* wrapper asinf(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float asinf(float x) /* wrapper asinf */ |
#else |
float asinf(x) /* wrapper asinf */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_asinf(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_asinf(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabsf(x)>(float)1.0) { |
/* asinf(|x|>1) */ |
exc.type = DOMAIN; |
exc.name = "asinf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
exc.retval = nan(""); |
if(_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double asin(double x) |
#else |
double asin(x) |
double x; |
#endif |
{ |
return (double) asinf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_atan2.c |
---|
0,0 → 1,46 |
/* wf_atan2.c -- float version of w_atan2.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
/* |
* wrapper atan2f(y,x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float atan2f(float y, float x) /* wrapper atan2f */ |
#else |
float atan2f(y,x) /* wrapper atan2 */ |
float y,x; |
#endif |
{ |
return __ieee754_atan2f(y,x); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double atan2(double y, double x) |
#else |
double atan2(y,x) |
double y,x; |
#endif |
{ |
return (double) atan2f((float) y, (float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_atanh.c |
---|
0,0 → 1,83 |
/* wf_atanh.c -- float version of w_atanh.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper atanhf(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float atanhf(float x) /* wrapper atanhf */ |
#else |
float atanhf(x) /* wrapper atanhf */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_atanhf(x); |
#else |
float z,y; |
struct exception exc; |
z = __ieee754_atanhf(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
y = fabsf(x); |
if(y>=(float)1.0) { |
if(y>(float)1.0) { |
/* atanhf(|x|>1) */ |
exc.type = DOMAIN; |
exc.name = "atanhf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
exc.retval = 0.0/0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} else { |
/* atanhf(|x|=1) */ |
exc.type = SING; |
exc.name = "atanhf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
exc.retval = x/0.0; /* sign(x)*inf */ |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double atanh(double x) |
#else |
double atanh(x) |
double x; |
#endif |
{ |
return (double) atanhf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_cosh.c |
---|
0,0 → 1,78 |
/* wf_cosh.c -- float version of w_cosh.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper coshf(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float coshf(float x) /* wrapper coshf */ |
#else |
float coshf(x) /* wrapper coshf */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_coshf(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_coshf(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabsf(x)>(float)8.9415985107e+01) { |
/* coshf(finite) overflow */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = OVERFLOW; |
exc.name = "coshf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double cosh(double x) |
#else |
double cosh(x) |
double x; |
#endif |
{ |
return (double) coshf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_drem.c |
---|
0,0 → 1,19 |
/* |
* dremf() wrapper for remainderf(). |
* |
* Written by J.T. Conklin, <jtc@wimsey.com> |
* Placed into the Public Domain, 1994. |
*/ |
#include "fdlibm.h" |
float |
#ifdef __STDC__ |
dremf(float x, float y) |
#else |
dremf(x, y) |
float x, y; |
#endif |
{ |
return remainderf(x, y); |
} |
/contrib/sdk/sources/libc/math/wf_exp.c |
---|
0,0 → 1,103 |
/* wf_exp.c -- float version of w_exp.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper expf(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
o_threshold= 8.8721679688e+01, /* 0x42b17180 */ |
u_threshold= -1.0397208405e+02; /* 0xc2cff1b5 */ |
#ifdef __STDC__ |
float expf(float x) /* wrapper expf */ |
#else |
float expf(x) /* wrapper expf */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_expf(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_expf(x); |
if(_LIB_VERSION == _IEEE_) return z; |
if(finitef(x)) { |
if(x>o_threshold) { |
/* expf(finite) overflow */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = OVERFLOW; |
exc.name = "expf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else if(x<u_threshold) { |
/* expf(finite) underflow */ |
exc.type = UNDERFLOW; |
exc.name = "expf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
} |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double exp(double x) |
#else |
double exp(x) |
double x; |
#endif |
{ |
return (double) expf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_exp2.c |
---|
0,0 → 1,46 |
/* wf_exp2.c -- float version of w_exp2.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper exp2f(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#include <math.h> |
#ifdef __STDC__ |
float exp2f(float x) /* wrapper exp2f */ |
#else |
float exp2f(x) /* wrapper exp2f */ |
float x; |
#endif |
{ |
return powf(2.0, x); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double exp2(double x) |
#else |
double exp2(x) |
double x; |
#endif |
{ |
return (double) exp2f((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_fmod.c |
---|
0,0 → 1,73 |
/* wf_fmod.c -- float version of w_fmod.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper fmodf(x,y) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float fmodf(float x, float y) /* wrapper fmodf */ |
#else |
float fmodf(x,y) /* wrapper fmodf */ |
float x,y; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_fmodf(x,y); |
#else |
float z; |
struct exception exc; |
z = __ieee754_fmodf(x,y); |
if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z; |
if(y==(float)0.0) { |
/* fmodf(x,0) */ |
exc.type = DOMAIN; |
exc.name = "fmodf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)y; |
if (_LIB_VERSION == _SVID_) |
exc.retval = x; |
else |
exc.retval = 0.0/0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double fmod(double x, double y) |
#else |
double fmod(x,y) |
double x,y; |
#endif |
{ |
return (double) fmodf((float) x, (float) y); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_gamma.c |
---|
0,0 → 1,93 |
/* wf_gamma.c -- float version of w_gamma.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
#include "fdlibm.h" |
#include <reent.h> |
#include <errno.h> |
#ifdef __STDC__ |
float gammaf(float x) |
#else |
float gammaf(x) |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_gammaf_r(x,&(_REENT_SIGNGAM(_REENT))); |
#else |
float y; |
struct exception exc; |
y = __ieee754_gammaf_r(x,&(_REENT_SIGNGAM(_REENT))); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finitef(y)&&finitef(x)) { |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
if(floorf(x)==x&&x<=(float)0.0) { |
/* gammaf(-integer) or gammaf(0) */ |
exc.type = SING; |
exc.name = "gammaf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} else { |
/* gammaf(finite) overflow */ |
exc.type = OVERFLOW; |
exc.name = "gammaf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return y; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double gamma(double x) |
#else |
double gamma(x) |
double x; |
#endif |
{ |
return (double) gammaf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_hypot.c |
---|
0,0 → 1,79 |
/* wf_hypot.c -- float version of w_hypot.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper hypotf(x,y) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float hypotf(float x, float y) /* wrapper hypotf */ |
#else |
float hypotf(x,y) /* wrapper hypotf */ |
float x,y; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_hypotf(x,y); |
#else |
float z; |
struct exception exc; |
z = __ieee754_hypotf(x,y); |
if(_LIB_VERSION == _IEEE_) return z; |
if((!finitef(z))&&finitef(x)&&finitef(y)) { |
/* hypotf(finite,finite) overflow */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = OVERFLOW; |
exc.name = "hypotf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)y; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double hypot(double x, double y) |
#else |
double hypot(x,y) |
double x,y; |
#endif |
{ |
return (double) hypotf((float) x, (float) y); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_j0.c |
---|
0,0 → 1,137 |
/* wf_j0.c -- float version of w_j0.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper j0f(float x), y0f(float x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float j0f(float x) /* wrapper j0f */ |
#else |
float j0f(x) /* wrapper j0f */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_j0f(x); |
#else |
struct exception exc; |
float z = __ieee754_j0f(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabsf(x)>(float)X_TLOSS) { |
/* j0f(|x|>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "j0f"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef __STDC__ |
float y0f(float x) /* wrapper y0f */ |
#else |
float y0f(x) /* wrapper y0f */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_y0f(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_y0f(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(x <= (float)0.0){ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
/* y0f(0) = -inf or y0f(x<0) = NaN */ |
exc.type = DOMAIN; /* should be SING for IEEE y0f(0) */ |
exc.name = "y0f"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} |
if(x>(float)X_TLOSS) { |
/* y0f(x>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "y0f"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double j0(double x) |
#else |
double j0(x) |
double x; |
#endif |
{ |
return (double) j0f((float) x); |
} |
#ifdef __STDC__ |
double y0(double x) |
#else |
double y0(x) |
double x; |
#endif |
{ |
return (double) y0f((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_j1.c |
---|
0,0 → 1,139 |
/* wf_j1.c -- float version of w_j1.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper of j1f,y1f |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float j1f(float x) /* wrapper j1f */ |
#else |
float j1f(x) /* wrapper j1f */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_j1f(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_j1f(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(fabsf(x)>(float)X_TLOSS) { |
/* j1f(|x|>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "j1f"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef __STDC__ |
float y1f(float x) /* wrapper y1f */ |
#else |
float y1f(x) /* wrapper y1f */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_y1f(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_y1f(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(x <= (float)0.0){ |
/* y1f(0) = -inf or y1f(x<0) = NaN */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = DOMAIN; /* should be SING for IEEE */ |
exc.name = "y1f"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} |
if(x>(float)X_TLOSS) { |
/* y1f(x>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "y1f"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double j1(double x) |
#else |
double j1(x) |
double x; |
#endif |
{ |
return (double) j1f((float) x); |
} |
#ifdef __STDC__ |
double y1(double x) |
#else |
double y1(x) |
double x; |
#endif |
{ |
return (double) y1f((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_jn.c |
---|
0,0 → 1,138 |
/* wf_jn.c -- float version of w_jn.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float jnf(int n, float x) /* wrapper jnf */ |
#else |
float jnf(n,x) /* wrapper jnf */ |
float x; int n; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_jnf(n,x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_jnf(n,x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(fabsf(x)>(float)X_TLOSS) { |
/* jnf(|x|>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "jnf"; |
exc.err = 0; |
exc.arg1 = (double)n; |
exc.arg2 = (double)x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef __STDC__ |
float ynf(int n, float x) /* wrapper ynf */ |
#else |
float ynf(n,x) /* wrapper ynf */ |
float x; int n; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_ynf(n,x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_ynf(n,x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(x <= (float)0.0){ |
/* ynf(n,0) = -inf or ynf(x<0) = NaN */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = DOMAIN; /* should be SING for IEEE */ |
exc.name = "ynf"; |
exc.err = 0; |
exc.arg1 = (double)n; |
exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} |
if(x>(float)X_TLOSS) { |
/* ynf(x>X_TLOSS) */ |
exc.type = TLOSS; |
exc.name = "ynf"; |
exc.err = 0; |
exc.arg1 = (double)n; |
exc.arg2 = (double)x; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double jn(int n, double x) |
#else |
double jn(n,x) |
double x; int n; |
#endif |
{ |
return (double) jnf(n, (float) x); |
} |
#ifdef __STDC__ |
double yn(int n, double x) |
#else |
double yn(n,x) |
double x; int n; |
#endif |
{ |
return (double) ynf(n, (float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_lgamma.c |
---|
0,0 → 1,87 |
/* wf_lgamma.c -- float version of w_lgamma.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
* |
*/ |
#include "fdlibm.h" |
#include <reent.h> |
#include <errno.h> |
#ifdef __STDC__ |
float lgammaf(float x) |
#else |
float lgammaf(x) |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT))); |
#else |
float y; |
struct exception exc; |
y = __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT))); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finitef(y)&&finitef(x)) { |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "lgammaf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if(floorf(x)==x&&x<=(float)0.0) { |
/* lgammaf(-integer) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} else { |
/* lgammaf(finite) overflow */ |
exc.type = OVERFLOW; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return y; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double lgamma(double x) |
#else |
double lgamma(x) |
double x; |
#endif |
{ |
return (double) lgammaf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_log.c |
---|
0,0 → 1,86 |
/* wf_log.c -- float version of w_log.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper logf(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float logf(float x) /* wrapper logf */ |
#else |
float logf(x) /* wrapper logf */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_logf(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_logf(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) || x > (float)0.0) return z; |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "logf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if(x==(float)0.0) { |
/* logf(0) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} else { |
/* logf(x<0) */ |
exc.type = DOMAIN; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
exc.retval = nan(""); |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double log(double x) |
#else |
double log(x) |
double x; |
#endif |
{ |
return (double) logf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_log10.c |
---|
0,0 → 1,89 |
/* wf_log10.c -- float version of w_log10.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper log10f(X) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float log10f(float x) /* wrapper log10f */ |
#else |
float log10f(x) /* wrapper log10f */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_log10f(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_log10f(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(x<=(float)0.0) { |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "log10f"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = -HUGE; |
else |
exc.retval = -HUGE_VAL; |
if(x==(float)0.0) { |
/* log10f(0) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} else { |
/* log10f(x<0) */ |
exc.type = DOMAIN; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
exc.retval = nan(""); |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double log10(double x) |
#else |
double log10(x) |
double x; |
#endif |
{ |
return (double) log10f((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_pow.c |
---|
0,0 → 1,179 |
/* wf_pow.c -- float version of w_pow.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper powf(x,y) return x**y |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float powf(float x, float y) /* wrapper powf */ |
#else |
float powf(x,y) /* wrapper powf */ |
float x,y; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_powf(x,y); |
#else |
float z; |
struct exception exc; |
z=__ieee754_powf(x,y); |
if(_LIB_VERSION == _IEEE_|| isnan(y)) return z; |
if(isnan(x)) { |
if(y==(float)0.0) { |
/* powf(NaN,0.0) */ |
/* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ |
exc.type = DOMAIN; |
exc.name = "powf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)y; |
exc.retval = 1.0; |
if (_LIB_VERSION == _IEEE_ || |
_LIB_VERSION == _POSIX_) exc.retval = 1.0; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
} |
if(x==(float)0.0){ |
if(y==(float)0.0) { |
/* powf(0.0,0.0) */ |
/* error only if _LIB_VERSION == _SVID_ */ |
exc.type = DOMAIN; |
exc.name = "powf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)y; |
exc.retval = 0.0; |
if (_LIB_VERSION != _SVID_) exc.retval = 1.0; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} |
if(finitef(y)&&y<(float)0.0) { |
/* 0**neg */ |
exc.type = DOMAIN; |
exc.name = "powf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)y; |
if (_LIB_VERSION == _SVID_) |
exc.retval = 0.0; |
else |
exc.retval = -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} |
return z; |
} |
if(!finitef(z)) { |
if(finitef(x)&&finitef(y)) { |
if(isnan(z)) { |
/* neg**non-integral */ |
exc.type = DOMAIN; |
exc.name = "powf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)y; |
if (_LIB_VERSION == _SVID_) |
exc.retval = 0.0; |
else |
exc.retval = 0.0/0.0; /* X/Open allow NaN */ |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else { |
/* powf(x,y) overflow */ |
exc.type = OVERFLOW; |
exc.name = "powf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)y; |
if (_LIB_VERSION == _SVID_) { |
exc.retval = HUGE; |
y *= 0.5; |
if(x<0.0&&rint(y)!=y) exc.retval = -HUGE; |
} else { |
exc.retval = HUGE_VAL; |
y *= 0.5; |
if(x<0.0&&rint(y)!=y) exc.retval = -HUGE_VAL; |
} |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} |
} |
} |
if(z==(float)0.0&&finitef(x)&&finitef(y)) { |
/* powf(x,y) underflow */ |
exc.type = UNDERFLOW; |
exc.name = "powf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)y; |
exc.retval = 0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double pow(double x, double y) |
#else |
double pow(x,y) |
double x,y; |
#endif |
{ |
return (double) powf((float) x, (float) y); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_remainder.c |
---|
0,0 → 1,74 |
/* wf_remainder.c -- float version of w_remainder.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper remainderf(x,p) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float remainderf(float x, float y) /* wrapper remainder */ |
#else |
float remainderf(x,y) /* wrapper remainder */ |
float x,y; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_remainderf(x,y); |
#else |
float z; |
struct exception exc; |
z = __ieee754_remainderf(x,y); |
if(_LIB_VERSION == _IEEE_ || isnan(y)) return z; |
if(y==(float)0.0) { |
/* remainderf(x,0) */ |
exc.type = DOMAIN; |
exc.name = "remainderf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)y; |
exc.retval = 0.0/0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double remainder(double x, double y) |
#else |
double remainder(x,y) |
double x,y; |
#endif |
{ |
return (double) remainderf((float) x, (float) y); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_scalb.c |
---|
0,0 → 1,118 |
/* wf_scalb.c -- float version of w_scalb.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper scalbf(float x, float fn) is provide for |
* passing various standard test suite. One |
* should use scalbn() instead. |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
#ifdef _SCALB_INT |
float scalbf(float x, int fn) /* wrapper scalbf */ |
#else |
float scalbf(float x, float fn) /* wrapper scalbf */ |
#endif |
#else |
float scalbf(x,fn) /* wrapper scalbf */ |
#ifdef _SCALB_INT |
float x; int fn; |
#else |
float x,fn; |
#endif |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_scalbf(x,fn); |
#else |
float z; |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
struct exception exc; |
z = __ieee754_scalbf(x,fn); |
if(_LIB_VERSION == _IEEE_) return z; |
if(!(finitef(z)||isnan(z))&&finitef(x)) { |
/* scalbf overflow; SVID also returns +-HUGE_VAL */ |
exc.type = OVERFLOW; |
exc.name = "scalbf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)fn; |
exc.retval = x > 0.0 ? HUGE_VAL : -HUGE_VAL; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
if(z==(float)0.0&&z!=x) { |
/* scalbf underflow */ |
exc.type = UNDERFLOW; |
exc.name = "scalbf"; |
exc.err = 0; |
exc.arg1 = (double)x; |
exc.arg2 = (double)fn; |
exc.retval = copysign(0.0,x); |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} |
#ifndef _SCALB_INT |
if(!finitef(fn)) errno = ERANGE; |
#endif |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
#ifdef _SCALB_INT |
double scalb(double x, int fn) |
#else |
double scalb(double x, double fn) |
#endif |
#else |
double scalb(x, fn) |
#ifdef _SCALB_INT |
double x; int fn; |
#else |
double x,fn; |
#endif |
#endif |
{ |
#ifdef _SCALB_INT |
return (double) scalbf((float) x, fn); |
#else |
return (double) scalbf((float) x, (float) fn); |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_sincos.c |
---|
0,0 → 1,33 |
/* sincos -- currently no more efficient than two separate calls to |
sin and cos. */ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
void sincosf(float x, float *sinx, float *cosx) |
#else |
void sincosf(x, sinx, cosx) |
float x; |
float *sinx; |
float *cosx; |
#endif |
{ |
*sinx = sinf (x); |
*cosx = cosf (x); |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
void sincos(double x, double *sinx, double *cosx) |
#else |
void sincos(x, sinx, cosx) |
double x; |
double sinx; |
double cosx; |
#endif |
{ |
*sinx = sinf((float) x); |
*cosx = cosf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_sinh.c |
---|
0,0 → 1,78 |
/* wf_sinh.c -- float version of w_sinh.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper sinhf(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float sinhf(float x) /* wrapper sinhf */ |
#else |
float sinhf(x) /* wrapper sinhf */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_sinhf(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_sinhf(x); |
if(_LIB_VERSION == _IEEE_) return z; |
if(!finitef(z)&&finitef(x)) { |
/* sinhf(finite) overflow */ |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.type = OVERFLOW; |
exc.name = "sinhf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = ( (x>0.0) ? HUGE : -HUGE); |
else |
exc.retval = ( (x>0.0) ? HUGE_VAL : -HUGE_VAL); |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double sinh(double x) |
#else |
double sinh(x) |
double x; |
#endif |
{ |
return (double) sinhf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_sqrt.c |
---|
0,0 → 1,72 |
/* wf_sqrt.c -- float version of w_sqrt.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper sqrtf(x) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float sqrtf(float x) /* wrapper sqrtf */ |
#else |
float sqrtf(x) /* wrapper sqrtf */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_sqrtf(x); |
#else |
float z; |
struct exception exc; |
z = __ieee754_sqrtf(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(x<(float)0.0) { |
/* sqrtf(negative) */ |
exc.type = DOMAIN; |
exc.name = "sqrtf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = 0.0; |
else |
exc.retval = 0.0/0.0; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return z; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double sqrt(double x) |
#else |
double sqrt(x) |
double x; |
#endif |
{ |
return (double) sqrtf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wf_tgamma.c |
---|
0,0 → 1,59 |
/* w_gammaf.c -- float version of w_gamma.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
#include "math.h" |
#include "fdlibm.h" |
#ifdef __STDC__ |
float tgammaf(float x) |
#else |
float tgammaf(x) |
float x; |
#endif |
{ |
float y; |
int local_signgam; |
y = __ieee754_gammaf_r(x,&local_signgam); |
if (local_signgam < 0) y = -y; |
#ifdef _IEEE_LIBM |
return y; |
#else |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finitef(y)&&finitef(x)) { |
if(floorf(x)==x&&x<=(float)0.0) |
/* tgammaf pole */ |
return (float)__kernel_standard((double)x,(double)x,141); |
else |
/* tgammaf overflow */ |
return (float)__kernel_standard((double)x,(double)x,140); |
} |
return y; |
#endif |
} |
#ifdef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double tgamma(double x) |
#else |
double tgamma(x) |
double x; |
#endif |
{ |
return (double) tgammaf((float) x); |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wr_gamma.c |
---|
0,0 → 1,76 |
/* @(#)wr_gamma.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper double gamma_r(double x, int *signgamp) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double gamma_r(double x, int *signgamp) /* wrapper lgamma_r */ |
#else |
double gamma_r(x,signgamp) /* wrapper lgamma_r */ |
double x; int *signgamp; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_gamma_r(x,signgamp); |
#else |
double y; |
struct exception exc; |
y = __ieee754_gamma_r(x,signgamp); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finite(y)&&finite(x)) { |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "gamma"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if(floor(x)==x&&x<=0.0) { |
/* gamma(-integer) or gamma(0) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} else { |
/* gamma(finite) overflow */ |
exc.type = OVERFLOW; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return y; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wr_lgamma.c |
---|
0,0 → 1,77 |
/* @(#)wr_lgamma.c 5.1 93/09/24 */ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper double lgamma_r(double x, int *signgamp) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifndef _DOUBLE_IS_32BITS |
#ifdef __STDC__ |
double lgamma_r(double x, int *signgamp) /* wrapper lgamma_r */ |
#else |
double lgamma_r(x,signgamp) /* wrapper lgamma_r */ |
double x; int *signgamp; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_lgamma_r(x,signgamp); |
#else |
double y; |
struct exception exc; |
y = __ieee754_lgamma_r(x,signgamp); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finite(y)&&finite(x)) { |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "lgamma"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if(floor(x)==x&&x<=0.0) { |
/* lgamma(-integer) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} else { |
/* lgamma(finite) overflow */ |
exc.type = OVERFLOW; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} |
if (exc.err != 0) |
errno = exc.err; |
return exc.retval; |
} else |
return y; |
#endif |
} |
#endif /* defined(_DOUBLE_IS_32BITS) */ |
/contrib/sdk/sources/libc/math/wrf_gamma.c |
---|
0,0 → 1,74 |
/* wrf_gamma.c -- float version of wr_gamma.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper float gammaf_r(float x, int *signgamp) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float gammaf_r(float x, int *signgamp) /* wrapper lgammaf_r */ |
#else |
float gammaf_r(x,signgamp) /* wrapper lgammaf_r */ |
float x; int *signgamp; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_gammaf_r(x,signgamp); |
#else |
float y; |
struct exception exc; |
y = __ieee754_gammaf_r(x,signgamp); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finitef(y)&&finitef(x)) { |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "gammaf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if(floorf(x)==x&&x<=(float)0.0) { |
/* gammaf(-integer) or gamma(0) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} else { |
/* gammaf(finite) overflow */ |
exc.type = OVERFLOW; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return y; |
#endif |
} |
/contrib/sdk/sources/libc/math/wrf_lgamma.c |
---|
0,0 → 1,75 |
/* wrf_lgamma.c -- float version of wr_lgamma.c. |
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
*/ |
/* |
* ==================================================== |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
* |
* Developed at SunPro, a Sun Microsystems, Inc. business. |
* Permission to use, copy, modify, and distribute this |
* software is freely granted, provided that this notice |
* is preserved. |
* ==================================================== |
*/ |
/* |
* wrapper float lgammaf_r(float x, int *signgamp) |
*/ |
#include "fdlibm.h" |
#include <errno.h> |
#ifdef __STDC__ |
float lgammaf_r(float x, int *signgamp) /* wrapper lgammaf_r */ |
#else |
float lgammaf_r(x,signgamp) /* wrapper lgammaf_r */ |
float x; int *signgamp; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_lgammaf_r(x,signgamp); |
#else |
float y; |
struct exception exc; |
y = __ieee754_lgammaf_r(x,signgamp); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finitef(y)&&finitef(x)) { |
#ifndef HUGE_VAL |
#define HUGE_VAL inf |
double inf = 0.0; |
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
#endif |
exc.name = "lgammaf"; |
exc.err = 0; |
exc.arg1 = exc.arg2 = (double)x; |
if (_LIB_VERSION == _SVID_) |
exc.retval = HUGE; |
else |
exc.retval = HUGE_VAL; |
if(floorf(x)==x&&x<=(float)0.0) { |
/* lgammaf(-integer) or lgamma(0) */ |
exc.type = SING; |
if (_LIB_VERSION == _POSIX_) |
errno = EDOM; |
else if (!matherr(&exc)) { |
errno = EDOM; |
} |
} else { |
/* lgammaf(finite) overflow */ |
exc.type = OVERFLOW; |
if (_LIB_VERSION == _POSIX_) |
errno = ERANGE; |
else if (!matherr(&exc)) { |
errno = ERANGE; |
} |
} |
if (exc.err != 0) |
errno = exc.err; |
return (float)exc.retval; |
} else |
return y; |
#endif |
} |
/contrib/sdk/sources/libc/newlib.sed |
---|
0,0 → 1,0 |
s|[^ ][A-Za-z0-9_]*|_&,'&',\\| |
/contrib/sdk/sources/libc/pe_app.lds |
---|
0,0 → 1,119 |
OUTPUT_FORMAT(pei-i386) |
ENTRY("__start") |
SECTIONS |
{ |
. = SIZEOF_HEADERS; |
. = ALIGN(__section_alignment__); |
.text __image_base__ + . : |
{ |
*(.init) |
*(.text) |
*(SORT(.text$*)) |
*(.text.*) |
*(.glue_7t) |
*(.glue_7) |
___CTOR_LIST__ = .; __CTOR_LIST__ = . ; |
LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); |
___DTOR_LIST__ = .; __DTOR_LIST__ = . ; |
LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); |
*(.fini) |
/* ??? Why is .gcc_exc here? */ |
*(.gcc_exc) |
PROVIDE (etext = .); |
*(.gcc_except_table) |
*(.rdata) |
*(SORT(.rdata$*)) |
___RUNTIME_PSEUDO_RELOC_LIST__ = .; |
__RUNTIME_PSEUDO_RELOC_LIST__ = .; |
*(.rdata_runtime_pseudo_reloc) |
___RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
__RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
} |
.data ALIGN(__section_alignment__): |
{ |
PROVIDE ( __data_start__ = .) ; |
*(.data) |
*(.data2) |
*(SORT(.data$*)) |
*(.jcr) |
__CRT_MT = .; |
LONG(0); |
PROVIDE ( __data_end__ = .) ; |
*(.data_cygwin_nocopy) |
} |
.eh_frame ALIGN(__section_alignment__): |
{ |
*(.eh_frame) |
___iend = . ; |
} |
.CRT ALIGN(__section_alignment__): |
{ |
___crt_xc_start__ = . ; |
*(SORT(.CRT$XC*)) /* C initialization */ |
___crt_xc_end__ = . ; |
___crt_xi_start__ = . ; |
*(SORT(.CRT$XI*)) /* C++ initialization */ |
___crt_xi_end__ = . ; |
___crt_xl_start__ = . ; |
*(SORT(.CRT$XL*)) /* TLS callbacks */ |
/* ___crt_xl_end__ is defined in the TLS Directory support code */ |
___crt_xp_start__ = . ; |
*(SORT(.CRT$XP*)) /* Pre-termination */ |
___crt_xp_end__ = . ; |
___crt_xt_start__ = . ; |
*(SORT(.CRT$XT*)) /* Termination */ |
___crt_xt_end__ = . ; |
} |
.bss ALIGN(__section_alignment__): |
{ |
*(.bss) |
*(COMMON) |
} |
/DISCARD/ : |
{ |
*(.debug$S) |
*(.debug$T) |
*(.debug$F) |
*(.drectve) |
*(.note.GNU-stack) |
*(.edata) |
*(.comment) |
*(.debug_abbrev) |
*(.debug_info) |
*(.debug_line) |
*(.debug_frame) |
*(.debug_loc) |
*(.debug_pubnames) |
*(.debug_aranges) |
*(.debug_ranges) |
} |
.idata ALIGN(__section_alignment__): |
{ |
SORT(*)(.idata$2) |
SORT(*)(.idata$3) |
/* These zeroes mark the end of the import list. */ |
LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); |
SORT(*)(.idata$4) |
SORT(*)(.idata$5) |
SORT(*)(.idata$6) |
SORT(*)(.idata$7) |
} |
.reloc ALIGN(__section_alignment__) : |
{ |
*(.reloc) |
} |
} |
/contrib/sdk/sources/libc/reent/closer.c |
---|
0,0 → 1,87 |
/* Reentrant version of close system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <errno.h> |
/* Some targets provides their own versions of this functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
/* |
FUNCTION |
<<_close_r>>---Reentrant version of close |
INDEX |
_close_r |
ANSI_SYNOPSIS |
#include <reent.h> |
int _close_r(struct _reent *<[ptr]>, int <[fd]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
int _close_r(<[ptr]>, <[fd]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
DESCRIPTION |
This is a reentrant version of <<close>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
extern unsigned __NFiles; |
#define __handle_check( __h, __r ) \ |
if( (__h) < 0 || (__h) > __NFiles ) { \ |
ptr->_errno = EBADF ; \ |
return( __r ); \ |
} |
int |
_DEFUN(_close_r, (ptr, fd), |
struct _reent *ptr _AND |
int fd) |
{ |
int ret; |
int h; |
__file_handle *fh; |
__handle_check( fd, -1 ); |
fh = (__file_handle*) __getOSHandle( fd ); |
if( fd > STDERR_FILENO ) |
{ |
_free_r(ptr, fh->name); |
_free_r(ptr, fh); |
__freePOSIXHandle( fd ); |
__SetIOMode_nogrow( fd, 0 ); |
} |
return 0; |
} |
int |
_DEFUN( close,(fd), |
int fd) |
{ |
return _close_r(_REENT, fd); |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/contrib/sdk/sources/libc/reent/fstatr.c |
---|
0,0 → 1,156 |
/* Reentrant versions of fstat system call. This implementation just |
calls the fstat system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <sys/stat.h> |
#include <_syslist.h> |
#include <errno.h> |
#include <string.h> |
/* Some targets provides their own versions of these functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifdef REENTRANT_SYSCALLS_PROVIDED |
int _dummy_fstat_syscalls = 1; |
#else |
/* We use the errno variable used by the system dependent layer. */ |
/* |
FUNCTION |
<<_fstat_r>>---Reentrant version of fstat |
INDEX |
_fstat_r |
ANSI_SYNOPSIS |
#include <reent.h> |
int _fstat_r(struct _reent *<[ptr]>, |
int <[fd]>, struct stat *<[pstat]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
int _fstat_r(<[ptr]>, <[fd]>, <[pstat]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
struct stat *<[pstat]>; |
DESCRIPTION |
This is a reentrant version of <<fstat>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
#pragma pack(push, 1) |
typedef struct |
{ |
char sec; |
char min; |
char hour; |
char rsv; |
}detime_t; |
typedef struct |
{ |
char day; |
char month; |
short year; |
}dedate_t; |
typedef struct |
{ |
unsigned attr; |
unsigned flags; |
union |
{ |
detime_t ctime; |
unsigned cr_time; |
}; |
union |
{ |
dedate_t cdate; |
unsigned cr_date; |
}; |
union |
{ |
detime_t atime; |
unsigned acc_time; |
}; |
union |
{ |
dedate_t adate; |
unsigned acc_date; |
}; |
union |
{ |
detime_t mtime; |
unsigned mod_time; |
}; |
union |
{ |
dedate_t mdate; |
unsigned mod_date; |
}; |
unsigned size; |
unsigned size_high; |
} FILEINFO; |
#pragma pack(pop) |
extern unsigned __NFiles; |
#define __handle_check( __h, __r ) \ |
if( (__h) < 0 || (__h) > __NFiles ) { \ |
ptr->_errno = EBADF ; \ |
return( __r ); \ |
} |
int |
_fstat_r (ptr, fd, pstat) |
struct _reent *ptr; |
int fd; |
struct stat *pstat; |
{ |
FILEINFO info; |
int ret; |
__file_handle *fh; |
__handle_check( fd, -1 ); |
if (fd < 3) |
{ |
pstat->st_mode = S_IFCHR; |
pstat->st_blksize = 0; |
return 0; |
} |
fh = (__file_handle*) __getOSHandle( fd ); |
get_fileinfo(fh->name, &info); |
memset (pstat, 0, sizeof (* pstat)); |
pstat->st_mode = S_IFREG; |
pstat->st_blksize = 4096; |
pstat->st_size = info.size; |
return 0; |
} |
int |
_DEFUN (fstat, (fd, pstat), |
int fd _AND |
struct stat *pstat) |
{ |
return _fstat_r (_REENT, fd, pstat); |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/contrib/sdk/sources/libc/reent/getreent.c |
---|
0,0 → 1,25 |
/* default reentrant pointer when multithread enabled */ |
#include <_ansi.h> |
#include <string.h> |
#include <reent.h> |
#include <kos32sys.h> |
void init_reent() |
{ |
struct _reent *ent; |
ent = user_alloc(sizeof(struct _reent)); |
_REENT_INIT_PTR(ent); |
__asm__ __volatile__( |
"movl %0, %%fs:16" |
::"r"(ent)); |
__sinit(ent); |
} |
/contrib/sdk/sources/libc/reent/gettimeofdayr.c |
---|
0,0 → 1,113 |
/* Reentrant version of gettimeofday system call |
This implementation just calls the times/gettimeofday system calls. |
Gettimeofday may not be available on all targets. It's presence |
here is dubious. Consider it for internal use only. */ |
#include <reent.h> |
#include <time.h> |
#include <sys/time.h> |
#include <sys/times.h> |
#include <_syslist.h> |
#include <errno.h> |
/* Some targets provides their own versions of these functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifdef REENTRANT_SYSCALLS_PROVIDED |
int _dummy_gettimeofday_syscalls = 1; |
#else |
/* We use the errno variable used by the system dependent layer. */ |
#undef errno |
static int errno; |
/* |
FUNCTION |
<<_gettimeofday_r>>---Reentrant version of gettimeofday |
INDEX |
_gettimeofday_r |
ANSI_SYNOPSIS |
#include <reent.h> |
#include <time.h> |
int _gettimeofday_r(struct _reent *<[ptr]>, |
struct timeval *<[ptimeval]>, |
void *<[ptimezone]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
#include <time.h> |
int _gettimeofday_r(<[ptr]>, <[ptimeval]>, <[ptimezone]>) |
struct _reent *<[ptr]>; |
struct timeval *<[ptimeval]>; |
void *<[ptimezone]>; |
DESCRIPTION |
This is a reentrant version of <<gettimeofday>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
This function is only available for a few targets. |
Check libc.a to see if its available on yours. |
*/ |
int |
_DEFUN (_gettimeofday_r, (ptr, ptimeval, ptimezone), |
struct _reent *ptr _AND |
struct timeval *ptimeval _AND |
void *ptimezone) |
{ |
int ret; |
errno = 0; |
if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0) |
ptr->_errno = errno; |
return ret; |
} |
#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) |
int |
_gettimeofday (struct timeval *tv, void *tz) |
{ |
unsigned int xtmp; |
struct tm tmblk; |
if( tv ) |
{ |
tv->tv_usec = 0; |
__asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(3)); |
tmblk.tm_sec = (xtmp>>16)&0xff; |
tmblk.tm_min = (xtmp>>8)&0xff; |
tmblk.tm_hour = xtmp&0xff; |
BCD_TO_BIN(tmblk.tm_sec); |
BCD_TO_BIN(tmblk.tm_min); |
BCD_TO_BIN(tmblk.tm_hour); |
__asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(29)); |
tmblk.tm_mday = (xtmp>>16)&0xff; |
tmblk.tm_mon = ((xtmp>>8)&0xff)-1; |
tmblk.tm_year = ((xtmp&0xff)+2000)-1900; |
tmblk.tm_wday = tmblk.tm_yday = 0; |
tmblk.tm_isdst = -1; |
tv->tv_sec = mktime(&tmblk); |
return 0; |
} |
else |
{ |
errno = EINVAL; |
return -1; |
}; |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/contrib/sdk/sources/libc/reent/hdlman.c |
---|
0,0 → 1,381 |
/**************************************************************************** |
* |
* Open Watcom Project |
* |
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. |
* |
* ======================================================================== |
* |
* This file contains Original Code and/or Modifications of Original |
* Code as defined in and that are subject to the Sybase Open Watcom |
* Public License version 1.0 (the 'License'). You may not use this file |
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO |
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is |
* provided with the Original Code and Modifications, and is also |
* available at www.sybase.com/developer/opensource. |
* |
* The Original Code and all software distributed under the License are |
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM |
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR |
* NON-INFRINGEMENT. Please see the License for the specific language |
* governing rights and limitations under the License. |
* |
* ======================================================================== |
* |
* Description: Handle manager routines. |
* |
****************************************************************************/ |
#include <reent.h> |
#include <unistd.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <errno.h> |
#include <fcntl.h> |
#define _NFILES 20 |
#define _DYNAMIC 0x4000 /* FILE is dynamically allocated */ |
#define _READ 0x0001 /* file opened for reading */ |
#define _WRITE 0x0002 /* file opened for writing */ |
#define NULL_HANDLE (int)-1 |
#define DUMMY_HANDLE (int)-2 |
#define INVALID_HANDLE_VALUE (int) -1 |
#define _AccessIOB() |
#define _ReleaseIOB() |
#undef __getOSHandle |
void __ChkTTYIOMode( int handle ); |
void __initPOSIXHandles( void ) __attribute__ ((constructor)); |
void __grow_iomode( int num ); |
int debugwrite(const char *path,const void *buff, |
size_t offset, size_t count, size_t *writes); |
int _fmode; |
#define NUM_STD_STREAMS 3 |
#define _ISTTY 0x2000 /* is console device */ |
unsigned __init_mode[_NFILES] = { /* file mode information (flags) */ |
_READ, /* stdin */ |
_WRITE, /* stdout */ |
_WRITE /* stderr */ |
}; |
unsigned *__io_mode = __init_mode; /* initially points to static array */ |
unsigned __NFiles = _NFILES; /* maximum # of files we can open */ |
unsigned __NHandles = 0; |
int *__OSHandles = NULL; |
static __file_handle |
stdin_handle = { |
NULL, |
0, |
NULL |
}; |
static __file_handle |
stdout_handle = |
{ |
NULL, |
0, |
debugwrite |
}; |
static __file_handle |
stderr_handle = |
{ |
NULL, |
0, |
debugwrite |
}; |
unsigned __growPOSIXHandles( unsigned num ) |
{ |
int *new2; |
unsigned i; |
if( num > __NHandles ) |
{ |
if( __OSHandles == NULL ) |
{ |
new2 = malloc( num * sizeof( int ) ); |
} |
else |
{ |
new2 = realloc( __OSHandles, num * sizeof( int ) ); |
} |
if( new2 == NULL ) |
{ |
// __set_errno( ENOMEM ); |
num = __NHandles; |
} |
else |
{ |
for( i = __NHandles; i < num; i++ ) |
{ |
new2[ i ] = NULL_HANDLE; |
} |
__OSHandles = new2; |
__NHandles = num; |
} |
} |
return( __NHandles ); |
} |
int __allocPOSIXHandle( int hdl ) |
{ |
int i; |
for( i = 0; i < __NHandles; i++ ) |
{ |
if( __OSHandles[i] == NULL_HANDLE ) break; |
} |
if( i >= __NHandles ) |
{ |
// 20 -> (20+10+1) -> 31 |
// 31 -> (31+15+1) -> 47 |
// 47 -> (47+23+1) -> 71 |
__growPOSIXHandles( i + (i >> 1) + 1 ); |
// keep iomode array in sync |
if( __NHandles > __NFiles ) __grow_iomode( __NHandles ); |
for( ; i < __NHandles; i++ ) |
{ |
if( __OSHandles[i] == NULL_HANDLE ) break; |
} |
} |
if( i >= __NHandles ) |
{ |
i = -1; |
} else { |
__OSHandles[i] = hdl; |
} |
return( i ); |
} |
void __freePOSIXHandle( int hid ) |
{ |
__OSHandles[ hid ] = NULL_HANDLE; |
} |
int __getOSHandle( int hid ) |
{ |
return( __OSHandles[ hid ] ); |
} |
int __setOSHandle( unsigned hid, int hdl ) |
{ |
// call the Win32 API for a standard file handle |
switch( hid ) { |
case STDIN_FILENO: |
// SetStdHandle( STD_INPUT_HANDLE, hdl ); |
break; |
case STDOUT_FILENO: |
// SetStdHandle( STD_OUTPUT_HANDLE, hdl ); |
break; |
case STDERR_FILENO: |
// SetStdHandle( STD_ERROR_HANDLE, hdl ); |
break; |
} |
if( hid < __NHandles ) |
{ |
__OSHandles[ hid ] = hdl; |
} |
else |
{ |
hid = (unsigned)-1; // this should never happen |
} |
return( hid ); |
} |
// called from library startup code |
void __initPOSIXHandles( void ) |
{ |
int h; |
_fmode = O_BINARY; |
__growPOSIXHandles( __NFiles ); |
h = (int)&stdin_handle; |
__allocPOSIXHandle( h ); // should return 0==STDIN_FILENO |
h = (int)&stdout_handle; |
__allocPOSIXHandle( h ); // should return 1==STDOUT_FILENO |
h = (int)&stderr_handle; |
__allocPOSIXHandle( h ); // should return 3==STDERR_FILENO |
} |
/* |
static void __finiPOSIXHandles( void ) |
{ |
if( __OSHandles != NULL ) { |
free( __OSHandles ); |
__OSHandles = NULL; |
} |
if( __FakeHandles != NULL ) |
{ |
int i; |
for( i = 0 ; i < __topFakeHandle ; i++ ) |
{ |
// CloseHandle( __FakeHandles[i] ); |
} |
free( __FakeHandles ); |
__FakeHandles = 0; |
} |
} |
*/ |
void __set_handles( int num ) |
{ |
__NHandles = num; |
} |
int _grow_handles( int num ) |
{ |
if( num > __NHandles ) |
{ |
num = __growPOSIXHandles( num ); |
if( num > __NFiles ) { |
__grow_iomode( num ); // sets new __NFiles if successful |
} |
__NHandles = num; |
} |
return( __NHandles ); |
} |
static unsigned _init_NFiles; // original __NFiles value; |
void __grow_iomode( int num ) |
{ |
unsigned *new; |
_AccessIOB(); |
if( __io_mode == __init_mode ) |
{ |
_init_NFiles = __NFiles; |
new = (unsigned *) malloc( num * sizeof( unsigned ) ); |
if( new != NULL ) { |
memcpy( new, __init_mode, __NFiles * sizeof(unsigned) ); |
} |
} |
else |
{ |
new = (unsigned *) realloc( __io_mode, num * sizeof( unsigned ) ); |
} |
if( new == NULL ) |
{ |
// __set_errno( ENOMEM ); |
} |
else |
{ |
memset( &new[__NFiles], 0, (num-__NFiles)*sizeof(unsigned) ); |
__io_mode = new; |
__NFiles = num; |
} |
_ReleaseIOB(); |
} |
void __shrink_iomode( void ) |
{ |
_AccessIOB(); |
// free any malloc'd iomode array |
if( __io_mode != __init_mode ) |
{ |
free( __io_mode ); |
__io_mode = __init_mode; |
__NFiles = _init_NFiles; |
} |
_ReleaseIOB(); |
} |
#define _INITIALIZED _DYNAMIC |
signed __SetIOMode( int handle, unsigned value ) |
{ |
int i; |
if( handle >= __NFiles ) |
{ |
i = __NFiles; // 20 -> (20+10+1) -> 31 |
// 31 -> (31+15+1) -> 47 |
// 47 -> (47+23+1) -> 71 |
__grow_iomode( i + (i > 1) + 1 ); |
} |
if( handle >= __NFiles ) |
{ |
// return an error indication (errno should be set to ENOMEM) |
return( -1 ); |
} |
else |
{ |
if( value != 0 ) |
{ |
__ChkTTYIOMode( handle ); |
__io_mode[handle] = value | _INITIALIZED; |
} |
else |
{ |
__io_mode[handle] = value; /* we're closing it; smite _INITIALIZED */ |
} |
return( handle ); |
} |
} |
int _isatty( int hid ) |
{ |
return( 0 ); |
} |
void __ChkTTYIOMode( int handle ) |
{ |
if( handle < NUM_STD_STREAMS && !(__io_mode[handle] & _INITIALIZED) ) |
{ |
__io_mode[handle] |= _INITIALIZED; |
if( _isatty( handle ) ) |
{ |
__io_mode[handle] |= _ISTTY; |
} |
} |
} |
unsigned __GetIOMode( int handle ) |
{ |
if( handle >= __NFiles ) |
{ |
return( 0 ); |
} |
return( __io_mode[handle] ); |
}; |
void __SetIOMode_nogrow( int handle, unsigned value ) |
{ |
if( handle < __NFiles ) |
{ |
__io_mode[handle] = value; /* we're closing it; smite _INITIALIZED */ |
} |
} |
/contrib/sdk/sources/libc/reent/impure.c |
---|
0,0 → 1,28 |
#include <reent.h> |
/* Note that there is a copy of this in sys/reent.h. */ |
#ifndef __ATTRIBUTE_IMPURE_PTR__ |
#define __ATTRIBUTE_IMPURE_PTR__ |
#endif |
#ifndef __ATTRIBUTE_IMPURE_DATA__ |
#define __ATTRIBUTE_IMPURE_DATA__ |
#endif |
/* Redeclare these symbols locally as weak so that the file containing |
their definitions (along with a lot of other stuff) isn't sucked in |
unless they are actually used by other compilation units. This is |
important to reduce image size for targets with very small amounts |
of memory. */ |
#ifdef _REENT_SMALL |
extern const struct __sFILE_fake __sf_fake_stdin _ATTRIBUTE ((weak)); |
extern const struct __sFILE_fake __sf_fake_stdout _ATTRIBUTE ((weak)); |
extern const struct __sFILE_fake __sf_fake_stderr _ATTRIBUTE ((weak)); |
#endif |
static struct _reent __ATTRIBUTE_IMPURE_DATA__ impure_data = _REENT_INIT (impure_data); |
#ifdef __CYGWIN__ |
extern struct _reent reent_data __attribute__ ((alias("impure_data"))); |
#endif |
struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr = &impure_data; |
struct _reent *_CONST __ATTRIBUTE_IMPURE_PTR__ _global_impure_ptr = &impure_data; |
/contrib/sdk/sources/libc/reent/init_reent.c |
---|
0,0 → 1,18 |
#include <_ansi.h> |
#include <string.h> |
#include <reent.h> |
void init_global_reent() |
{ |
struct _reent *ent; |
ent =_GLOBAL_REENT; |
_REENT_INIT_PTR(ent); |
__asm__ __volatile__( |
"movl %0, %%fs:16" |
::"r"(ent)); |
// __sinit(ent); |
} |
/contrib/sdk/sources/libc/reent/isattyr.c |
---|
0,0 → 1,62 |
/* Reentrant versions of isatty system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <errno.h> |
/* Some targets provides their own versions of these functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifdef REENTRANT_SYSCALLS_PROVIDED |
int _dummy_isatty_syscalls = 1; |
#else |
/* We use the errno variable used by the system dependent layer. */ |
#undef errno |
extern int errno; |
/* |
FUNCTION |
<<_isatty_r>>---Reentrant version of isatty |
INDEX |
_isatty_r |
ANSI_SYNOPSIS |
#include <reent.h> |
int _isatty_r(struct _reent *<[ptr]>, |
int <[fd]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
int _isatty_r(<[ptr]>, <[fd]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
DESCRIPTION |
This is a reentrant version of <<isatty>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
int |
_isatty_r (ptr, fd) |
struct _reent *ptr; |
int fd; |
{ |
int ret; |
ptr->_errno = ENOTTY ; |
return 0; |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/contrib/sdk/sources/libc/reent/lseekr.c |
---|
0,0 → 1,159 |
/* Reentrant versions of lseek system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <errno.h> |
/* Some targets provides their own versions of this functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#pragma pack(push, 1) |
typedef struct |
{ |
char sec; |
char min; |
char hour; |
char rsv; |
}detime_t; |
typedef struct |
{ |
char day; |
char month; |
short year; |
}dedate_t; |
typedef struct |
{ |
unsigned attr; |
unsigned flags; |
union |
{ |
detime_t ctime; |
unsigned cr_time; |
}; |
union |
{ |
dedate_t cdate; |
unsigned cr_date; |
}; |
union |
{ |
detime_t atime; |
unsigned acc_time; |
}; |
union |
{ |
dedate_t adate; |
unsigned acc_date; |
}; |
union |
{ |
detime_t mtime; |
unsigned mod_time; |
}; |
union |
{ |
dedate_t mdate; |
unsigned mod_date; |
}; |
unsigned size; |
unsigned size_high; |
} FILEINFO; |
#pragma pack(pop) |
extern unsigned __NFiles; |
#define __handle_check( __h, __r ) \ |
if( (__h) < 0 || (__h) > __NFiles ) { \ |
ptr->_errno = EBADF ; \ |
return( __r ); \ |
} |
/* |
FUNCTION |
<<_lseek_r>>---Reentrant version of lseek |
INDEX |
_lseek_r |
ANSI_SYNOPSIS |
#include <reent.h> |
off_t _lseek_r(struct _reent *<[ptr]>, |
int <[fd]>, off_t <[pos]>, int <[whence]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
off_t _lseek_r(<[ptr]>, <[fd]>, <[pos]>, <[whence]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
off_t <[pos]>; |
int <[whence]>; |
DESCRIPTION |
This is a reentrant version of <<lseek>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
_off_t |
_DEFUN (_lseek_r, (ptr, fd, pos, whence), |
struct _reent *ptr _AND |
int fd _AND |
_off_t pos _AND |
int whence) |
{ |
_off_t ret; |
__file_handle *fh; |
__handle_check( fd, -1 ); |
fh = (__file_handle*) __getOSHandle( fd ); |
switch(whence) |
{ |
case SEEK_SET: |
ret = pos; |
break; |
case SEEK_CUR: |
ret = fh->offset + pos; |
break; |
case SEEK_END: |
{ |
FILEINFO info; |
get_fileinfo(fh->name, &info); |
ret = pos + info.size; |
break; |
} |
default: |
ptr->_errno = EINVAL; |
return -1; |
}; |
fh->offset = ret; |
return( ret ); |
} |
_off_t |
_DEFUN (lseek, (fd, pos, whence), |
int fd _AND |
_off_t pos _AND |
int whence) |
{ |
return _lseek_r(_REENT, fd, pos, whence); |
}; |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/contrib/sdk/sources/libc/reent/mutex.c |
---|
0,0 → 1,23 |
void __mutex_lock(volatile int *val) |
{ |
int tmp; |
__asm__ __volatile__ ( |
"0:\n\t" |
"mov %0, %1\n\t" |
"testl %1, %1\n\t" |
"jz 1f\n\t" |
"movl $68, %%eax\n\t" |
"movl $1, %%ebx\n\t" |
"int $0x40\n\t" |
"jmp 0b\n\t" |
"1:\n\t" |
"incl %1\n\t" |
"xchgl %0, %1\n\t" |
"testl %1, %1\n\t" |
"jnz 0b\n" |
: "+m" (*val), "=&r"(tmp) |
::"eax","ebx" ); |
} |
/contrib/sdk/sources/libc/reent/openr.c |
---|
0,0 → 1,221 |
/* Reentrant versions of open system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <fcntl.h> |
#include <_syslist.h> |
#include <sys/errno.h> |
#include <stdlib.h> |
#include <string.h> |
#include <stdarg.h> |
#include <sys/kos_io.h> |
/* Some targets provides their own versions of this functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
/* We use the errno variable used by the system dependent layer. */ |
/* |
FUNCTION |
<<_open_r>>---Reentrant version of open |
INDEX |
_open_r |
ANSI_SYNOPSIS |
#include <reent.h> |
int _open_r(struct _reent *<[ptr]>, |
const char *<[file]>, int <[flags]>, int <[mode]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
int _open_r(<[ptr]>, <[file]>, <[flags]>, <[mode]>) |
struct _reent *<[ptr]>; |
char *<[file]>; |
int <[flags]>; |
int <[mode]>; |
DESCRIPTION |
This is a reentrant version of <<open>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
#define NULL_HANDLE (int)-1 |
#define DUMMY_HANDLE (int)-2 |
#define _READ 0x0001 /* file opened for reading */ |
#define _WRITE 0x0002 /* file opened for writing */ |
#define _UNGET 0x0004 /* ungetc has been done */ |
#define _BIGBUF 0x0008 /* big buffer allocated */ |
#define _EOF 0x0010 /* EOF has occurred */ |
#define _SFERR 0x0020 /* error has occurred on this file */ |
#define _APPEND 0x0080 /* file opened for append */ |
#define _BINARY 0x0040 /* file is binary, skip CRLF processing */ |
#define _TMPFIL 0x0800 /* this is a temporary file */ |
#define _DIRTY 0x1000 /* buffer has been modified */ |
#define _ISTTY 0x2000 /* is console device */ |
#define _DYNAMIC 0x4000 /* FILE is dynamically allocated */ |
#define _FILEEXT 0x8000 /* lseek with positive offset has been done */ |
#define _COMMIT 0x0001 /* extended flag: commit OS buffers on flush */ |
extern int _fmode; |
static inline void debug_out(const char val) |
{ |
__asm__ __volatile__( |
"int $0x40 \n\t" |
::"a"(63), "b"(1),"c"(val)); |
} |
int debugwrite(const char *path, const void *buff, |
size_t offset, size_t count, size_t *writes) |
{ |
int ret = count; |
const char *p = buff; |
while (count--) |
{ |
debug_out(*p++); |
}; |
*writes = ret; |
return ret; |
}; |
static int __openFileHandle(const char *path, int mode, int *err) |
{ |
fileinfo_t info; |
__file_handle *handle; |
// path = getfullpath(name); |
*err = get_fileinfo(path, &info); |
if( mode & O_EXCL && mode & O_CREAT ) |
{ |
if( ! *err) |
{ |
*err = EEXIST; |
return -1; |
}; |
} |
if( *err) |
{ |
if(mode & O_CREAT) |
*err=create_file(path); |
if( *err) |
{ |
return -1; |
}; |
}; |
if( mode & O_TRUNC ) |
set_file_size(path, 0); |
if ( !(handle=(__file_handle*)malloc(sizeof( __file_handle) ))) |
{ |
*err = ENOMEM; |
return -1; |
}; |
handle->name = strdup(path); |
handle->offset = 0; |
handle->write = write_file; |
*err = 0; |
return (int)handle; |
}; |
int |
_DEFUN (_open_r, (ptr, file, flags, dmode), |
struct _reent *ptr _AND |
_CONST char *file _AND |
int flags _AND |
int dmode) |
{ |
int hid; |
int handle; |
int err = 0; |
unsigned iomode_flags; |
int rwmode; |
/* |
if (flags & ~(O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_APPEND | O_TRUNC)) |
{ |
ptr->_errno = ENOSYS; |
return -1; |
} |
*/ |
// First try to get the required slot. |
// No point in creating a file only to not use it. JBS 99/10/26 |
hid = __allocPOSIXHandle( DUMMY_HANDLE ); |
if( hid == -1 ) |
{ |
ptr->_errno = EMFILE; |
return( -1 ); |
} |
handle = __openFileHandle( file, flags, &err); |
if( handle == -1 ) |
{ |
__freePOSIXHandle( hid ); |
ptr->_errno = err; |
return( -1 ); |
} |
__setOSHandle( hid, handle ); // JBS 99/11/01 |
rwmode = flags & ( O_RDONLY | O_WRONLY | O_RDWR | O_NOINHERIT ); |
iomode_flags = 0; |
if( rwmode == O_RDWR ) iomode_flags |= _READ | _WRITE; |
else if( rwmode == O_RDONLY) iomode_flags |= _READ; |
else if( rwmode == O_WRONLY) iomode_flags |= _WRITE; |
if( flags & O_APPEND ) iomode_flags |= _APPEND; |
if( flags & (O_BINARY|O_TEXT) ) { |
if( flags & O_BINARY ) iomode_flags |= _BINARY; |
} else { |
if( _fmode == O_BINARY ) iomode_flags |= _BINARY; |
} |
__SetIOMode( hid, iomode_flags ); |
ptr->_errno = 0; |
return (hid); |
} |
int |
_DEFUN (open, (file, flags, ...), |
const char *file _AND |
int flags _DOTS) |
{ |
va_list ap; |
int ret; |
va_start (ap, flags); |
ret = _open_r (_REENT, file, flags, va_arg (ap, int)); |
va_end (ap); |
return ret; |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/contrib/sdk/sources/libc/reent/readr.c |
---|
0,0 → 1,168 |
/* Reentrant versions of read system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <errno.h> |
/* Some targets provides their own versions of this functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
/* We use the errno variable used by the system dependent layer. */ |
/* |
FUNCTION |
<<_read_r>>---Reentrant version of read |
INDEX |
_read_r |
ANSI_SYNOPSIS |
#include <reent.h> |
_ssize_t _read_r(struct _reent *<[ptr]>, |
int <[fd]>, void *<[buf]>, size_t <[cnt]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
_ssize_t _read_r(<[ptr]>, <[fd]>, <[buf]>, <[cnt]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
char *<[buf]>; |
size_t <[cnt]>; |
DESCRIPTION |
This is a reentrant version of <<read>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
extern unsigned __NFiles; |
#define _READ 0x0001 /* file opened for reading */ |
#define _BINARY 0x0040 /* file is binary, skip CRLF processing */ |
#define _ISTTY 0x2000 /* is console device */ |
#define __handle_check( __h, __r ) \ |
if( (__h) < 0 || (__h) > __NFiles ) { \ |
ptr->_errno = EBADF; \ |
return( __r ); \ |
} |
_ssize_t |
_DEFUN (_read, (fd, buf, cnt), |
int fd _AND |
_PTR buf _AND |
size_t cnt) |
{ |
return _read_r( _REENT, fd, buf, cnt); |
} |
_ssize_t |
_DEFUN (_read_r, (ptr, fd, buf, cnt), |
struct _reent *ptr _AND |
int fd _AND |
_PTR buf _AND |
size_t cnt) |
{ |
_ssize_t ret; |
_ssize_t read_len, total_len; |
unsigned reduce_idx, finish_idx; |
unsigned iomode_flags; |
char *buffer = buf; |
int rc; |
int h; |
unsigned amount_read; |
int err; |
__file_handle *fh; |
__handle_check( fd, -1 ); |
__ChkTTYIOMode( fd ); |
iomode_flags = __GetIOMode( fd ); |
if( iomode_flags == 0 ) |
{ |
ptr->_errno = EBADF; |
return( -1 ); |
} |
if( !(iomode_flags & _READ) ) |
{ |
ptr->_errno = EACCES; /* changed from EBADF to EACCES 23-feb-89 */ |
return( -1 ); |
} |
fh = (__file_handle*) __getOSHandle( fd ); |
if( iomode_flags & _BINARY ) /* if binary mode */ |
{ |
err = read_file(fh->name, buffer, fh->offset, cnt, &amount_read); |
fh->offset+= amount_read; |
total_len = amount_read; |
if(err) |
if ( amount_read == 0) |
return (-1); |
} |
else |
{ |
total_len = 0; |
read_len = cnt; |
do |
{ |
err=read_file(fh->name,buffer, fh->offset, cnt, &amount_read); |
fh->offset+=amount_read; |
if( amount_read == 0 ) |
break; /* EOF */ |
reduce_idx = 0; |
finish_idx = reduce_idx; |
for( ; reduce_idx < amount_read; ++reduce_idx ) |
{ |
if( buffer[ reduce_idx ] == 0x1a ) /* EOF */ |
{ |
_lseek_r(ptr, fd, ((long)reduce_idx - (long)amount_read)+1L, |
SEEK_CUR ); |
total_len += finish_idx; |
return( total_len ); |
} |
if( buffer[ reduce_idx ] != '\r' ) |
{ |
buffer[ finish_idx++ ] = buffer[ reduce_idx ]; |
}; |
} |
total_len += finish_idx; |
buffer += finish_idx; |
read_len -= finish_idx; |
if( iomode_flags & _ISTTY ) |
{ |
break; /* 04-feb-88, FWC */ |
} |
} while( read_len != 0 ); |
} |
return( total_len ); |
} |
_ssize_t |
_DEFUN (read, (fd, buf, cnt), |
int fd _AND |
_PTR buf _AND |
size_t cnt) |
{ |
return _read_r(_REENT, fd, buf, cnt); |
}; |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/contrib/sdk/sources/libc/reent/writer.c |
---|
0,0 → 1,257 |
/* Reentrant versions of write system call. */ |
#include <reent.h> |
#include <unistd.h> |
#include <_syslist.h> |
#include <alloca.h> |
#include <errno.h> |
#include <string.h> |
/* Some targets provides their own versions of this functions. Those |
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
#ifdef _REENT_ONLY |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
#define REENTRANT_SYSCALLS_PROVIDED |
#endif |
#endif |
#ifndef REENTRANT_SYSCALLS_PROVIDED |
/* We use the errno variable used by the system dependent layer. */ |
/* |
FUNCTION |
<<_write_r>>---Reentrant version of write |
INDEX |
_write_r |
ANSI_SYNOPSIS |
#include <reent.h> |
_ssize_t _write_r(struct _reent *<[ptr]>, |
int <[fd]>, const void *<[buf]>, size_t <[cnt]>); |
TRAD_SYNOPSIS |
#include <reent.h> |
_ssize_t _write_r(<[ptr]>, <[fd]>, <[buf]>, <[cnt]>) |
struct _reent *<[ptr]>; |
int <[fd]>; |
char *<[buf]>; |
size_t <[cnt]>; |
DESCRIPTION |
This is a reentrant version of <<write>>. It |
takes a pointer to the global data block, which holds |
<<errno>>. |
*/ |
#define _WRITE 0x0002 /* file opened for writing */ |
#define _APPEND 0x0080 /* file opened for append */ |
#define _BINARY 0x0040 /* file is binary, skip CRLF processing */ |
#define _ISTTY 0x2000 /* is console device */ |
#define _FILEEXT 0x8000 /* lseek with positive offset has been done */ |
#define __handle_check( __h, __r ) \ |
if( (__h) < 0 || (__h) > __NFiles ) { \ |
ptr->_errno = EBADF; \ |
return( __r ); \ |
} |
extern unsigned __NFiles; |
#define PAD_SIZE 512 |
static int zero_pad(struct _reent *ptr, int handle ) /* 09-jan-95 */ |
/*******************************/ |
{ |
int rc; |
long curPos, eodPos; |
long bytesToWrite; |
unsigned writeAmt; |
char zeroBuf[PAD_SIZE]; |
// Pad with zeros due to lseek() past EOF (POSIX) |
curPos = _lseek_r( ptr, handle, 0L, SEEK_CUR ); /* current offset */ |
if( curPos == -1 ) |
return( -1 ); |
eodPos = _lseek_r( ptr, handle, 0L, SEEK_END ); /* end of data offset */ |
if( eodPos == -1 ) |
return( -1 ); |
if( curPos > eodPos ) { |
bytesToWrite = curPos - eodPos; /* amount to pad by */ |
if( bytesToWrite > 0 ) { /* only write if needed */ |
memset( zeroBuf, 0x00, PAD_SIZE ); /* zero out a buffer */ |
do { /* loop until done */ |
if( bytesToWrite > PAD_SIZE ) |
writeAmt = 512; |
else |
writeAmt = (unsigned)bytesToWrite; |
rc = _write_r(ptr, handle, zeroBuf, writeAmt ); |
if( rc < 0 ) |
return( rc ); |
bytesToWrite -= writeAmt; /* more bytes written */ |
} while( bytesToWrite != 0 ); |
} |
} else { |
curPos = _lseek_r( ptr, handle, curPos, SEEK_SET ); |
if( curPos == -1 ) { |
return( -1 ); |
} |
} |
return( 0 ); /* return success code */ |
} |
static int os_write(struct _reent *ptr, int handle, |
const void *buffer, unsigned len, unsigned *amt ) |
/********************************************************************************/ |
{ |
__file_handle *fh; |
int rc; |
rc = 0; |
*amt = 0; |
fh = (__file_handle*) __getOSHandle( handle ); |
rc = fh->write(fh->name,buffer,fh->offset,len,amt); |
fh->offset+= *amt; |
if( *amt != len ) |
{ |
rc = ENOSPC; |
ptr->_errno = ENOSPC; |
} |
return( rc ); |
} |
_ssize_t |
_DEFUN (_write_r, (ptr, fd, buffer, cnt), |
struct _reent *ptr _AND |
int fd _AND |
_CONST _PTR buffer _AND |
size_t cnt) |
{ |
_ssize_t ret; |
unsigned int iomode_flags; |
unsigned len_written, i, j; |
int rc2; |
char *buf; |
__file_handle *fh; |
__handle_check( fd, -1 ); |
iomode_flags = __GetIOMode( fd ); |
if( iomode_flags == 0 ) |
{ |
ptr->_errno = EBADF; |
return( -1 ); |
} |
if( !(iomode_flags & _WRITE) ) { |
ptr->_errno = EACCES ; /* changed from EBADF to EACCES 23-feb-89 */ |
return( -1 ); |
} |
if( (iomode_flags & _APPEND) && !(iomode_flags & _ISTTY) ) |
{ |
fh->offset = _lseek_r(ptr, fd, 0L, SEEK_END ); /* end of data offset */ |
} |
len_written = 0; |
rc2 = 0; |
// Pad the file with zeros if necessary |
if( iomode_flags & _FILEEXT ) |
{ |
// turn off file extended flag |
__SetIOMode_nogrow( fd, iomode_flags&(~_FILEEXT) ); |
// It is not required to pad a file with zeroes on an NTFS file system; |
// unfortunately it is required on FAT (and probably FAT32). (JBS) |
rc2 = zero_pad( ptr, fd ); |
} |
if( rc2 == 0 ) |
{ |
if( iomode_flags & _BINARY ) { /* if binary mode */ |
rc2 = os_write(ptr, fd, buffer, cnt, &len_written ); |
/* end of binary mode part */ |
} else { /* text mode */ |
int buf_size = 512; |
buf = (char*)alloca( buf_size ); |
j = 0; |
for( i = 0; i < cnt; ) |
{ |
if( ((const char*)buffer)[i] == '\n' ) |
{ |
buf[j] = '\r'; |
++j; |
if( j == buf_size ) |
{ |
rc2 = os_write(ptr, fd, buf, buf_size, &j ); |
if( rc2 == -1 ) |
break; |
len_written += j; |
if( rc2 == ENOSPC ) |
break; |
len_written = i; |
j = 0; |
} |
} |
buf[j] = ((const char*)buffer)[i]; |
++i; |
++j; |
if( j == buf_size ) { |
rc2 = os_write(ptr, fd, buf, buf_size, &j ); |
if( rc2 == -1 ) |
break; |
len_written += j; |
if( rc2 == ENOSPC ) |
break; |
len_written = i; |
j = 0; |
} |
} |
if( j ) { |
rc2 = os_write(ptr, fd, buf, j, &i ); |
if( rc2 == ENOSPC ) { |
len_written += i; |
} else { |
len_written = cnt; |
} |
} |
/* end of text mode part */ |
} |
} |
if( rc2 == -1 ) { |
return( rc2 ); |
} else { |
return( len_written ); |
} |
} |
_ssize_t |
_DEFUN (write, ( fd, buffer, cnt), |
int fd _AND |
_CONST _PTR buffer _AND |
size_t cnt) |
{ |
return _write_r(_REENT, fd, buffer, cnt); |
} |
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
/contrib/sdk/sources/libc/sdk/fasm/hello.asm |
---|
0,0 → 1,30 |
STACK_SIZE equ 4096 |
include "app.inc" |
align 8 |
main: |
cinvoke _printf, msg_hello |
ret |
msg_hello db 'Hello world!',0x0D,0x0A,0 |
align 16 |
__idata_start: |
library libc,'libc.dll' |
include 'libc.inc' |
__idata_end: |
__iend: |
__cmdline: rb 256 |
__pgmname: rb 1024 |
rb 16 |
__stack: |
__bssend: |
/contrib/sdk/sources/libc/sdk/fasm/include/app.inc |
---|
0,0 → 1,283 |
include 'import32.inc' |
include 'proc32.inc' |
use32 |
org 0x0 |
db 'MENUET02' |
dd 0x01 |
dd __start |
dd __iend |
dd __bssend |
dd __stack |
dd __cmdline |
dd __pgmname |
dd 0x0 |
dd __idata_start |
dd __idata_end |
dd main |
IMAGE_DOS_SIGNATURE equ 0x5A4D |
IMAGE_NT_SIGNATURE equ 0x00004550 |
IMAGE_FILE_MACHINE_I386 equ 0x014c |
IMAGE_NT_OPTIONAL_HDR32_MAGIC equ 0x10B |
IMAGE_NT_HEADERS32_SIZE equ 0xF8 |
__start: |
.e_lfanew equ 0x3C |
.FileHeader.NumberOfSections equ 0x06 |
.OptionalHeader.ImageBase equ 0x34 |
.SectionAlignment equ 0x38 |
.FileAlignment equ 0x3C |
.OptionalHeader.SizeOfImage equ 0x50 |
.OptionalHeader.SizeOfHeaders equ 0x54 |
.VirtualAddress equ 0x0C |
.SizeOfRawData equ 0x10 |
.PointerToRawData equ 0x14 |
.OptionalHeader.RelocDataDirectory.VirtualAddress equ 0xA0 |
.OptionalHeader.RelocDataDirectory.Size equ 0xA4 |
.SizeOfBlock equ 0x04 |
mov eax, 68 |
mov ebx, 12 |
mov ecx, STACK_SIZE |
add ecx, 4095 |
and ecx, -4096 |
int 0x40 |
test eax, eax |
jz .exit |
add ecx, eax |
mov [fs:8], eax |
mov [fs:12], ecx |
mov esp, ecx |
sub esp, 1024 |
mov eax, 9 |
mov ebx, esp |
mov ecx, -1 |
int 0x40 |
mov eax, [ebx+30] |
mov [fs:0], eax |
add esp, 1024 |
mov eax, 68 |
mov ebx, 27 |
mov ecx, libc_path |
int 0x40 |
test eax, eax |
jz .exit |
push edx |
push eax |
.validate_pe: |
cmp edx, 0x3F |
jbe .exit |
cmp word [eax], IMAGE_DOS_SIGNATURE |
jne .exit |
mov edx, [eax+.e_lfanew] |
test edx, edx |
jz .exit |
add edx, eax ;edx = nt header |
jb .exit |
cmp dword [edx], IMAGE_NT_SIGNATURE |
jnz .exit |
cmp word [edx+0x04], IMAGE_FILE_MACHINE_I386 |
jnz .exit |
cmp word [edx+0x18], IMAGE_NT_OPTIONAL_HDR32_MAGIC |
jnz .exit |
mov ecx, [edx+.SectionAlignment] |
cmp ecx, 4095 |
ja .l1 |
cmp ecx, [edx+.FileAlignment] |
jne .exit |
jmp @F |
.l1: |
cmp ecx, [edx+.FileAlignment] |
jb .exit |
@@: |
test ecx, ecx |
jz .exit |
lea eax, [ecx-1] |
test ecx, eax |
jnz .exit |
mov ecx, [edx+.FileAlignment] |
test ecx, ecx |
jz .exit |
lea ebx, [ecx-1] |
test ecx, ebx |
jnz .exit |
cmp word [edx+.FileHeader.NumberOfSections], 96 |
ja .exit |
.create_image: |
mov ecx, [edx+.OptionalHeader.SizeOfImage] |
mov eax, 68 |
mov ebx, 12 |
int 0x40 |
mov ebp, eax |
test eax, eax |
jz .exit_2 |
mov ecx, [edx+.OptionalHeader.SizeOfHeaders] |
mov esi, [esp] |
mov edi, eax |
shr ecx, 2 ;copy header |
rep movsd |
lea eax, [edx+IMAGE_NT_HEADERS32_SIZE] ;eax = MAGE_SECTION_HEADER |
movzx ebx, word [edx+.FileHeader.NumberOfSections] |
test ebx, ebx |
jz @F |
.copy_loop: |
mov ecx, [eax+.SizeOfRawData] |
test ecx, ecx |
jz .next_section |
mov esi, [eax+.PointerToRawData] |
test esi, esi |
jz .next_section |
add esi, [esp] |
mov edi, [eax+.VirtualAddress] |
add edi, ebp |
shr ecx, 2 |
rep movsd |
;copy section |
.next_section: |
add eax, 0x28 |
dec ebx |
jnz .copy_loop |
@@: |
push edx |
mov esi, [edx+.OptionalHeader.RelocDataDirectory.Size] |
test esi, esi |
jz .call_libc |
mov ebx, ebp |
sub ebx, [edx+.OptionalHeader.ImageBase] ;delta |
mov edx, [edx+.OptionalHeader.RelocDataDirectory.VirtualAddress] |
lea ecx, [ebp+edx] ;IMAGE_BASE_RELOCATION |
mov eax, [ecx+.SizeOfBlock] |
test eax, eax |
jz .unmap_relocs |
mov esi, ebx |
shr esi, 16 |
push esi |
align 4 |
.loop_block: |
sub eax, 8 |
lea edx, [ecx+8] ;entry |
shr eax, 1 |
jz .next_block |
lea edi, [ecx+eax*2+8] ;last entry |
align 4 |
.loop_reloc: |
mov si, [edx] |
mov eax, esi |
and eax, 0FFFh |
add eax, [ecx] ;offset |
shr si, 12 ;reloc type |
dec si |
jnz @F |
.type_1: |
mov esi, [esp] |
add [eax+ebp], si |
jmp .next_entry |
@@: |
dec si |
jnz @F |
.type_2: |
add [eax+ebp], bx |
jmp .next_entry |
@@: |
dec si |
jnz .next_entry |
.type_3: |
add [eax+ebp], ebx |
.next_entry: |
add edx, 2 |
cmp edx, edi |
jne .loop_reloc |
.next_block: |
add ecx, [ecx+.SizeOfBlock] |
mov eax, [ecx+.SizeOfBlock] |
test eax, eax |
jnz .loop_block |
add esp, 4 |
pop edx |
mov esi, [edx+.OptionalHeader.RelocDataDirectory.Size] |
mov edx, [edx+.OptionalHeader.RelocDataDirectory.VirtualAddress] |
.unmap_relocs: |
mov ebx, 26 |
mov eax, 68 |
mov ecx, ebp |
int 0x40 |
.call_libc: |
push ebp |
mov edx, [ebp+0x3C] |
add ebp, [ebp+edx+0x28] |
call ebp |
.exit_2: |
.exit: |
or eax, -1 |
int 0x40 |
libc_path db '/kolibrios/lib/libc.dll',0 |
/contrib/sdk/sources/libc/sdk/fasm/include/avcodec-54.inc |
---|
0,0 → 1,275 |
import avcodec-54,\ |
audio_resample,'audio_resample',\ |
audio_resample_close,'audio_resample_close',\ |
av_audio_convert,'av_audio_convert',\ |
av_audio_convert_alloc,'av_audio_convert_alloc',\ |
av_audio_convert_free,'av_audio_convert_free',\ |
av_audio_resample_init,'av_audio_resample_init',\ |
av_bitstream_filter_close,'av_bitstream_filter_close',\ |
av_bitstream_filter_filter,'av_bitstream_filter_filter',\ |
av_bitstream_filter_init,'av_bitstream_filter_init',\ |
av_bitstream_filter_next,'av_bitstream_filter_next',\ |
av_codec_get_codec_descriptor,'av_codec_get_codec_descriptor',\ |
av_codec_get_pkt_timebase,'av_codec_get_pkt_timebase',\ |
av_codec_is_decoder,'av_codec_is_decoder',\ |
av_codec_is_encoder,'av_codec_is_encoder',\ |
av_codec_next,'av_codec_next',\ |
av_codec_set_codec_descriptor,'av_codec_set_codec_descriptor',\ |
av_codec_set_pkt_timebase,'av_codec_set_pkt_timebase',\ |
av_copy_packet,'av_copy_packet',\ |
av_dct_calc,'av_dct_calc',\ |
av_dct_end,'av_dct_end',\ |
av_dct_init,'av_dct_init',\ |
av_destruct_packet,'av_destruct_packet',\ |
av_dup_packet,'av_dup_packet',\ |
av_fast_malloc,'av_fast_malloc',\ |
av_fast_padded_malloc,'av_fast_padded_malloc',\ |
av_fast_padded_mallocz,'av_fast_padded_mallocz',\ |
av_fast_realloc,'av_fast_realloc',\ |
av_fft_calc,'av_fft_calc',\ |
av_fft_end,'av_fft_end',\ |
av_fft_init,'av_fft_init',\ |
av_fft_permute,'av_fft_permute',\ |
av_frame_get_best_effort_timestamp,'av_frame_get_best_effort_timestamp',\ |
av_frame_get_channel_layout,'av_frame_get_channel_layout',\ |
av_frame_get_channels,'av_frame_get_channels',\ |
av_frame_get_decode_error_flags,'av_frame_get_decode_error_flags',\ |
av_frame_get_metadata,'av_frame_get_metadata',\ |
av_frame_get_pkt_duration,'av_frame_get_pkt_duration',\ |
av_frame_get_pkt_pos,'av_frame_get_pkt_pos',\ |
av_frame_get_pkt_size,'av_frame_get_pkt_size',\ |
av_frame_get_sample_rate,'av_frame_get_sample_rate',\ |
av_frame_set_best_effort_timestamp,'av_frame_set_best_effort_timestamp',\ |
av_frame_set_channel_layout,'av_frame_set_channel_layout',\ |
av_frame_set_channels,'av_frame_set_channels',\ |
av_frame_set_decode_error_flags,'av_frame_set_decode_error_flags',\ |
av_frame_set_metadata,'av_frame_set_metadata',\ |
av_frame_set_pkt_duration,'av_frame_set_pkt_duration',\ |
av_frame_set_pkt_pos,'av_frame_set_pkt_pos',\ |
av_frame_set_pkt_size,'av_frame_set_pkt_size',\ |
av_frame_set_sample_rate,'av_frame_set_sample_rate',\ |
av_free_packet,'av_free_packet',\ |
av_get_audio_frame_duration,'av_get_audio_frame_duration',\ |
av_get_bits_per_sample,'av_get_bits_per_sample',\ |
av_get_codec_tag_string,'av_get_codec_tag_string',\ |
av_get_exact_bits_per_sample,'av_get_exact_bits_per_sample',\ |
av_get_pcm_codec,'av_get_pcm_codec',\ |
av_get_profile_name,'av_get_profile_name',\ |
av_grow_packet,'av_grow_packet',\ |
av_hwaccel_next,'av_hwaccel_next',\ |
av_imdct_calc,'av_imdct_calc',\ |
av_imdct_half,'av_imdct_half',\ |
av_init_packet,'av_init_packet',\ |
av_lockmgr_register,'av_lockmgr_register',\ |
av_log_ask_for_sample,'av_log_ask_for_sample',\ |
av_log_missing_feature,'av_log_missing_feature',\ |
av_mdct_calc,'av_mdct_calc',\ |
av_mdct_end,'av_mdct_end',\ |
av_mdct_init,'av_mdct_init',\ |
av_new_packet,'av_new_packet',\ |
av_packet_get_side_data,'av_packet_get_side_data',\ |
av_packet_merge_side_data,'av_packet_merge_side_data',\ |
av_packet_new_side_data,'av_packet_new_side_data',\ |
av_packet_shrink_side_data,'av_packet_shrink_side_data',\ |
av_packet_split_side_data,'av_packet_split_side_data',\ |
av_parser_change,'av_parser_change',\ |
av_parser_close,'av_parser_close',\ |
av_parser_init,'av_parser_init',\ |
av_parser_next,'av_parser_next',\ |
av_parser_parse2,'av_parser_parse2',\ |
av_picture_copy,'av_picture_copy',\ |
av_picture_crop,'av_picture_crop',\ |
av_picture_pad,'av_picture_pad',\ |
av_rdft_calc,'av_rdft_calc',\ |
av_rdft_end,'av_rdft_end',\ |
av_rdft_init,'av_rdft_init',\ |
av_register_bitstream_filter,'av_register_bitstream_filter',\ |
av_register_codec_parser,'av_register_codec_parser',\ |
av_register_hwaccel,'av_register_hwaccel',\ |
av_resample,'av_resample',\ |
av_resample_close,'av_resample_close',\ |
av_resample_compensate,'av_resample_compensate',\ |
av_resample_init,'av_resample_init',\ |
av_shrink_packet,'av_shrink_packet',\ |
av_xiphlacing,'av_xiphlacing',\ |
avcodec_align_dimensions,'avcodec_align_dimensions',\ |
avcodec_align_dimensions2,'avcodec_align_dimensions2',\ |
avcodec_alloc_context,'avcodec_alloc_context',\ |
avcodec_alloc_context2,'avcodec_alloc_context2',\ |
avcodec_alloc_context3,'avcodec_alloc_context3',\ |
avcodec_alloc_frame,'avcodec_alloc_frame',\ |
avcodec_close,'avcodec_close',\ |
avcodec_configuration,'avcodec_configuration',\ |
avcodec_copy_context,'avcodec_copy_context',\ |
avcodec_decode_audio3,'avcodec_decode_audio3',\ |
avcodec_decode_audio4,'avcodec_decode_audio4',\ |
avcodec_decode_subtitle2,'avcodec_decode_subtitle2',\ |
avcodec_decode_video2,'avcodec_decode_video2',\ |
avcodec_default_execute,'avcodec_default_execute',\ |
avcodec_default_execute2,'avcodec_default_execute2',\ |
avcodec_default_free_buffers,'avcodec_default_free_buffers',\ |
avcodec_default_get_buffer,'avcodec_default_get_buffer',\ |
avcodec_default_get_format,'avcodec_default_get_format',\ |
avcodec_default_reget_buffer,'avcodec_default_reget_buffer',\ |
avcodec_default_release_buffer,'avcodec_default_release_buffer',\ |
avcodec_descriptor_get,'avcodec_descriptor_get',\ |
avcodec_descriptor_get_by_name,'avcodec_descriptor_get_by_name',\ |
avcodec_descriptor_next,'avcodec_descriptor_next',\ |
avcodec_encode_audio,'avcodec_encode_audio',\ |
avcodec_encode_audio2,'avcodec_encode_audio2',\ |
avcodec_encode_subtitle,'avcodec_encode_subtitle',\ |
avcodec_encode_video,'avcodec_encode_video',\ |
avcodec_encode_video2,'avcodec_encode_video2',\ |
avcodec_fill_audio_frame,'avcodec_fill_audio_frame',\ |
avcodec_find_best_pix_fmt,'avcodec_find_best_pix_fmt',\ |
avcodec_find_best_pix_fmt2,'avcodec_find_best_pix_fmt2',\ |
avcodec_find_best_pix_fmt_of_2,'avcodec_find_best_pix_fmt_of_2',\ |
avcodec_find_best_pix_fmt_of_list,'avcodec_find_best_pix_fmt_of_list',\ |
avcodec_find_decoder,'avcodec_find_decoder',\ |
avcodec_find_decoder_by_name,'avcodec_find_decoder_by_name',\ |
avcodec_find_encoder,'avcodec_find_encoder',\ |
avcodec_find_encoder_by_name,'avcodec_find_encoder_by_name',\ |
avcodec_flush_buffers,'avcodec_flush_buffers',\ |
avcodec_free_frame,'avcodec_free_frame',\ |
avcodec_get_chroma_sub_sample,'avcodec_get_chroma_sub_sample',\ |
avcodec_get_class,'avcodec_get_class',\ |
avcodec_get_context_defaults,'avcodec_get_context_defaults',\ |
avcodec_get_context_defaults2,'avcodec_get_context_defaults2',\ |
avcodec_get_context_defaults3,'avcodec_get_context_defaults3',\ |
avcodec_get_edge_width,'avcodec_get_edge_width',\ |
avcodec_get_frame_class,'avcodec_get_frame_class',\ |
avcodec_get_frame_defaults,'avcodec_get_frame_defaults',\ |
avcodec_get_name,'avcodec_get_name',\ |
avcodec_get_pix_fmt_loss,'avcodec_get_pix_fmt_loss',\ |
avcodec_get_subtitle_rect_class,'avcodec_get_subtitle_rect_class',\ |
avcodec_get_type,'avcodec_get_type',\ |
avcodec_is_open,'avcodec_is_open',\ |
avcodec_license,'avcodec_license',\ |
avcodec_open,'avcodec_open',\ |
avcodec_open2,'avcodec_open2',\ |
avcodec_pix_fmt_to_codec_tag,'avcodec_pix_fmt_to_codec_tag',\ |
avcodec_register,'avcodec_register',\ |
avcodec_register_all,'avcodec_register_all',\ |
avcodec_set_dimensions,'avcodec_set_dimensions',\ |
avcodec_string,'avcodec_string',\ |
avcodec_version,'avcodec_version',\ |
avpicture_alloc,'avpicture_alloc',\ |
avpicture_deinterlace,'avpicture_deinterlace',\ |
avpicture_fill,'avpicture_fill',\ |
avpicture_free,'avpicture_free',\ |
avpicture_get_size,'avpicture_get_size',\ |
avpicture_layout,'avpicture_layout',\ |
avpriv_aac_parse_header,'avpriv_aac_parse_header',\ |
avpriv_ac3_channel_layout_tab,'avpriv_ac3_channel_layout_tab',\ |
avpriv_ac3_parse_header,'avpriv_ac3_parse_header',\ |
avpriv_adx_decode_header,'avpriv_adx_decode_header',\ |
avpriv_align_put_bits,'avpriv_align_put_bits',\ |
avpriv_bprint_to_extradata,'avpriv_bprint_to_extradata',\ |
avpriv_check_timecode_rate,'avpriv_check_timecode_rate',\ |
avpriv_copy_bits,'avpriv_copy_bits',\ |
avpriv_copy_pce_data,'avpriv_copy_pce_data',\ |
avpriv_dca_sample_rates,'avpriv_dca_sample_rates',\ |
avpriv_dirac_parse_sequence_header,'avpriv_dirac_parse_sequence_header',\ |
avpriv_dnxhd_get_frame_size,'avpriv_dnxhd_get_frame_size',\ |
avpriv_dv_codec_profile,'avpriv_dv_codec_profile',\ |
avpriv_dv_frame_profile,'avpriv_dv_frame_profile',\ |
avpriv_dv_frame_profile2,'avpriv_dv_frame_profile2',\ |
avpriv_flac_is_extradata_valid,'avpriv_flac_is_extradata_valid',\ |
avpriv_flac_parse_block_header,'avpriv_flac_parse_block_header',\ |
avpriv_flac_parse_streaminfo,'avpriv_flac_parse_streaminfo',\ |
avpriv_framenum_to_drop_timecode,'avpriv_framenum_to_drop_timecode',\ |
avpriv_framenum_to_smpte_timecode,'avpriv_framenum_to_smpte_timecode',\ |
avpriv_h264_has_num_reorder_frames,'avpriv_h264_has_num_reorder_frames',\ |
avpriv_init_smpte_timecode,'avpriv_init_smpte_timecode',\ |
avpriv_lock_avformat,'avpriv_lock_avformat',\ |
avpriv_mjpeg_bits_ac_chrominance,'avpriv_mjpeg_bits_ac_chrominance',\ |
avpriv_mjpeg_bits_ac_luminance,'avpriv_mjpeg_bits_ac_luminance',\ |
avpriv_mjpeg_bits_dc_chrominance,'avpriv_mjpeg_bits_dc_chrominance',\ |
avpriv_mjpeg_bits_dc_luminance,'avpriv_mjpeg_bits_dc_luminance',\ |
avpriv_mjpeg_val_ac_chrominance,'avpriv_mjpeg_val_ac_chrominance',\ |
avpriv_mjpeg_val_ac_luminance,'avpriv_mjpeg_val_ac_luminance',\ |
avpriv_mjpeg_val_dc,'avpriv_mjpeg_val_dc',\ |
avpriv_mpa_bitrate_tab,'avpriv_mpa_bitrate_tab',\ |
avpriv_mpa_decode_header,'avpriv_mpa_decode_header',\ |
avpriv_mpa_freq_tab,'avpriv_mpa_freq_tab',\ |
avpriv_mpeg4audio_get_config,'avpriv_mpeg4audio_get_config',\ |
avpriv_mpeg4audio_sample_rates,'avpriv_mpeg4audio_sample_rates',\ |
avpriv_mpegaudio_decode_header,'avpriv_mpegaudio_decode_header',\ |
avpriv_mpv_find_start_code,'avpriv_mpv_find_start_code',\ |
avpriv_put_string,'avpriv_put_string',\ |
avpriv_split_xiph_headers,'avpriv_split_xiph_headers',\ |
avpriv_tak_parse_streaminfo,'avpriv_tak_parse_streaminfo',\ |
avpriv_timecode_to_string,'avpriv_timecode_to_string',\ |
avpriv_toupper4,'avpriv_toupper4',\ |
avpriv_unlock_avformat,'avpriv_unlock_avformat',\ |
avpriv_vorbis_parse_extradata,'avpriv_vorbis_parse_extradata',\ |
avpriv_vorbis_parse_frame,'avpriv_vorbis_parse_frame',\ |
avpriv_vorbis_parse_reset,'avpriv_vorbis_parse_reset',\ |
avsubtitle_free,'avsubtitle_free',\ |
dsputil_init,'dsputil_init',\ |
ff_aanscales,'ff_aanscales',\ |
ff_dct32_fixed,'ff_dct32_fixed',\ |
ff_dct32_float,'ff_dct32_float',\ |
ff_dct32_float_sse,'ff_dct32_float_sse',\ |
ff_dct32_float_sse2,'ff_dct32_float_sse2',\ |
ff_dct_common_init,'ff_dct_common_init',\ |
ff_dct_end,'ff_dct_end',\ |
ff_dct_init,'ff_dct_init',\ |
ff_dct_init_x86,'ff_dct_init_x86',\ |
ff_dnxhd_cid_table,'ff_dnxhd_cid_table',\ |
ff_dnxhd_get_cid_table,'ff_dnxhd_get_cid_table',\ |
ff_faanidct,'ff_faanidct',\ |
ff_faanidct_add,'ff_faanidct_add',\ |
ff_faanidct_put,'ff_faanidct_put',\ |
ff_fdct_mmx,'ff_fdct_mmx',\ |
ff_fdct_mmxext,'ff_fdct_mmxext',\ |
ff_fdct_sse2,'ff_fdct_sse2',\ |
ff_fft_calc_3dnow,'ff_fft_calc_3dnow',\ |
ff_fft_calc_3dnowext,'ff_fft_calc_3dnowext',\ |
ff_fft_calc_sse,'ff_fft_calc_sse',\ |
ff_fft_end,'ff_fft_end',\ |
ff_fft_end_fixed,'ff_fft_end_fixed',\ |
ff_fft_init,'ff_fft_init',\ |
ff_fft_init_fixed,'ff_fft_init_fixed',\ |
ff_fft_init_x86,'ff_fft_init_x86',\ |
ff_fft_permute_sse,'ff_fft_permute_sse',\ |
ff_find_pix_fmt,'ff_find_pix_fmt',\ |
ff_framenum_to_drop_timecode,'ff_framenum_to_drop_timecode',\ |
ff_framenum_to_smtpe_timecode,'ff_framenum_to_smtpe_timecode',\ |
ff_idct_xvid_mmx,'ff_idct_xvid_mmx',\ |
ff_idct_xvid_mmx_add,'ff_idct_xvid_mmx_add',\ |
ff_idct_xvid_mmx_put,'ff_idct_xvid_mmx_put',\ |
ff_idct_xvid_mmxext,'ff_idct_xvid_mmxext',\ |
ff_idct_xvid_mmxext_add,'ff_idct_xvid_mmxext_add',\ |
ff_idct_xvid_mmxext_put,'ff_idct_xvid_mmxext_put',\ |
ff_idct_xvid_sse2,'ff_idct_xvid_sse2',\ |
ff_idct_xvid_sse2_add,'ff_idct_xvid_sse2_add',\ |
ff_idct_xvid_sse2_put,'ff_idct_xvid_sse2_put',\ |
ff_init_smtpe_timecode,'ff_init_smtpe_timecode',\ |
ff_mdct_calc_c,'ff_mdct_calc_c',\ |
ff_mdct_calc_c_fixed,'ff_mdct_calc_c_fixed',\ |
ff_mdct_calcw_c,'ff_mdct_calcw_c',\ |
ff_mdct_end,'ff_mdct_end',\ |
ff_mdct_end_fixed,'ff_mdct_end_fixed',\ |
ff_mdct_init,'ff_mdct_init',\ |
ff_mdct_init_fixed,'ff_mdct_init_fixed',\ |
ff_mdct_win_fixed,'ff_mdct_win_fixed',\ |
ff_mdct_win_float,'ff_mdct_win_float',\ |
ff_mmx_idct,'ff_mmx_idct',\ |
ff_mmxext_idct,'ff_mmxext_idct',\ |
ff_raw_pix_fmt_tags,'ff_raw_pix_fmt_tags',\ |
ff_rdft_end,'ff_rdft_end',\ |
ff_rdft_init,'ff_rdft_init',\ |
ff_simple_idct248_put,'ff_simple_idct248_put',\ |
ff_simple_idct44_add,'ff_simple_idct44_add',\ |
ff_simple_idct48_add,'ff_simple_idct48_add',\ |
ff_simple_idct84_add,'ff_simple_idct84_add',\ |
ff_simple_idct_10,'ff_simple_idct_10',\ |
ff_simple_idct_8,'ff_simple_idct_8',\ |
ff_simple_idct_add_10,'ff_simple_idct_add_10',\ |
ff_simple_idct_add_8,'ff_simple_idct_add_8',\ |
ff_simple_idct_add_mmx,'ff_simple_idct_add_mmx',\ |
ff_simple_idct_mmx,'ff_simple_idct_mmx',\ |
ff_simple_idct_put_10,'ff_simple_idct_put_10',\ |
ff_simple_idct_put_8,'ff_simple_idct_put_8',\ |
ff_simple_idct_put_mmx,'ff_simple_idct_put_mmx' |
/contrib/sdk/sources/libc/sdk/fasm/include/avdevice-54.inc |
---|
0,0 → 1,5 |
import avdevice-54,\ |
avdevice_configuration,'avdevice_configuration',\ |
avdevice_license,'avdevice_license',\ |
avdevice_register_all,'avdevice_register_all',\ |
avdevice_version,'avdevice_version' |
/contrib/sdk/sources/libc/sdk/fasm/include/avformat-54.inc |
---|
0,0 → 1,132 |
import avformat-54,\ |
av_add_index_entry,'av_add_index_entry',\ |
av_append_packet,'av_append_packet',\ |
av_close_input_file,'av_close_input_file',\ |
av_codec_get_id,'av_codec_get_id',\ |
av_codec_get_tag,'av_codec_get_tag',\ |
av_convert_lang_to,'av_convert_lang_to',\ |
av_demuxer_open,'av_demuxer_open',\ |
av_dump_format,'av_dump_format',\ |
av_filename_number_test,'av_filename_number_test',\ |
av_find_best_stream,'av_find_best_stream',\ |
av_find_default_stream_index,'av_find_default_stream_index',\ |
av_find_input_format,'av_find_input_format',\ |
av_find_program_from_stream,'av_find_program_from_stream',\ |
av_find_stream_info,'av_find_stream_info',\ |
av_fmt_ctx_get_duration_estimation_method,'av_fmt_ctx_get_duration_estimation_method',\ |
av_get_frame_filename,'av_get_frame_filename',\ |
av_get_output_timestamp,'av_get_output_timestamp',\ |
av_get_packet,'av_get_packet',\ |
av_gettime,'av_gettime',\ |
av_guess_codec,'av_guess_codec',\ |
av_guess_format,'av_guess_format',\ |
av_guess_sample_aspect_ratio,'av_guess_sample_aspect_ratio',\ |
av_hex_dump,'av_hex_dump',\ |
av_hex_dump_log,'av_hex_dump_log',\ |
av_iformat_next,'av_iformat_next',\ |
av_index_search_timestamp,'av_index_search_timestamp',\ |
av_interleave_packet_per_dts,'av_interleave_packet_per_dts',\ |
av_interleaved_write_frame,'av_interleaved_write_frame',\ |
av_match_ext,'av_match_ext',\ |
av_new_program,'av_new_program',\ |
av_new_stream,'av_new_stream',\ |
av_oformat_next,'av_oformat_next',\ |
av_pkt_dump2,'av_pkt_dump2',\ |
av_pkt_dump_log2,'av_pkt_dump_log2',\ |
av_probe_input_buffer,'av_probe_input_buffer',\ |
av_probe_input_format,'av_probe_input_format',\ |
av_probe_input_format2,'av_probe_input_format2',\ |
av_probe_input_format3,'av_probe_input_format3',\ |
av_read_frame,'av_read_frame',\ |
av_read_packet,'av_read_packet',\ |
av_read_pause,'av_read_pause',\ |
av_read_play,'av_read_play',\ |
av_register_all,'av_register_all',\ |
av_register_input_format,'av_register_input_format',\ |
av_register_output_format,'av_register_output_format',\ |
av_sdp_create,'av_sdp_create',\ |
av_seek_frame,'av_seek_frame',\ |
av_set_pts_info,'av_set_pts_info',\ |
av_url_split,'av_url_split',\ |
av_write_frame,'av_write_frame',\ |
av_write_trailer,'av_write_trailer',\ |
avformat_alloc_context,'avformat_alloc_context',\ |
avformat_alloc_output_context,'avformat_alloc_output_context',\ |
avformat_alloc_output_context2,'avformat_alloc_output_context2',\ |
avformat_close_input,'avformat_close_input',\ |
avformat_configuration,'avformat_configuration',\ |
avformat_find_stream_info,'avformat_find_stream_info',\ |
avformat_free_context,'avformat_free_context',\ |
avformat_get_class,'avformat_get_class',\ |
avformat_get_riff_audio_tags,'avformat_get_riff_audio_tags',\ |
avformat_get_riff_video_tags,'avformat_get_riff_video_tags',\ |
avformat_license,'avformat_license',\ |
avformat_match_stream_specifier,'avformat_match_stream_specifier',\ |
avformat_network_deinit,'avformat_network_deinit',\ |
avformat_network_init,'avformat_network_init',\ |
avformat_new_stream,'avformat_new_stream',\ |
avformat_open_input,'avformat_open_input',\ |
avformat_query_codec,'avformat_query_codec',\ |
avformat_queue_attached_pictures,'avformat_queue_attached_pictures',\ |
avformat_seek_file,'avformat_seek_file',\ |
avformat_version,'avformat_version',\ |
avformat_write_header,'avformat_write_header',\ |
avio_alloc_context,'avio_alloc_context',\ |
avio_check,'avio_check',\ |
avio_close,'avio_close',\ |
avio_close_dyn_buf,'avio_close_dyn_buf',\ |
avio_closep,'avio_closep',\ |
avio_enum_protocols,'avio_enum_protocols',\ |
avio_flush,'avio_flush',\ |
avio_get_str,'avio_get_str',\ |
avio_get_str16be,'avio_get_str16be',\ |
avio_get_str16le,'avio_get_str16le',\ |
avio_open,'avio_open',\ |
avio_open2,'avio_open2',\ |
avio_open_dyn_buf,'avio_open_dyn_buf',\ |
avio_pause,'avio_pause',\ |
avio_printf,'avio_printf',\ |
avio_put_str,'avio_put_str',\ |
avio_put_str16le,'avio_put_str16le',\ |
avio_r8,'avio_r8',\ |
avio_rb16,'avio_rb16',\ |
avio_rb24,'avio_rb24',\ |
avio_rb32,'avio_rb32',\ |
avio_rb64,'avio_rb64',\ |
avio_read,'avio_read',\ |
avio_rl16,'avio_rl16',\ |
avio_rl24,'avio_rl24',\ |
avio_rl32,'avio_rl32',\ |
avio_rl64,'avio_rl64',\ |
avio_seek,'avio_seek',\ |
avio_seek_time,'avio_seek_time',\ |
avio_size,'avio_size',\ |
avio_skip,'avio_skip',\ |
avio_w8,'avio_w8',\ |
avio_wb16,'avio_wb16',\ |
avio_wb24,'avio_wb24',\ |
avio_wb32,'avio_wb32',\ |
avio_wb64,'avio_wb64',\ |
avio_wl16,'avio_wl16',\ |
avio_wl24,'avio_wl24',\ |
avio_wl32,'avio_wl32',\ |
avio_wl64,'avio_wl64',\ |
avio_write,'avio_write',\ |
avpriv_dv_get_packet,'avpriv_dv_get_packet',\ |
avpriv_dv_init_demux,'avpriv_dv_init_demux',\ |
avpriv_dv_produce_packet,'avpriv_dv_produce_packet',\ |
avpriv_new_chapter,'avpriv_new_chapter',\ |
avpriv_set_pts_info,'avpriv_set_pts_info',\ |
ff_mpegts_parse_close,'ff_mpegts_parse_close',\ |
ff_mpegts_parse_open,'ff_mpegts_parse_open',\ |
ff_mpegts_parse_packet,'ff_mpegts_parse_packet',\ |
ffio_open_dyn_packet_buf,'ffio_open_dyn_packet_buf',\ |
ffio_set_buf_size,'ffio_set_buf_size',\ |
ffurl_close,'ffurl_close',\ |
ffurl_open,'ffurl_open',\ |
ffurl_protocol_next,'ffurl_protocol_next',\ |
ffurl_read_complete,'ffurl_read_complete',\ |
ffurl_seek,'ffurl_seek',\ |
ffurl_size,'ffurl_size',\ |
ffurl_write,'ffurl_write',\ |
url_feof,'url_feof' |
/contrib/sdk/sources/libc/sdk/fasm/include/avutil-52.inc |
---|
0,0 → 1,286 |
import avutil-52,\ |
av_add_q,'av_add_q',\ |
av_adler32_update,'av_adler32_update',\ |
av_aes_alloc,'av_aes_alloc',\ |
av_aes_crypt,'av_aes_crypt',\ |
av_aes_init,'av_aes_init',\ |
av_aes_size,'av_aes_size',\ |
av_asprintf,'av_asprintf',\ |
av_audio_fifo_alloc,'av_audio_fifo_alloc',\ |
av_audio_fifo_drain,'av_audio_fifo_drain',\ |
av_audio_fifo_free,'av_audio_fifo_free',\ |
av_audio_fifo_read,'av_audio_fifo_read',\ |
av_audio_fifo_realloc,'av_audio_fifo_realloc',\ |
av_audio_fifo_reset,'av_audio_fifo_reset',\ |
av_audio_fifo_size,'av_audio_fifo_size',\ |
av_audio_fifo_space,'av_audio_fifo_space',\ |
av_audio_fifo_write,'av_audio_fifo_write',\ |
av_base64_decode,'av_base64_decode',\ |
av_base64_encode,'av_base64_encode',\ |
av_basename,'av_basename',\ |
av_blowfish_crypt,'av_blowfish_crypt',\ |
av_blowfish_crypt_ecb,'av_blowfish_crypt_ecb',\ |
av_blowfish_init,'av_blowfish_init',\ |
av_bmg_get,'av_bmg_get',\ |
av_bprint_channel_layout,'av_bprint_channel_layout',\ |
av_bprint_chars,'av_bprint_chars',\ |
av_bprint_clear,'av_bprint_clear',\ |
av_bprint_finalize,'av_bprint_finalize',\ |
av_bprint_get_buffer,'av_bprint_get_buffer',\ |
av_bprint_init,'av_bprint_init',\ |
av_bprint_init_for_buffer,'av_bprint_init_for_buffer',\ |
av_bprint_strftime,'av_bprint_strftime',\ |
av_bprintf,'av_bprintf',\ |
av_calloc,'av_calloc',\ |
av_channel_layout_extract_channel,'av_channel_layout_extract_channel',\ |
av_compare_mod,'av_compare_mod',\ |
av_compare_ts,'av_compare_ts',\ |
av_crc,'av_crc',\ |
av_crc_get_table,'av_crc_get_table',\ |
av_crc_init,'av_crc_init',\ |
av_ctz,'av_ctz',\ |
av_d2q,'av_d2q',\ |
av_d2str,'av_d2str',\ |
av_dbl2ext,'av_dbl2ext',\ |
av_dbl2int,'av_dbl2int',\ |
av_default_get_category,'av_default_get_category',\ |
av_default_item_name,'av_default_item_name',\ |
av_des_crypt,'av_des_crypt',\ |
av_des_init,'av_des_init',\ |
av_des_mac,'av_des_mac',\ |
av_dict_copy,'av_dict_copy',\ |
av_dict_count,'av_dict_count',\ |
av_dict_free,'av_dict_free',\ |
av_dict_get,'av_dict_get',\ |
av_dict_set,'av_dict_set',\ |
av_dirname,'av_dirname',\ |
av_div_q,'av_div_q',\ |
av_dynarray_add,'av_dynarray_add',\ |
av_evaluate_lls,'av_evaluate_lls',\ |
av_expr_eval,'av_expr_eval',\ |
av_expr_free,'av_expr_free',\ |
av_expr_parse,'av_expr_parse',\ |
av_expr_parse_and_eval,'av_expr_parse_and_eval',\ |
av_ext2dbl,'av_ext2dbl',\ |
av_fifo_alloc,'av_fifo_alloc',\ |
av_fifo_drain,'av_fifo_drain',\ |
av_fifo_free,'av_fifo_free',\ |
av_fifo_generic_read,'av_fifo_generic_read',\ |
av_fifo_generic_write,'av_fifo_generic_write',\ |
av_fifo_grow,'av_fifo_grow',\ |
av_fifo_realloc2,'av_fifo_realloc2',\ |
av_fifo_reset,'av_fifo_reset',\ |
av_fifo_size,'av_fifo_size',\ |
av_fifo_space,'av_fifo_space',\ |
av_file_map,'av_file_map',\ |
av_file_unmap,'av_file_unmap',\ |
av_find_info_tag,'av_find_info_tag',\ |
av_find_nearest_q_idx,'av_find_nearest_q_idx',\ |
av_find_opt,'av_find_opt',\ |
av_flt2int,'av_flt2int',\ |
av_force_cpu_flags,'av_force_cpu_flags',\ |
av_free,'av_free',\ |
av_freep,'av_freep',\ |
av_gcd,'av_gcd',\ |
av_get_alt_sample_fmt,'av_get_alt_sample_fmt',\ |
av_get_bits_per_pixel,'av_get_bits_per_pixel',\ |
av_get_bits_per_sample_fmt,'av_get_bits_per_sample_fmt',\ |
av_get_bytes_per_sample,'av_get_bytes_per_sample',\ |
av_get_channel_description,'av_get_channel_description',\ |
av_get_channel_layout,'av_get_channel_layout',\ |
av_get_channel_layout_channel_index,'av_get_channel_layout_channel_index',\ |
av_get_channel_layout_nb_channels,'av_get_channel_layout_nb_channels',\ |
av_get_channel_layout_string,'av_get_channel_layout_string',\ |
av_get_channel_name,'av_get_channel_name',\ |
av_get_cpu_flags,'av_get_cpu_flags',\ |
av_get_default_channel_layout,'av_get_default_channel_layout',\ |
av_get_double,'av_get_double',\ |
av_get_int,'av_get_int',\ |
av_get_media_type_string,'av_get_media_type_string',\ |
av_get_packed_sample_fmt,'av_get_packed_sample_fmt',\ |
av_get_padded_bits_per_pixel,'av_get_padded_bits_per_pixel',\ |
av_get_picture_type_char,'av_get_picture_type_char',\ |
av_get_pix_fmt,'av_get_pix_fmt',\ |
av_get_pix_fmt_name,'av_get_pix_fmt_name',\ |
av_get_pix_fmt_string,'av_get_pix_fmt_string',\ |
av_get_planar_sample_fmt,'av_get_planar_sample_fmt',\ |
av_get_q,'av_get_q',\ |
av_get_random_seed,'av_get_random_seed',\ |
av_get_sample_fmt,'av_get_sample_fmt',\ |
av_get_sample_fmt_name,'av_get_sample_fmt_name',\ |
av_get_sample_fmt_string,'av_get_sample_fmt_string',\ |
av_get_standard_channel_layout,'av_get_standard_channel_layout',\ |
av_get_string,'av_get_string',\ |
av_get_token,'av_get_token',\ |
av_gettime,'av_gettime',\ |
av_image_alloc,'av_image_alloc',\ |
av_image_check_size,'av_image_check_size',\ |
av_image_copy,'av_image_copy',\ |
av_image_copy_plane,'av_image_copy_plane',\ |
av_image_copy_to_buffer,'av_image_copy_to_buffer',\ |
av_image_fill_arrays,'av_image_fill_arrays',\ |
av_image_fill_linesizes,'av_image_fill_linesizes',\ |
av_image_fill_max_pixsteps,'av_image_fill_max_pixsteps',\ |
av_image_fill_pointers,'av_image_fill_pointers',\ |
av_image_get_buffer_size,'av_image_get_buffer_size',\ |
av_image_get_linesize,'av_image_get_linesize',\ |
av_init_lls,'av_init_lls',\ |
av_int2dbl,'av_int2dbl',\ |
av_int2flt,'av_int2flt',\ |
av_lfg_init,'av_lfg_init',\ |
av_log,'av_log',\ |
av_log2,'av_log2',\ |
av_log2_16bit,'av_log2_16bit',\ |
av_log_default_callback,'av_log_default_callback',\ |
av_log_format_line,'av_log_format_line',\ |
av_log_get_level,'av_log_get_level',\ |
av_log_set_callback,'av_log_set_callback',\ |
av_log_set_flags,'av_log_set_flags',\ |
av_log_set_level,'av_log_set_level',\ |
av_lzo1x_decode,'av_lzo1x_decode',\ |
av_malloc,'av_malloc',\ |
av_mallocz,'av_mallocz',\ |
av_max_alloc,'av_max_alloc',\ |
av_md5_alloc,'av_md5_alloc',\ |
av_md5_final,'av_md5_final',\ |
av_md5_init,'av_md5_init',\ |
av_md5_size,'av_md5_size',\ |
av_md5_sum,'av_md5_sum',\ |
av_md5_update,'av_md5_update',\ |
av_memcpy_backptr,'av_memcpy_backptr',\ |
av_mul_q,'av_mul_q',\ |
av_nearer_q,'av_nearer_q',\ |
av_next_option,'av_next_option',\ |
av_opt_child_class_next,'av_opt_child_class_next',\ |
av_opt_child_next,'av_opt_child_next',\ |
av_opt_eval_double,'av_opt_eval_double',\ |
av_opt_eval_flags,'av_opt_eval_flags',\ |
av_opt_eval_float,'av_opt_eval_float',\ |
av_opt_eval_int,'av_opt_eval_int',\ |
av_opt_eval_int64,'av_opt_eval_int64',\ |
av_opt_eval_q,'av_opt_eval_q',\ |
av_opt_find,'av_opt_find',\ |
av_opt_find2,'av_opt_find2',\ |
av_opt_flag_is_set,'av_opt_flag_is_set',\ |
av_opt_free,'av_opt_free',\ |
av_opt_freep_ranges,'av_opt_freep_ranges',\ |
av_opt_get,'av_opt_get',\ |
av_opt_get_double,'av_opt_get_double',\ |
av_opt_get_image_size,'av_opt_get_image_size',\ |
av_opt_get_int,'av_opt_get_int',\ |
av_opt_get_key_value,'av_opt_get_key_value',\ |
av_opt_get_pixel_fmt,'av_opt_get_pixel_fmt',\ |
av_opt_get_q,'av_opt_get_q',\ |
av_opt_get_sample_fmt,'av_opt_get_sample_fmt',\ |
av_opt_next,'av_opt_next',\ |
av_opt_ptr,'av_opt_ptr',\ |
av_opt_query_ranges,'av_opt_query_ranges',\ |
av_opt_query_ranges_default,'av_opt_query_ranges_default',\ |
av_opt_set,'av_opt_set',\ |
av_opt_set_bin,'av_opt_set_bin',\ |
av_opt_set_defaults,'av_opt_set_defaults',\ |
av_opt_set_defaults2,'av_opt_set_defaults2',\ |
av_opt_set_dict,'av_opt_set_dict',\ |
av_opt_set_double,'av_opt_set_double',\ |
av_opt_set_from_string,'av_opt_set_from_string',\ |
av_opt_set_image_size,'av_opt_set_image_size',\ |
av_opt_set_int,'av_opt_set_int',\ |
av_opt_set_pixel_fmt,'av_opt_set_pixel_fmt',\ |
av_opt_set_q,'av_opt_set_q',\ |
av_opt_set_sample_fmt,'av_opt_set_sample_fmt',\ |
av_opt_show2,'av_opt_show2',\ |
av_parse_color,'av_parse_color',\ |
av_parse_cpu_caps,'av_parse_cpu_caps',\ |
av_parse_cpu_flags,'av_parse_cpu_flags',\ |
av_parse_ratio,'av_parse_ratio',\ |
av_parse_time,'av_parse_time',\ |
av_parse_video_rate,'av_parse_video_rate',\ |
av_parse_video_size,'av_parse_video_size',\ |
av_pix_fmt_desc_get,'av_pix_fmt_desc_get',\ |
av_pix_fmt_desc_get_id,'av_pix_fmt_desc_get_id',\ |
av_pix_fmt_desc_next,'av_pix_fmt_desc_next',\ |
av_pix_fmt_descriptors,'av_pix_fmt_descriptors',\ |
av_pix_fmt_get_chroma_sub_sample,'av_pix_fmt_get_chroma_sub_sample',\ |
av_rc4_crypt,'av_rc4_crypt',\ |
av_rc4_init,'av_rc4_init',\ |
av_read_image_line,'av_read_image_line',\ |
av_realloc,'av_realloc',\ |
av_realloc_f,'av_realloc_f',\ |
av_reduce,'av_reduce',\ |
av_rescale,'av_rescale',\ |
av_rescale_delta,'av_rescale_delta',\ |
av_rescale_q,'av_rescale_q',\ |
av_rescale_q_rnd,'av_rescale_q_rnd',\ |
av_rescale_rnd,'av_rescale_rnd',\ |
av_reverse,'av_reverse',\ |
av_sample_fmt_is_planar,'av_sample_fmt_is_planar',\ |
av_samples_alloc,'av_samples_alloc',\ |
av_samples_copy,'av_samples_copy',\ |
av_samples_fill_arrays,'av_samples_fill_arrays',\ |
av_samples_get_buffer_size,'av_samples_get_buffer_size',\ |
av_samples_set_silence,'av_samples_set_silence',\ |
av_set_cpu_flags_mask,'av_set_cpu_flags_mask',\ |
av_set_double,'av_set_double',\ |
av_set_int,'av_set_int',\ |
av_set_options_string,'av_set_options_string',\ |
av_set_q,'av_set_q',\ |
av_set_string3,'av_set_string3',\ |
av_sha_alloc,'av_sha_alloc',\ |
av_sha_final,'av_sha_final',\ |
av_sha_init,'av_sha_init',\ |
av_sha_size,'av_sha_size',\ |
av_sha_update,'av_sha_update',\ |
av_small_strptime,'av_small_strptime',\ |
av_solve_lls,'av_solve_lls',\ |
av_strcasecmp,'av_strcasecmp',\ |
av_strdup,'av_strdup',\ |
av_strerror,'av_strerror',\ |
av_stristart,'av_stristart',\ |
av_stristr,'av_stristr',\ |
av_strlcat,'av_strlcat',\ |
av_strlcatf,'av_strlcatf',\ |
av_strlcpy,'av_strlcpy',\ |
av_strncasecmp,'av_strncasecmp',\ |
av_strstart,'av_strstart',\ |
av_strtod,'av_strtod',\ |
av_strtok,'av_strtok',\ |
av_sub_q,'av_sub_q',\ |
av_tempfile,'av_tempfile',\ |
av_timecode_adjust_ntsc_framenum2,'av_timecode_adjust_ntsc_framenum2',\ |
av_timecode_check_frame_rate,'av_timecode_check_frame_rate',\ |
av_timecode_get_smpte_from_framenum,'av_timecode_get_smpte_from_framenum',\ |
av_timecode_init,'av_timecode_init',\ |
av_timecode_init_from_string,'av_timecode_init_from_string',\ |
av_timecode_make_mpeg_tc_string,'av_timecode_make_mpeg_tc_string',\ |
av_timecode_make_smpte_tc_string,'av_timecode_make_smpte_tc_string',\ |
av_timecode_make_string,'av_timecode_make_string',\ |
av_timegm,'av_timegm',\ |
av_tree_destroy,'av_tree_destroy',\ |
av_tree_enumerate,'av_tree_enumerate',\ |
av_tree_find,'av_tree_find',\ |
av_tree_insert,'av_tree_insert',\ |
av_tree_node_alloc,'av_tree_node_alloc',\ |
av_tree_node_size,'av_tree_node_size',\ |
av_update_lls,'av_update_lls',\ |
av_usleep,'av_usleep',\ |
av_vlog,'av_vlog',\ |
av_write_image_line,'av_write_image_line',\ |
av_xtea_crypt,'av_xtea_crypt',\ |
av_xtea_init,'av_xtea_init',\ |
avpriv_cga_font,'avpriv_cga_font',\ |
avpriv_float_dsp_init,'avpriv_float_dsp_init',\ |
avpriv_set_systematic_pal2,'avpriv_set_systematic_pal2',\ |
avpriv_vga16_font,'avpriv_vga16_font',\ |
avutil_configuration,'avutil_configuration',\ |
avutil_license,'avutil_license',\ |
avutil_version,'avutil_version',\ |
ff_cpu_cpuid,'ff_cpu_cpuid',\ |
ff_cpu_cpuid_test,'ff_cpu_cpuid_test',\ |
ff_cpu_xgetbv,'ff_cpu_xgetbv',\ |
ff_float_dsp_init_x86,'ff_float_dsp_init_x86',\ |
ff_get_cpu_flags_x86,'ff_get_cpu_flags_x86',\ |
ff_log2_tab,'ff_log2_tab',\ |
ff_vector_dmul_scalar_sse2,'ff_vector_dmul_scalar_sse2',\ |
ff_vector_fmac_scalar_sse,'ff_vector_fmac_scalar_sse',\ |
ff_vector_fmul_scalar_sse,'ff_vector_fmul_scalar_sse',\ |
ff_vector_fmul_sse,'ff_vector_fmul_sse' |
/contrib/sdk/sources/libc/sdk/fasm/include/cairo2.inc |
---|
0,0 → 1,1112 |
import cairo2,\ |
__cairo_clip_all,'__cairo_clip_all',\ |
__cairo_contour_add_point,'__cairo_contour_add_point',\ |
__cairo_contour_remove_last_chain,'__cairo_contour_remove_last_chain',\ |
__cairo_no_compositor,'__cairo_no_compositor',\ |
_cairo_analysis_surface_create,'_cairo_analysis_surface_create',\ |
_cairo_analysis_surface_get_bounding_box,'_cairo_analysis_surface_get_bounding_box',\ |
_cairo_analysis_surface_get_ctm,'_cairo_analysis_surface_get_ctm',\ |
_cairo_analysis_surface_get_supported,'_cairo_analysis_surface_get_supported',\ |
_cairo_analysis_surface_get_unsupported,'_cairo_analysis_surface_get_unsupported',\ |
_cairo_analysis_surface_has_supported,'_cairo_analysis_surface_has_supported',\ |
_cairo_analysis_surface_has_unsupported,'_cairo_analysis_surface_has_unsupported',\ |
_cairo_analysis_surface_merge_status,'_cairo_analysis_surface_merge_status',\ |
_cairo_analysis_surface_set_ctm,'_cairo_analysis_surface_set_ctm',\ |
_cairo_arc_path,'_cairo_arc_path',\ |
_cairo_arc_path_negative,'_cairo_arc_path_negative',\ |
_cairo_array_allocate,'_cairo_array_allocate',\ |
_cairo_array_append,'_cairo_array_append',\ |
_cairo_array_append_multiple,'_cairo_array_append_multiple',\ |
_cairo_array_copy_element,'_cairo_array_copy_element',\ |
_cairo_array_fini,'_cairo_array_fini',\ |
_cairo_array_grow_by,'_cairo_array_grow_by',\ |
_cairo_array_index,'_cairo_array_index',\ |
_cairo_array_index_const,'_cairo_array_index_const',\ |
_cairo_array_init,'_cairo_array_init',\ |
_cairo_array_num_elements,'_cairo_array_num_elements',\ |
_cairo_array_size,'_cairo_array_size',\ |
_cairo_array_truncate,'_cairo_array_truncate',\ |
_cairo_atomic_int_cmpxchg_return_old_impl,'_cairo_atomic_int_cmpxchg_return_old_impl',\ |
_cairo_atomic_int_dec_and_test,'_cairo_atomic_int_dec_and_test',\ |
_cairo_atomic_int_inc,'_cairo_atomic_int_inc',\ |
_cairo_atomic_mutex,'_cairo_atomic_mutex',\ |
_cairo_atomic_ptr_cmpxchg_return_old_impl,'_cairo_atomic_ptr_cmpxchg_return_old_impl',\ |
_cairo_base64_stream_create,'_cairo_base64_stream_create',\ |
_cairo_base85_stream_create,'_cairo_base85_stream_create',\ |
_cairo_bentley_ottmann_tessellate_boxes,'_cairo_bentley_ottmann_tessellate_boxes',\ |
_cairo_bentley_ottmann_tessellate_polygon,'_cairo_bentley_ottmann_tessellate_polygon',\ |
_cairo_bentley_ottmann_tessellate_rectangular_traps,'_cairo_bentley_ottmann_tessellate_rectangular_traps',\ |
_cairo_bentley_ottmann_tessellate_rectilinear_polygon_to_boxes,'_cairo_bentley_ottmann_tessellate_rectilinear_polygon_to_boxes',\ |
_cairo_bentley_ottmann_tessellate_rectilinear_traps,'_cairo_bentley_ottmann_tessellate_rectilinear_traps',\ |
_cairo_bentley_ottmann_tessellate_traps,'_cairo_bentley_ottmann_tessellate_traps',\ |
_cairo_botor_scan_converter_init,'_cairo_botor_scan_converter_init',\ |
_cairo_box_add_curve_to,'_cairo_box_add_curve_to',\ |
_cairo_box_from_doubles,'_cairo_box_from_doubles',\ |
_cairo_box_from_rectangle,'_cairo_box_from_rectangle',\ |
_cairo_box_intersects_line_segment,'_cairo_box_intersects_line_segment',\ |
_cairo_box_round_to_rectangle,'_cairo_box_round_to_rectangle',\ |
_cairo_box_to_doubles,'_cairo_box_to_doubles',\ |
_cairo_boxes_add,'_cairo_boxes_add',\ |
_cairo_boxes_clear,'_cairo_boxes_clear',\ |
_cairo_boxes_extents,'_cairo_boxes_extents',\ |
_cairo_boxes_fini,'_cairo_boxes_fini',\ |
_cairo_boxes_for_each_box,'_cairo_boxes_for_each_box',\ |
_cairo_boxes_get_extents,'_cairo_boxes_get_extents',\ |
_cairo_boxes_init,'_cairo_boxes_init',\ |
_cairo_boxes_init_for_array,'_cairo_boxes_init_for_array',\ |
_cairo_boxes_init_from_rectangle,'_cairo_boxes_init_from_rectangle',\ |
_cairo_boxes_init_with_clip,'_cairo_boxes_init_with_clip',\ |
_cairo_boxes_intersect,'_cairo_boxes_intersect',\ |
_cairo_boxes_limit,'_cairo_boxes_limit',\ |
_cairo_boxes_to_array,'_cairo_boxes_to_array',\ |
_cairo_cache_fini,'_cairo_cache_fini',\ |
_cairo_cache_foreach,'_cairo_cache_foreach',\ |
_cairo_cache_freeze,'_cairo_cache_freeze',\ |
_cairo_cache_init,'_cairo_cache_init',\ |
_cairo_cache_insert,'_cairo_cache_insert',\ |
_cairo_cache_lookup,'_cairo_cache_lookup',\ |
_cairo_cache_remove,'_cairo_cache_remove',\ |
_cairo_cache_thaw,'_cairo_cache_thaw',\ |
_cairo_cff_fallback_fini,'_cairo_cff_fallback_fini',\ |
_cairo_cff_fallback_init,'_cairo_cff_fallback_init',\ |
_cairo_cff_scaled_font_is_cid_cff,'_cairo_cff_scaled_font_is_cid_cff',\ |
_cairo_cff_subset_fini,'_cairo_cff_subset_fini',\ |
_cairo_cff_subset_init,'_cairo_cff_subset_init',\ |
_cairo_clip_combine_with_surface,'_cairo_clip_combine_with_surface',\ |
_cairo_clip_contains_box,'_cairo_clip_contains_box',\ |
_cairo_clip_contains_extents,'_cairo_clip_contains_extents',\ |
_cairo_clip_contains_rectangle,'_cairo_clip_contains_rectangle',\ |
_cairo_clip_copy,'_cairo_clip_copy',\ |
_cairo_clip_copy_path,'_cairo_clip_copy_path',\ |
_cairo_clip_copy_rectangle_list,'_cairo_clip_copy_rectangle_list',\ |
_cairo_clip_copy_region,'_cairo_clip_copy_region',\ |
_cairo_clip_copy_with_translation,'_cairo_clip_copy_with_translation',\ |
_cairo_clip_create,'_cairo_clip_create',\ |
_cairo_clip_destroy,'_cairo_clip_destroy',\ |
_cairo_clip_equal,'_cairo_clip_equal',\ |
_cairo_clip_from_boxes,'_cairo_clip_from_boxes',\ |
_cairo_clip_get_extents,'_cairo_clip_get_extents',\ |
_cairo_clip_get_image,'_cairo_clip_get_image',\ |
_cairo_clip_get_polygon,'_cairo_clip_get_polygon',\ |
_cairo_clip_get_region,'_cairo_clip_get_region',\ |
_cairo_clip_get_surface,'_cairo_clip_get_surface',\ |
_cairo_clip_intersect_box,'_cairo_clip_intersect_box',\ |
_cairo_clip_intersect_boxes,'_cairo_clip_intersect_boxes',\ |
_cairo_clip_intersect_clip,'_cairo_clip_intersect_clip',\ |
_cairo_clip_intersect_path,'_cairo_clip_intersect_path',\ |
_cairo_clip_intersect_rectangle,'_cairo_clip_intersect_rectangle',\ |
_cairo_clip_intersect_rectilinear_path,'_cairo_clip_intersect_rectilinear_path',\ |
_cairo_clip_is_polygon,'_cairo_clip_is_polygon',\ |
_cairo_clip_is_region,'_cairo_clip_is_region',\ |
_cairo_clip_path_destroy,'_cairo_clip_path_destroy',\ |
_cairo_clip_path_reference,'_cairo_clip_path_reference',\ |
_cairo_clip_reduce_for_composite,'_cairo_clip_reduce_for_composite',\ |
_cairo_clip_reduce_to_rectangle,'_cairo_clip_reduce_to_rectangle',\ |
_cairo_clip_reset_static_data,'_cairo_clip_reset_static_data',\ |
_cairo_clip_tor_scan_converter_create,'_cairo_clip_tor_scan_converter_create',\ |
_cairo_clip_transform,'_cairo_clip_transform',\ |
_cairo_clip_translate,'_cairo_clip_translate',\ |
_cairo_color_double_to_short,'_cairo_color_double_to_short',\ |
_cairo_color_equal,'_cairo_color_equal',\ |
_cairo_color_get_content,'_cairo_color_get_content',\ |
_cairo_color_get_rgba,'_cairo_color_get_rgba',\ |
_cairo_color_get_rgba_premultiplied,'_cairo_color_get_rgba_premultiplied',\ |
_cairo_color_init_rgba,'_cairo_color_init_rgba',\ |
_cairo_color_multiply_alpha,'_cairo_color_multiply_alpha',\ |
_cairo_color_stop_equal,'_cairo_color_stop_equal',\ |
_cairo_composite_rectangles_add_to_damage,'_cairo_composite_rectangles_add_to_damage',\ |
_cairo_composite_rectangles_can_reduce_clip,'_cairo_composite_rectangles_can_reduce_clip',\ |
_cairo_composite_rectangles_fini,'_cairo_composite_rectangles_fini',\ |
_cairo_composite_rectangles_init_for_boxes,'_cairo_composite_rectangles_init_for_boxes',\ |
_cairo_composite_rectangles_init_for_fill,'_cairo_composite_rectangles_init_for_fill',\ |
_cairo_composite_rectangles_init_for_glyphs,'_cairo_composite_rectangles_init_for_glyphs',\ |
_cairo_composite_rectangles_init_for_mask,'_cairo_composite_rectangles_init_for_mask',\ |
_cairo_composite_rectangles_init_for_paint,'_cairo_composite_rectangles_init_for_paint',\ |
_cairo_composite_rectangles_init_for_polygon,'_cairo_composite_rectangles_init_for_polygon',\ |
_cairo_composite_rectangles_init_for_stroke,'_cairo_composite_rectangles_init_for_stroke',\ |
_cairo_composite_rectangles_intersect_mask_extents,'_cairo_composite_rectangles_intersect_mask_extents',\ |
_cairo_composite_rectangles_intersect_source_extents,'_cairo_composite_rectangles_intersect_source_extents',\ |
_cairo_compositor_fill,'_cairo_compositor_fill',\ |
_cairo_compositor_glyphs,'_cairo_compositor_glyphs',\ |
_cairo_compositor_mask,'_cairo_compositor_mask',\ |
_cairo_compositor_paint,'_cairo_compositor_paint',\ |
_cairo_compositor_stroke,'_cairo_compositor_stroke',\ |
_cairo_content_from_format,'_cairo_content_from_format',\ |
_cairo_content_from_pixman_format,'_cairo_content_from_pixman_format',\ |
_cairo_contour_add,'_cairo_contour_add',\ |
_cairo_contour_add_reversed,'_cairo_contour_add_reversed',\ |
_cairo_contour_fini,'_cairo_contour_fini',\ |
_cairo_contour_init,'_cairo_contour_init',\ |
_cairo_contour_reset,'_cairo_contour_reset',\ |
_cairo_contour_reverse,'_cairo_contour_reverse',\ |
_cairo_contour_simplify,'_cairo_contour_simplify',\ |
_cairo_create_in_error,'_cairo_create_in_error',\ |
_cairo_damage_add_box,'_cairo_damage_add_box',\ |
_cairo_damage_add_rectangle,'_cairo_damage_add_rectangle',\ |
_cairo_damage_add_region,'_cairo_damage_add_region',\ |
_cairo_damage_create,'_cairo_damage_create',\ |
_cairo_damage_create_in_error,'_cairo_damage_create_in_error',\ |
_cairo_damage_destroy,'_cairo_damage_destroy',\ |
_cairo_damage_reduce,'_cairo_damage_reduce',\ |
_cairo_debug_print_boxes,'_cairo_debug_print_boxes',\ |
_cairo_debug_print_clip,'_cairo_debug_print_clip',\ |
_cairo_debug_print_contour,'_cairo_debug_print_contour',\ |
_cairo_debug_print_path,'_cairo_debug_print_path',\ |
_cairo_debug_print_pattern,'_cairo_debug_print_pattern',\ |
_cairo_debug_print_polygon,'_cairo_debug_print_polygon',\ |
_cairo_debug_print_traps,'_cairo_debug_print_traps',\ |
_cairo_default_context_create,'_cairo_default_context_create',\ |
_cairo_default_context_fini,'_cairo_default_context_fini',\ |
_cairo_default_context_init,'_cairo_default_context_init',\ |
_cairo_default_context_reset_static_data,'_cairo_default_context_reset_static_data',\ |
_cairo_deflate_stream_create,'_cairo_deflate_stream_create',\ |
_cairo_device_create_in_error,'_cairo_device_create_in_error',\ |
_cairo_device_init,'_cairo_device_init',\ |
_cairo_device_set_error,'_cairo_device_set_error',\ |
_cairo_empty_rectangle,'_cairo_empty_rectangle',\ |
_cairo_error,'_cairo_error',\ |
_cairo_fallback_compositor,'_cairo_fallback_compositor',\ |
_cairo_fini,'_cairo_fini',\ |
_cairo_font_face_init,'_cairo_font_face_init',\ |
_cairo_font_face_is_user,'_cairo_font_face_is_user',\ |
_cairo_font_face_nil,'_cairo_font_face_nil',\ |
_cairo_font_face_set_error,'_cairo_font_face_set_error',\ |
_cairo_font_face_twin_create_fallback,'_cairo_font_face_twin_create_fallback',\ |
_cairo_font_face_twin_create_for_toy,'_cairo_font_face_twin_create_for_toy',\ |
_cairo_font_options_get_lcd_filter,'_cairo_font_options_get_lcd_filter',\ |
_cairo_font_options_get_round_glyph_positions,'_cairo_font_options_get_round_glyph_positions',\ |
_cairo_font_options_init_copy,'_cairo_font_options_init_copy',\ |
_cairo_font_options_init_default,'_cairo_font_options_init_default',\ |
_cairo_font_options_set_lcd_filter,'_cairo_font_options_set_lcd_filter',\ |
_cairo_font_options_set_round_glyph_positions,'_cairo_font_options_set_round_glyph_positions',\ |
_cairo_format_bits_per_pixel,'_cairo_format_bits_per_pixel',\ |
_cairo_format_from_content,'_cairo_format_from_content',\ |
_cairo_format_from_pixman_format,'_cairo_format_from_pixman_format',\ |
_cairo_format_to_pixman_format_code,'_cairo_format_to_pixman_format_code',\ |
_cairo_freelist_alloc,'_cairo_freelist_alloc',\ |
_cairo_freelist_calloc,'_cairo_freelist_calloc',\ |
_cairo_freelist_fini,'_cairo_freelist_fini',\ |
_cairo_freelist_free,'_cairo_freelist_free',\ |
_cairo_freelist_init,'_cairo_freelist_init',\ |
_cairo_freepool_alloc_array,'_cairo_freepool_alloc_array',\ |
_cairo_freepool_alloc_from_new_pool,'_cairo_freepool_alloc_from_new_pool',\ |
_cairo_freepool_fini,'_cairo_freepool_fini',\ |
_cairo_freepool_init,'_cairo_freepool_init',\ |
_cairo_ft_font_face_backend,'_cairo_ft_font_face_backend',\ |
_cairo_ft_font_reset_static_data,'_cairo_ft_font_reset_static_data',\ |
_cairo_ft_scaled_font_get_load_flags,'_cairo_ft_scaled_font_get_load_flags',\ |
_cairo_ft_unscaled_font_map_mutex,'_cairo_ft_unscaled_font_map_mutex',\ |
_cairo_glyph_cache_mutex,'_cairo_glyph_cache_mutex',\ |
_cairo_gradient_pattern_box_to_parameter,'_cairo_gradient_pattern_box_to_parameter',\ |
_cairo_gradient_pattern_fit_to_range,'_cairo_gradient_pattern_fit_to_range',\ |
_cairo_gradient_pattern_interpolate,'_cairo_gradient_pattern_interpolate',\ |
_cairo_gradient_pattern_is_solid,'_cairo_gradient_pattern_is_solid',\ |
_cairo_gstate_backend_to_user_rectangle,'_cairo_gstate_backend_to_user_rectangle',\ |
_cairo_gstate_clip,'_cairo_gstate_clip',\ |
_cairo_gstate_clip_extents,'_cairo_gstate_clip_extents',\ |
_cairo_gstate_copy_clip_rectangle_list,'_cairo_gstate_copy_clip_rectangle_list',\ |
_cairo_gstate_copy_page,'_cairo_gstate_copy_page',\ |
_cairo_gstate_device_to_user,'_cairo_gstate_device_to_user',\ |
_cairo_gstate_device_to_user_distance,'_cairo_gstate_device_to_user_distance',\ |
_cairo_gstate_fill,'_cairo_gstate_fill',\ |
_cairo_gstate_fill_extents,'_cairo_gstate_fill_extents',\ |
_cairo_gstate_fini,'_cairo_gstate_fini',\ |
_cairo_gstate_get_antialias,'_cairo_gstate_get_antialias',\ |
_cairo_gstate_get_clip,'_cairo_gstate_get_clip',\ |
_cairo_gstate_get_dash,'_cairo_gstate_get_dash',\ |
_cairo_gstate_get_fill_rule,'_cairo_gstate_get_fill_rule',\ |
_cairo_gstate_get_font_extents,'_cairo_gstate_get_font_extents',\ |
_cairo_gstate_get_font_face,'_cairo_gstate_get_font_face',\ |
_cairo_gstate_get_font_matrix,'_cairo_gstate_get_font_matrix',\ |
_cairo_gstate_get_font_options,'_cairo_gstate_get_font_options',\ |
_cairo_gstate_get_line_cap,'_cairo_gstate_get_line_cap',\ |
_cairo_gstate_get_line_join,'_cairo_gstate_get_line_join',\ |
_cairo_gstate_get_line_width,'_cairo_gstate_get_line_width',\ |
_cairo_gstate_get_matrix,'_cairo_gstate_get_matrix',\ |
_cairo_gstate_get_miter_limit,'_cairo_gstate_get_miter_limit',\ |
_cairo_gstate_get_opacity,'_cairo_gstate_get_opacity',\ |
_cairo_gstate_get_operator,'_cairo_gstate_get_operator',\ |
_cairo_gstate_get_original_target,'_cairo_gstate_get_original_target',\ |
_cairo_gstate_get_scaled_font,'_cairo_gstate_get_scaled_font',\ |
_cairo_gstate_get_source,'_cairo_gstate_get_source',\ |
_cairo_gstate_get_target,'_cairo_gstate_get_target',\ |
_cairo_gstate_get_tolerance,'_cairo_gstate_get_tolerance',\ |
_cairo_gstate_glyph_extents,'_cairo_gstate_glyph_extents',\ |
_cairo_gstate_glyph_path,'_cairo_gstate_glyph_path',\ |
_cairo_gstate_identity_matrix,'_cairo_gstate_identity_matrix',\ |
_cairo_gstate_in_clip,'_cairo_gstate_in_clip',\ |
_cairo_gstate_in_fill,'_cairo_gstate_in_fill',\ |
_cairo_gstate_in_stroke,'_cairo_gstate_in_stroke',\ |
_cairo_gstate_init,'_cairo_gstate_init',\ |
_cairo_gstate_is_group,'_cairo_gstate_is_group',\ |
_cairo_gstate_mask,'_cairo_gstate_mask',\ |
_cairo_gstate_paint,'_cairo_gstate_paint',\ |
_cairo_gstate_path_extents,'_cairo_gstate_path_extents',\ |
_cairo_gstate_redirect_target,'_cairo_gstate_redirect_target',\ |
_cairo_gstate_reset_clip,'_cairo_gstate_reset_clip',\ |
_cairo_gstate_restore,'_cairo_gstate_restore',\ |
_cairo_gstate_rotate,'_cairo_gstate_rotate',\ |
_cairo_gstate_save,'_cairo_gstate_save',\ |
_cairo_gstate_scale,'_cairo_gstate_scale',\ |
_cairo_gstate_set_antialias,'_cairo_gstate_set_antialias',\ |
_cairo_gstate_set_dash,'_cairo_gstate_set_dash',\ |
_cairo_gstate_set_fill_rule,'_cairo_gstate_set_fill_rule',\ |
_cairo_gstate_set_font_face,'_cairo_gstate_set_font_face',\ |
_cairo_gstate_set_font_matrix,'_cairo_gstate_set_font_matrix',\ |
_cairo_gstate_set_font_options,'_cairo_gstate_set_font_options',\ |
_cairo_gstate_set_font_size,'_cairo_gstate_set_font_size',\ |
_cairo_gstate_set_line_cap,'_cairo_gstate_set_line_cap',\ |
_cairo_gstate_set_line_join,'_cairo_gstate_set_line_join',\ |
_cairo_gstate_set_line_width,'_cairo_gstate_set_line_width',\ |
_cairo_gstate_set_matrix,'_cairo_gstate_set_matrix',\ |
_cairo_gstate_set_miter_limit,'_cairo_gstate_set_miter_limit',\ |
_cairo_gstate_set_opacity,'_cairo_gstate_set_opacity',\ |
_cairo_gstate_set_operator,'_cairo_gstate_set_operator',\ |
_cairo_gstate_set_source,'_cairo_gstate_set_source',\ |
_cairo_gstate_set_tolerance,'_cairo_gstate_set_tolerance',\ |
_cairo_gstate_show_page,'_cairo_gstate_show_page',\ |
_cairo_gstate_show_text_glyphs,'_cairo_gstate_show_text_glyphs',\ |
_cairo_gstate_stroke,'_cairo_gstate_stroke',\ |
_cairo_gstate_stroke_extents,'_cairo_gstate_stroke_extents',\ |
_cairo_gstate_transform,'_cairo_gstate_transform',\ |
_cairo_gstate_translate,'_cairo_gstate_translate',\ |
_cairo_gstate_user_to_device,'_cairo_gstate_user_to_device',\ |
_cairo_gstate_user_to_device_distance,'_cairo_gstate_user_to_device_distance',\ |
_cairo_half_from_float,'_cairo_half_from_float',\ |
_cairo_hash_bytes,'_cairo_hash_bytes',\ |
_cairo_hash_string,'_cairo_hash_string',\ |
_cairo_hash_table_create,'_cairo_hash_table_create',\ |
_cairo_hash_table_destroy,'_cairo_hash_table_destroy',\ |
_cairo_hash_table_foreach,'_cairo_hash_table_foreach',\ |
_cairo_hash_table_insert,'_cairo_hash_table_insert',\ |
_cairo_hash_table_lookup,'_cairo_hash_table_lookup',\ |
_cairo_hash_table_random_entry,'_cairo_hash_table_random_entry',\ |
_cairo_hash_table_remove,'_cairo_hash_table_remove',\ |
_cairo_hull_compute,'_cairo_hull_compute',\ |
_cairo_image_analyze_color,'_cairo_image_analyze_color',\ |
_cairo_image_analyze_transparency,'_cairo_image_analyze_transparency',\ |
_cairo_image_info_get_jpeg_info,'_cairo_image_info_get_jpeg_info',\ |
_cairo_image_info_get_jpx_info,'_cairo_image_info_get_jpx_info',\ |
_cairo_image_info_get_png_info,'_cairo_image_info_get_png_info',\ |
_cairo_image_mask_compositor_get,'_cairo_image_mask_compositor_get',\ |
_cairo_image_reset_static_data,'_cairo_image_reset_static_data',\ |
_cairo_image_scaled_glyph_fini,'_cairo_image_scaled_glyph_fini',\ |
_cairo_image_solid_cache_mutex,'_cairo_image_solid_cache_mutex',\ |
_cairo_image_source_backend,'_cairo_image_source_backend',\ |
_cairo_image_source_create_for_pattern,'_cairo_image_source_create_for_pattern',\ |
_cairo_image_spans_compositor_get,'_cairo_image_spans_compositor_get',\ |
_cairo_image_surface_acquire_source_image,'_cairo_image_surface_acquire_source_image',\ |
_cairo_image_surface_assume_ownership_of_data,'_cairo_image_surface_assume_ownership_of_data',\ |
_cairo_image_surface_backend,'_cairo_image_surface_backend',\ |
_cairo_image_surface_clone_subimage,'_cairo_image_surface_clone_subimage',\ |
_cairo_image_surface_coerce,'_cairo_image_surface_coerce',\ |
_cairo_image_surface_coerce_to_format,'_cairo_image_surface_coerce_to_format',\ |
_cairo_image_surface_create_for_pixman_image,'_cairo_image_surface_create_for_pixman_image',\ |
_cairo_image_surface_create_from_image,'_cairo_image_surface_create_from_image',\ |
_cairo_image_surface_create_similar,'_cairo_image_surface_create_similar',\ |
_cairo_image_surface_create_with_content,'_cairo_image_surface_create_with_content',\ |
_cairo_image_surface_create_with_pixman_format,'_cairo_image_surface_create_with_pixman_format',\ |
_cairo_image_surface_fill,'_cairo_image_surface_fill',\ |
_cairo_image_surface_finish,'_cairo_image_surface_finish',\ |
_cairo_image_surface_get_extents,'_cairo_image_surface_get_extents',\ |
_cairo_image_surface_get_font_options,'_cairo_image_surface_get_font_options',\ |
_cairo_image_surface_glyphs,'_cairo_image_surface_glyphs',\ |
_cairo_image_surface_init,'_cairo_image_surface_init',\ |
_cairo_image_surface_map_to_image,'_cairo_image_surface_map_to_image',\ |
_cairo_image_surface_mask,'_cairo_image_surface_mask',\ |
_cairo_image_surface_paint,'_cairo_image_surface_paint',\ |
_cairo_image_surface_release_source_image,'_cairo_image_surface_release_source_image',\ |
_cairo_image_surface_snapshot,'_cairo_image_surface_snapshot',\ |
_cairo_image_surface_source,'_cairo_image_surface_source',\ |
_cairo_image_surface_stroke,'_cairo_image_surface_stroke',\ |
_cairo_image_surface_unmap_image,'_cairo_image_surface_unmap_image',\ |
_cairo_image_traps_compositor_get,'_cairo_image_traps_compositor_get',\ |
_cairo_init,'_cairo_init',\ |
_cairo_int128_cmp,'_cairo_int128_cmp',\ |
_cairo_int128_divrem,'_cairo_int128_divrem',\ |
_cairo_int128_lt,'_cairo_int128_lt',\ |
_cairo_int32_to_int128,'_cairo_int32_to_int128',\ |
_cairo_int64_to_int128,'_cairo_int64_to_int128',\ |
_cairo_int64x64_128_mul,'_cairo_int64x64_128_mul',\ |
_cairo_int_96by64_32x64_divrem,'_cairo_int_96by64_32x64_divrem',\ |
_cairo_int_surface_create_in_error,'_cairo_int_surface_create_in_error',\ |
_cairo_intern_string,'_cairo_intern_string',\ |
_cairo_intern_string_mutex,'_cairo_intern_string_mutex',\ |
_cairo_intern_string_reset_static_data,'_cairo_intern_string_reset_static_data',\ |
_cairo_linear_pattern_equal,'_cairo_linear_pattern_equal',\ |
_cairo_linear_pattern_hash,'_cairo_linear_pattern_hash',\ |
_cairo_lround,'_cairo_lround',\ |
_cairo_lzw_compress,'_cairo_lzw_compress',\ |
_cairo_mask_compositor_init,'_cairo_mask_compositor_init',\ |
_cairo_matrix_compute_basis_scale_factors,'_cairo_matrix_compute_basis_scale_factors',\ |
_cairo_matrix_compute_determinant,'_cairo_matrix_compute_determinant',\ |
_cairo_matrix_get_affine,'_cairo_matrix_get_affine',\ |
_cairo_matrix_has_unity_scale,'_cairo_matrix_has_unity_scale',\ |
_cairo_matrix_is_integer_translation,'_cairo_matrix_is_integer_translation',\ |
_cairo_matrix_is_invertible,'_cairo_matrix_is_invertible',\ |
_cairo_matrix_is_pixel_exact,'_cairo_matrix_is_pixel_exact',\ |
_cairo_matrix_is_pixman_translation,'_cairo_matrix_is_pixman_translation',\ |
_cairo_matrix_is_scale_0,'_cairo_matrix_is_scale_0',\ |
_cairo_matrix_multiply,'_cairo_matrix_multiply',\ |
_cairo_matrix_to_pixman_matrix_offset,'_cairo_matrix_to_pixman_matrix_offset',\ |
_cairo_matrix_transform_bounding_box,'_cairo_matrix_transform_bounding_box',\ |
_cairo_matrix_transform_bounding_box_fixed,'_cairo_matrix_transform_bounding_box_fixed',\ |
_cairo_matrix_transformed_circle_major_axis,'_cairo_matrix_transformed_circle_major_axis',\ |
_cairo_memory_stream_copy,'_cairo_memory_stream_copy',\ |
_cairo_memory_stream_create,'_cairo_memory_stream_create',\ |
_cairo_memory_stream_destroy,'_cairo_memory_stream_destroy',\ |
_cairo_memory_stream_length,'_cairo_memory_stream_length',\ |
_cairo_mempool_alloc,'_cairo_mempool_alloc',\ |
_cairo_mempool_fini,'_cairo_mempool_fini',\ |
_cairo_mempool_free,'_cairo_mempool_free',\ |
_cairo_mempool_init,'_cairo_mempool_init',\ |
_cairo_mesh_pattern_coord_box,'_cairo_mesh_pattern_coord_box',\ |
_cairo_mesh_pattern_rasterize,'_cairo_mesh_pattern_rasterize',\ |
_cairo_mono_scan_converter_add_polygon,'_cairo_mono_scan_converter_add_polygon',\ |
_cairo_mono_scan_converter_create,'_cairo_mono_scan_converter_create',\ |
_cairo_null_stream_create,'_cairo_null_stream_create',\ |
_cairo_null_surface_create,'_cairo_null_surface_create',\ |
_cairo_observers_notify,'_cairo_observers_notify',\ |
_cairo_operator_bounded_by_either,'_cairo_operator_bounded_by_either',\ |
_cairo_operator_bounded_by_mask,'_cairo_operator_bounded_by_mask',\ |
_cairo_operator_bounded_by_source,'_cairo_operator_bounded_by_source',\ |
_cairo_output_stream_close,'_cairo_output_stream_close',\ |
_cairo_output_stream_create,'_cairo_output_stream_create',\ |
_cairo_output_stream_create_for_file,'_cairo_output_stream_create_for_file',\ |
_cairo_output_stream_create_for_filename,'_cairo_output_stream_create_for_filename',\ |
_cairo_output_stream_create_in_error,'_cairo_output_stream_create_in_error',\ |
_cairo_output_stream_destroy,'_cairo_output_stream_destroy',\ |
_cairo_output_stream_fini,'_cairo_output_stream_fini',\ |
_cairo_output_stream_flush,'_cairo_output_stream_flush',\ |
_cairo_output_stream_get_position,'_cairo_output_stream_get_position',\ |
_cairo_output_stream_get_status,'_cairo_output_stream_get_status',\ |
_cairo_output_stream_init,'_cairo_output_stream_init',\ |
_cairo_output_stream_nil,'_cairo_output_stream_nil',\ |
_cairo_output_stream_printf,'_cairo_output_stream_printf',\ |
_cairo_output_stream_vprintf,'_cairo_output_stream_vprintf',\ |
_cairo_output_stream_write,'_cairo_output_stream_write',\ |
_cairo_output_stream_write_hex_string,'_cairo_output_stream_write_hex_string',\ |
_cairo_paginated_surface_create,'_cairo_paginated_surface_create',\ |
_cairo_paginated_surface_get_recording,'_cairo_paginated_surface_get_recording',\ |
_cairo_paginated_surface_get_target,'_cairo_paginated_surface_get_target',\ |
_cairo_paginated_surface_set_size,'_cairo_paginated_surface_set_size',\ |
_cairo_path_append_to_context,'_cairo_path_append_to_context',\ |
_cairo_path_bounder_extents,'_cairo_path_bounder_extents',\ |
_cairo_path_create,'_cairo_path_create',\ |
_cairo_path_create_flat,'_cairo_path_create_flat',\ |
_cairo_path_create_in_error,'_cairo_path_create_in_error',\ |
_cairo_path_fixed_append,'_cairo_path_fixed_append',\ |
_cairo_path_fixed_approximate_clip_extents,'_cairo_path_fixed_approximate_clip_extents',\ |
_cairo_path_fixed_approximate_fill_extents,'_cairo_path_fixed_approximate_fill_extents',\ |
_cairo_path_fixed_approximate_stroke_extents,'_cairo_path_fixed_approximate_stroke_extents',\ |
_cairo_path_fixed_close_path,'_cairo_path_fixed_close_path',\ |
_cairo_path_fixed_create,'_cairo_path_fixed_create',\ |
_cairo_path_fixed_curve_to,'_cairo_path_fixed_curve_to',\ |
_cairo_path_fixed_destroy,'_cairo_path_fixed_destroy',\ |
_cairo_path_fixed_equal,'_cairo_path_fixed_equal',\ |
_cairo_path_fixed_extents,'_cairo_path_fixed_extents',\ |
_cairo_path_fixed_fill_extents,'_cairo_path_fixed_fill_extents',\ |
_cairo_path_fixed_fill_rectilinear_to_boxes,'_cairo_path_fixed_fill_rectilinear_to_boxes',\ |
_cairo_path_fixed_fill_rectilinear_to_polygon,'_cairo_path_fixed_fill_rectilinear_to_polygon',\ |
_cairo_path_fixed_fill_to_polygon,'_cairo_path_fixed_fill_to_polygon',\ |
_cairo_path_fixed_fill_to_traps,'_cairo_path_fixed_fill_to_traps',\ |
_cairo_path_fixed_fini,'_cairo_path_fixed_fini',\ |
_cairo_path_fixed_get_current_point,'_cairo_path_fixed_get_current_point',\ |
_cairo_path_fixed_hash,'_cairo_path_fixed_hash',\ |
_cairo_path_fixed_in_fill,'_cairo_path_fixed_in_fill',\ |
_cairo_path_fixed_init,'_cairo_path_fixed_init',\ |
_cairo_path_fixed_init_copy,'_cairo_path_fixed_init_copy',\ |
_cairo_path_fixed_interpret,'_cairo_path_fixed_interpret',\ |
_cairo_path_fixed_interpret_flat,'_cairo_path_fixed_interpret_flat',\ |
_cairo_path_fixed_is_box,'_cairo_path_fixed_is_box',\ |
_cairo_path_fixed_is_rectangle,'_cairo_path_fixed_is_rectangle',\ |
_cairo_path_fixed_is_simple_quad,'_cairo_path_fixed_is_simple_quad',\ |
_cairo_path_fixed_is_stroke_box,'_cairo_path_fixed_is_stroke_box',\ |
_cairo_path_fixed_iter_at_end,'_cairo_path_fixed_iter_at_end',\ |
_cairo_path_fixed_iter_init,'_cairo_path_fixed_iter_init',\ |
_cairo_path_fixed_iter_is_fill_box,'_cairo_path_fixed_iter_is_fill_box',\ |
_cairo_path_fixed_line_to,'_cairo_path_fixed_line_to',\ |
_cairo_path_fixed_move_to,'_cairo_path_fixed_move_to',\ |
_cairo_path_fixed_new_sub_path,'_cairo_path_fixed_new_sub_path',\ |
_cairo_path_fixed_rel_curve_to,'_cairo_path_fixed_rel_curve_to',\ |
_cairo_path_fixed_rel_line_to,'_cairo_path_fixed_rel_line_to',\ |
_cairo_path_fixed_rel_move_to,'_cairo_path_fixed_rel_move_to',\ |
_cairo_path_fixed_size,'_cairo_path_fixed_size',\ |
_cairo_path_fixed_stroke_dashed_to_polygon,'_cairo_path_fixed_stroke_dashed_to_polygon',\ |
_cairo_path_fixed_stroke_extents,'_cairo_path_fixed_stroke_extents',\ |
_cairo_path_fixed_stroke_polygon_to_traps,'_cairo_path_fixed_stroke_polygon_to_traps',\ |
_cairo_path_fixed_stroke_rectilinear_to_boxes,'_cairo_path_fixed_stroke_rectilinear_to_boxes',\ |
_cairo_path_fixed_stroke_to_polygon,'_cairo_path_fixed_stroke_to_polygon',\ |
_cairo_path_fixed_stroke_to_shaper,'_cairo_path_fixed_stroke_to_shaper',\ |
_cairo_path_fixed_stroke_to_traps,'_cairo_path_fixed_stroke_to_traps',\ |
_cairo_path_fixed_stroke_to_tristrip,'_cairo_path_fixed_stroke_to_tristrip',\ |
_cairo_path_fixed_transform,'_cairo_path_fixed_transform',\ |
_cairo_path_fixed_translate,'_cairo_path_fixed_translate',\ |
_cairo_pattern_alpha_range,'_cairo_pattern_alpha_range',\ |
_cairo_pattern_analyze_filter,'_cairo_pattern_analyze_filter',\ |
_cairo_pattern_black,'_cairo_pattern_black',\ |
_cairo_pattern_clear,'_cairo_pattern_clear',\ |
_cairo_pattern_create_copy,'_cairo_pattern_create_copy',\ |
_cairo_pattern_create_in_error,'_cairo_pattern_create_in_error',\ |
_cairo_pattern_create_solid,'_cairo_pattern_create_solid',\ |
_cairo_pattern_equal,'_cairo_pattern_equal',\ |
_cairo_pattern_fini,'_cairo_pattern_fini',\ |
_cairo_pattern_get_extents,'_cairo_pattern_get_extents',\ |
_cairo_pattern_get_ink_extents,'_cairo_pattern_get_ink_extents',\ |
_cairo_pattern_hash,'_cairo_pattern_hash',\ |
_cairo_pattern_init,'_cairo_pattern_init',\ |
_cairo_pattern_init_copy,'_cairo_pattern_init_copy',\ |
_cairo_pattern_init_for_surface,'_cairo_pattern_init_for_surface',\ |
_cairo_pattern_init_snapshot,'_cairo_pattern_init_snapshot',\ |
_cairo_pattern_init_solid,'_cairo_pattern_init_solid',\ |
_cairo_pattern_init_static_copy,'_cairo_pattern_init_static_copy',\ |
_cairo_pattern_is_clear,'_cairo_pattern_is_clear',\ |
_cairo_pattern_is_opaque,'_cairo_pattern_is_opaque',\ |
_cairo_pattern_is_opaque_solid,'_cairo_pattern_is_opaque_solid',\ |
_cairo_pattern_reset_static_data,'_cairo_pattern_reset_static_data',\ |
_cairo_pattern_sampled_area,'_cairo_pattern_sampled_area',\ |
_cairo_pattern_solid_surface_cache_lock,'_cairo_pattern_solid_surface_cache_lock',\ |
_cairo_pattern_transform,'_cairo_pattern_transform',\ |
_cairo_pattern_white,'_cairo_pattern_white',\ |
_cairo_pdf_operators_clip,'_cairo_pdf_operators_clip',\ |
_cairo_pdf_operators_emit_stroke_style,'_cairo_pdf_operators_emit_stroke_style',\ |
_cairo_pdf_operators_enable_actual_text,'_cairo_pdf_operators_enable_actual_text',\ |
_cairo_pdf_operators_fill,'_cairo_pdf_operators_fill',\ |
_cairo_pdf_operators_fill_stroke,'_cairo_pdf_operators_fill_stroke',\ |
_cairo_pdf_operators_fini,'_cairo_pdf_operators_fini',\ |
_cairo_pdf_operators_flush,'_cairo_pdf_operators_flush',\ |
_cairo_pdf_operators_init,'_cairo_pdf_operators_init',\ |
_cairo_pdf_operators_reset,'_cairo_pdf_operators_reset',\ |
_cairo_pdf_operators_set_cairo_to_pdf_matrix,'_cairo_pdf_operators_set_cairo_to_pdf_matrix',\ |
_cairo_pdf_operators_set_font_subsets_callback,'_cairo_pdf_operators_set_font_subsets_callback',\ |
_cairo_pdf_operators_set_stream,'_cairo_pdf_operators_set_stream',\ |
_cairo_pdf_operators_show_text_glyphs,'_cairo_pdf_operators_show_text_glyphs',\ |
_cairo_pdf_operators_stroke,'_cairo_pdf_operators_stroke',\ |
_cairo_pdf_shading_fini,'_cairo_pdf_shading_fini',\ |
_cairo_pdf_shading_init_alpha,'_cairo_pdf_shading_init_alpha',\ |
_cairo_pdf_shading_init_color,'_cairo_pdf_shading_init_color',\ |
_cairo_pen_add_points,'_cairo_pen_add_points',\ |
_cairo_pen_find_active_ccw_vertex_index,'_cairo_pen_find_active_ccw_vertex_index',\ |
_cairo_pen_find_active_ccw_vertices,'_cairo_pen_find_active_ccw_vertices',\ |
_cairo_pen_find_active_cw_vertex_index,'_cairo_pen_find_active_cw_vertex_index',\ |
_cairo_pen_find_active_cw_vertices,'_cairo_pen_find_active_cw_vertices',\ |
_cairo_pen_fini,'_cairo_pen_fini',\ |
_cairo_pen_init,'_cairo_pen_init',\ |
_cairo_pen_init_copy,'_cairo_pen_init_copy',\ |
_cairo_pen_vertices_needed,'_cairo_pen_vertices_needed',\ |
_cairo_polygon_add_contour,'_cairo_polygon_add_contour',\ |
_cairo_polygon_add_external_edge,'_cairo_polygon_add_external_edge',\ |
_cairo_polygon_add_line,'_cairo_polygon_add_line',\ |
_cairo_polygon_fini,'_cairo_polygon_fini',\ |
_cairo_polygon_init,'_cairo_polygon_init',\ |
_cairo_polygon_init_box_array,'_cairo_polygon_init_box_array',\ |
_cairo_polygon_init_boxes,'_cairo_polygon_init_boxes',\ |
_cairo_polygon_init_with_clip,'_cairo_polygon_init_with_clip',\ |
_cairo_polygon_intersect,'_cairo_polygon_intersect',\ |
_cairo_polygon_intersect_with_boxes,'_cairo_polygon_intersect_with_boxes',\ |
_cairo_polygon_limit,'_cairo_polygon_limit',\ |
_cairo_polygon_limit_to_clip,'_cairo_polygon_limit_to_clip',\ |
_cairo_polygon_reduce,'_cairo_polygon_reduce',\ |
_cairo_polygon_translate,'_cairo_polygon_translate',\ |
_cairo_ps_standard_encoding_to_glyphname,'_cairo_ps_standard_encoding_to_glyphname',\ |
_cairo_radial_pattern_equal,'_cairo_radial_pattern_equal',\ |
_cairo_radial_pattern_focus_is_inside,'_cairo_radial_pattern_focus_is_inside',\ |
_cairo_radial_pattern_hash,'_cairo_radial_pattern_hash',\ |
_cairo_raster_source_pattern_acquire,'_cairo_raster_source_pattern_acquire',\ |
_cairo_raster_source_pattern_finish,'_cairo_raster_source_pattern_finish',\ |
_cairo_raster_source_pattern_init_copy,'_cairo_raster_source_pattern_init_copy',\ |
_cairo_raster_source_pattern_release,'_cairo_raster_source_pattern_release',\ |
_cairo_raster_source_pattern_snapshot,'_cairo_raster_source_pattern_snapshot',\ |
_cairo_rasterise_polygon_to_boxes,'_cairo_rasterise_polygon_to_boxes',\ |
_cairo_rasterise_polygon_to_traps,'_cairo_rasterise_polygon_to_traps',\ |
_cairo_recording_surface_get_bbox,'_cairo_recording_surface_get_bbox',\ |
_cairo_recording_surface_get_ink_bbox,'_cairo_recording_surface_get_ink_bbox',\ |
_cairo_recording_surface_get_path,'_cairo_recording_surface_get_path',\ |
_cairo_recording_surface_replay,'_cairo_recording_surface_replay',\ |
_cairo_recording_surface_replay_and_create_regions,'_cairo_recording_surface_replay_and_create_regions',\ |
_cairo_recording_surface_replay_one,'_cairo_recording_surface_replay_one',\ |
_cairo_recording_surface_replay_region,'_cairo_recording_surface_replay_region',\ |
_cairo_recording_surface_replay_with_clip,'_cairo_recording_surface_replay_with_clip',\ |
_cairo_rectangle_int_from_double,'_cairo_rectangle_int_from_double',\ |
_cairo_rectangle_intersect,'_cairo_rectangle_intersect',\ |
_cairo_rectangle_list_create_in_error,'_cairo_rectangle_list_create_in_error',\ |
_cairo_rectangle_union,'_cairo_rectangle_union',\ |
_cairo_rectangles_nil,'_cairo_rectangles_nil',\ |
_cairo_rectangular_scan_converter_add_box,'_cairo_rectangular_scan_converter_add_box',\ |
_cairo_rectangular_scan_converter_init,'_cairo_rectangular_scan_converter_init',\ |
_cairo_region_create_from_boxes,'_cairo_region_create_from_boxes',\ |
_cairo_region_create_in_error,'_cairo_region_create_in_error',\ |
_cairo_region_fini,'_cairo_region_fini',\ |
_cairo_region_get_boxes,'_cairo_region_get_boxes',\ |
_cairo_region_init,'_cairo_region_init',\ |
_cairo_region_init_rectangle,'_cairo_region_init_rectangle',\ |
_cairo_rtree_evict_random,'_cairo_rtree_evict_random',\ |
_cairo_rtree_fini,'_cairo_rtree_fini',\ |
_cairo_rtree_foreach,'_cairo_rtree_foreach',\ |
_cairo_rtree_init,'_cairo_rtree_init',\ |
_cairo_rtree_insert,'_cairo_rtree_insert',\ |
_cairo_rtree_node_collapse,'_cairo_rtree_node_collapse',\ |
_cairo_rtree_node_create,'_cairo_rtree_node_create',\ |
_cairo_rtree_node_destroy,'_cairo_rtree_node_destroy',\ |
_cairo_rtree_node_insert,'_cairo_rtree_node_insert',\ |
_cairo_rtree_node_remove,'_cairo_rtree_node_remove',\ |
_cairo_rtree_reset,'_cairo_rtree_reset',\ |
_cairo_rtree_unpin,'_cairo_rtree_unpin',\ |
_cairo_scaled_font_attach_private,'_cairo_scaled_font_attach_private',\ |
_cairo_scaled_font_create_in_error,'_cairo_scaled_font_create_in_error',\ |
_cairo_scaled_font_error_mutex,'_cairo_scaled_font_error_mutex',\ |
_cairo_scaled_font_find_private,'_cairo_scaled_font_find_private',\ |
_cairo_scaled_font_fini,'_cairo_scaled_font_fini',\ |
_cairo_scaled_font_freeze_cache,'_cairo_scaled_font_freeze_cache',\ |
_cairo_scaled_font_get_max_scale,'_cairo_scaled_font_get_max_scale',\ |
_cairo_scaled_font_glyph_approximate_extents,'_cairo_scaled_font_glyph_approximate_extents',\ |
_cairo_scaled_font_glyph_device_extents,'_cairo_scaled_font_glyph_device_extents',\ |
_cairo_scaled_font_glyph_path,'_cairo_scaled_font_glyph_path',\ |
_cairo_scaled_font_init,'_cairo_scaled_font_init',\ |
_cairo_scaled_font_is_ft,'_cairo_scaled_font_is_ft',\ |
_cairo_scaled_font_map_destroy,'_cairo_scaled_font_map_destroy',\ |
_cairo_scaled_font_map_mutex,'_cairo_scaled_font_map_mutex',\ |
_cairo_scaled_font_register_placeholder_and_unlock_font_map,'_cairo_scaled_font_register_placeholder_and_unlock_font_map',\ |
_cairo_scaled_font_reset_cache,'_cairo_scaled_font_reset_cache',\ |
_cairo_scaled_font_reset_static_data,'_cairo_scaled_font_reset_static_data',\ |
_cairo_scaled_font_set_error,'_cairo_scaled_font_set_error',\ |
_cairo_scaled_font_set_metrics,'_cairo_scaled_font_set_metrics',\ |
_cairo_scaled_font_subset_create_glyph_names,'_cairo_scaled_font_subset_create_glyph_names',\ |
_cairo_scaled_font_subsets_create_composite,'_cairo_scaled_font_subsets_create_composite',\ |
_cairo_scaled_font_subsets_create_scaled,'_cairo_scaled_font_subsets_create_scaled',\ |
_cairo_scaled_font_subsets_create_simple,'_cairo_scaled_font_subsets_create_simple',\ |
_cairo_scaled_font_subsets_destroy,'_cairo_scaled_font_subsets_destroy',\ |
_cairo_scaled_font_subsets_enable_latin_subset,'_cairo_scaled_font_subsets_enable_latin_subset',\ |
_cairo_scaled_font_subsets_foreach_scaled,'_cairo_scaled_font_subsets_foreach_scaled',\ |
_cairo_scaled_font_subsets_foreach_unscaled,'_cairo_scaled_font_subsets_foreach_unscaled',\ |
_cairo_scaled_font_subsets_foreach_user,'_cairo_scaled_font_subsets_foreach_user',\ |
_cairo_scaled_font_subsets_map_glyph,'_cairo_scaled_font_subsets_map_glyph',\ |
_cairo_scaled_font_thaw_cache,'_cairo_scaled_font_thaw_cache',\ |
_cairo_scaled_font_unregister_placeholder_and_lock_font_map,'_cairo_scaled_font_unregister_placeholder_and_lock_font_map',\ |
_cairo_scaled_glyph_attach_private,'_cairo_scaled_glyph_attach_private',\ |
_cairo_scaled_glyph_find_private,'_cairo_scaled_glyph_find_private',\ |
_cairo_scaled_glyph_lookup,'_cairo_scaled_glyph_lookup',\ |
_cairo_scaled_glyph_page_cache_mutex,'_cairo_scaled_glyph_page_cache_mutex',\ |
_cairo_scaled_glyph_set_metrics,'_cairo_scaled_glyph_set_metrics',\ |
_cairo_scaled_glyph_set_path,'_cairo_scaled_glyph_set_path',\ |
_cairo_scaled_glyph_set_recording_surface,'_cairo_scaled_glyph_set_recording_surface',\ |
_cairo_scaled_glyph_set_surface,'_cairo_scaled_glyph_set_surface',\ |
_cairo_scan_converter_create_in_error,'_cairo_scan_converter_create_in_error',\ |
_cairo_scan_converter_set_error,'_cairo_scan_converter_set_error',\ |
_cairo_scan_converter_status,'_cairo_scan_converter_status',\ |
_cairo_script_context_attach_snapshots,'_cairo_script_context_attach_snapshots',\ |
_cairo_script_context_create_internal,'_cairo_script_context_create_internal',\ |
_cairo_shape_mask_compositor_init,'_cairo_shape_mask_compositor_init',\ |
_cairo_slope_compare,'_cairo_slope_compare',\ |
_cairo_span_renderer_create_in_error,'_cairo_span_renderer_create_in_error',\ |
_cairo_span_renderer_set_error,'_cairo_span_renderer_set_error',\ |
_cairo_span_renderer_status,'_cairo_span_renderer_status',\ |
_cairo_spans_compositor_init,'_cairo_spans_compositor_init',\ |
_cairo_spline_bound,'_cairo_spline_bound',\ |
_cairo_spline_decompose,'_cairo_spline_decompose',\ |
_cairo_spline_init,'_cairo_spline_init',\ |
_cairo_spline_intersects,'_cairo_spline_intersects',\ |
_cairo_stock_color,'_cairo_stock_color',\ |
_cairo_stroke_style_dash_approximate,'_cairo_stroke_style_dash_approximate',\ |
_cairo_stroke_style_dash_can_approximate,'_cairo_stroke_style_dash_can_approximate',\ |
_cairo_stroke_style_dash_period,'_cairo_stroke_style_dash_period',\ |
_cairo_stroke_style_dash_stroked,'_cairo_stroke_style_dash_stroked',\ |
_cairo_stroke_style_fini,'_cairo_stroke_style_fini',\ |
_cairo_stroke_style_init,'_cairo_stroke_style_init',\ |
_cairo_stroke_style_init_copy,'_cairo_stroke_style_init_copy',\ |
_cairo_stroke_style_max_distance_from_path,'_cairo_stroke_style_max_distance_from_path',\ |
_cairo_stroke_style_max_join_distance_from_path,'_cairo_stroke_style_max_join_distance_from_path',\ |
_cairo_stroke_style_max_line_distance_from_path,'_cairo_stroke_style_max_line_distance_from_path',\ |
_cairo_stroker_dash_init,'_cairo_stroker_dash_init',\ |
_cairo_stroker_dash_start,'_cairo_stroker_dash_start',\ |
_cairo_stroker_dash_step,'_cairo_stroker_dash_step',\ |
_cairo_surface_acquire_source_image,'_cairo_surface_acquire_source_image',\ |
_cairo_surface_attach_snapshot,'_cairo_surface_attach_snapshot',\ |
_cairo_surface_begin_modification,'_cairo_surface_begin_modification',\ |
_cairo_surface_clipper_init,'_cairo_surface_clipper_init',\ |
_cairo_surface_clipper_reset,'_cairo_surface_clipper_reset',\ |
_cairo_surface_clipper_set_clip,'_cairo_surface_clipper_set_clip',\ |
_cairo_surface_copy_mime_data,'_cairo_surface_copy_mime_data',\ |
_cairo_surface_create_for_rectangle_int,'_cairo_surface_create_for_rectangle_int',\ |
_cairo_surface_create_in_error,'_cairo_surface_create_in_error',\ |
_cairo_surface_create_similar_scratch,'_cairo_surface_create_similar_scratch',\ |
_cairo_surface_create_similar_solid,'_cairo_surface_create_similar_solid',\ |
_cairo_surface_default_acquire_source_image,'_cairo_surface_default_acquire_source_image',\ |
_cairo_surface_default_release_source_image,'_cairo_surface_default_release_source_image',\ |
_cairo_surface_default_source,'_cairo_surface_default_source',\ |
_cairo_surface_detach_snapshot,'_cairo_surface_detach_snapshot',\ |
_cairo_surface_fallback_fill,'_cairo_surface_fallback_fill',\ |
_cairo_surface_fallback_glyphs,'_cairo_surface_fallback_glyphs',\ |
_cairo_surface_fallback_mask,'_cairo_surface_fallback_mask',\ |
_cairo_surface_fallback_paint,'_cairo_surface_fallback_paint',\ |
_cairo_surface_fallback_stroke,'_cairo_surface_fallback_stroke',\ |
_cairo_surface_fill,'_cairo_surface_fill',\ |
_cairo_surface_fill_stroke,'_cairo_surface_fill_stroke',\ |
_cairo_surface_flush,'_cairo_surface_flush',\ |
_cairo_surface_get_extents,'_cairo_surface_get_extents',\ |
_cairo_surface_get_source,'_cairo_surface_get_source',\ |
_cairo_surface_has_device_transform,'_cairo_surface_has_device_transform',\ |
_cairo_surface_has_snapshot,'_cairo_surface_has_snapshot',\ |
_cairo_surface_init,'_cairo_surface_init',\ |
_cairo_surface_is_paginated,'_cairo_surface_is_paginated',\ |
_cairo_surface_map_to_image,'_cairo_surface_map_to_image',\ |
_cairo_surface_mask,'_cairo_surface_mask',\ |
_cairo_surface_offset_fill,'_cairo_surface_offset_fill',\ |
_cairo_surface_offset_glyphs,'_cairo_surface_offset_glyphs',\ |
_cairo_surface_offset_mask,'_cairo_surface_offset_mask',\ |
_cairo_surface_offset_paint,'_cairo_surface_offset_paint',\ |
_cairo_surface_offset_stroke,'_cairo_surface_offset_stroke',\ |
_cairo_surface_paint,'_cairo_surface_paint',\ |
_cairo_surface_release_device_reference,'_cairo_surface_release_device_reference',\ |
_cairo_surface_release_source_image,'_cairo_surface_release_source_image',\ |
_cairo_surface_set_device_scale,'_cairo_surface_set_device_scale',\ |
_cairo_surface_set_error,'_cairo_surface_set_error',\ |
_cairo_surface_set_font_options,'_cairo_surface_set_font_options',\ |
_cairo_surface_set_resolution,'_cairo_surface_set_resolution',\ |
_cairo_surface_show_text_glyphs,'_cairo_surface_show_text_glyphs',\ |
_cairo_surface_snapshot,'_cairo_surface_snapshot',\ |
_cairo_surface_stroke,'_cairo_surface_stroke',\ |
_cairo_surface_subsurface_set_snapshot,'_cairo_surface_subsurface_set_snapshot',\ |
_cairo_surface_unmap_image,'_cairo_surface_unmap_image',\ |
_cairo_surface_wrapper_acquire_source_image,'_cairo_surface_wrapper_acquire_source_image',\ |
_cairo_surface_wrapper_create_similar,'_cairo_surface_wrapper_create_similar',\ |
_cairo_surface_wrapper_fill,'_cairo_surface_wrapper_fill',\ |
_cairo_surface_wrapper_fill_stroke,'_cairo_surface_wrapper_fill_stroke',\ |
_cairo_surface_wrapper_fini,'_cairo_surface_wrapper_fini',\ |
_cairo_surface_wrapper_get_extents,'_cairo_surface_wrapper_get_extents',\ |
_cairo_surface_wrapper_get_font_options,'_cairo_surface_wrapper_get_font_options',\ |
_cairo_surface_wrapper_get_target_extents,'_cairo_surface_wrapper_get_target_extents',\ |
_cairo_surface_wrapper_has_show_text_glyphs,'_cairo_surface_wrapper_has_show_text_glyphs',\ |
_cairo_surface_wrapper_init,'_cairo_surface_wrapper_init',\ |
_cairo_surface_wrapper_intersect_extents,'_cairo_surface_wrapper_intersect_extents',\ |
_cairo_surface_wrapper_mask,'_cairo_surface_wrapper_mask',\ |
_cairo_surface_wrapper_paint,'_cairo_surface_wrapper_paint',\ |
_cairo_surface_wrapper_release_source_image,'_cairo_surface_wrapper_release_source_image',\ |
_cairo_surface_wrapper_set_clip,'_cairo_surface_wrapper_set_clip',\ |
_cairo_surface_wrapper_set_inverse_transform,'_cairo_surface_wrapper_set_inverse_transform',\ |
_cairo_surface_wrapper_show_text_glyphs,'_cairo_surface_wrapper_show_text_glyphs',\ |
_cairo_surface_wrapper_snapshot,'_cairo_surface_wrapper_snapshot',\ |
_cairo_surface_wrapper_stroke,'_cairo_surface_wrapper_stroke',\ |
_cairo_tor22_scan_converter_add_polygon,'_cairo_tor22_scan_converter_add_polygon',\ |
_cairo_tor22_scan_converter_create,'_cairo_tor22_scan_converter_create',\ |
_cairo_tor_scan_converter_add_polygon,'_cairo_tor_scan_converter_add_polygon',\ |
_cairo_tor_scan_converter_create,'_cairo_tor_scan_converter_create',\ |
_cairo_toy_font_face_mutex,'_cairo_toy_font_face_mutex',\ |
_cairo_toy_font_face_reset_static_data,'_cairo_toy_font_face_reset_static_data',\ |
_cairo_trapezoid_array_translate_and_scale,'_cairo_trapezoid_array_translate_and_scale',\ |
_cairo_traps_add_trap,'_cairo_traps_add_trap',\ |
_cairo_traps_clear,'_cairo_traps_clear',\ |
_cairo_traps_compositor_init,'_cairo_traps_compositor_init',\ |
_cairo_traps_contain,'_cairo_traps_contain',\ |
_cairo_traps_extents,'_cairo_traps_extents',\ |
_cairo_traps_extract_region,'_cairo_traps_extract_region',\ |
_cairo_traps_fini,'_cairo_traps_fini',\ |
_cairo_traps_init,'_cairo_traps_init',\ |
_cairo_traps_init_boxes,'_cairo_traps_init_boxes',\ |
_cairo_traps_init_with_clip,'_cairo_traps_init_with_clip',\ |
_cairo_traps_limit,'_cairo_traps_limit',\ |
_cairo_traps_path,'_cairo_traps_path',\ |
_cairo_traps_tessellate_convex_quad,'_cairo_traps_tessellate_convex_quad',\ |
_cairo_traps_tessellate_rectangle,'_cairo_traps_tessellate_rectangle',\ |
_cairo_traps_tessellate_triangle,'_cairo_traps_tessellate_triangle',\ |
_cairo_traps_to_boxes,'_cairo_traps_to_boxes',\ |
_cairo_traps_translate,'_cairo_traps_translate',\ |
_cairo_tristrip_add_point,'_cairo_tristrip_add_point',\ |
_cairo_tristrip_extents,'_cairo_tristrip_extents',\ |
_cairo_tristrip_fini,'_cairo_tristrip_fini',\ |
_cairo_tristrip_init,'_cairo_tristrip_init',\ |
_cairo_tristrip_init_with_clip,'_cairo_tristrip_init_with_clip',\ |
_cairo_tristrip_limit,'_cairo_tristrip_limit',\ |
_cairo_tristrip_move_to,'_cairo_tristrip_move_to',\ |
_cairo_tristrip_translate,'_cairo_tristrip_translate',\ |
_cairo_truetype_get_style,'_cairo_truetype_get_style',\ |
_cairo_truetype_index_to_ucs4,'_cairo_truetype_index_to_ucs4',\ |
_cairo_truetype_read_font_name,'_cairo_truetype_read_font_name',\ |
_cairo_truetype_subset_fini,'_cairo_truetype_subset_fini',\ |
_cairo_truetype_subset_init_pdf,'_cairo_truetype_subset_init_pdf',\ |
_cairo_truetype_subset_init_ps,'_cairo_truetype_subset_init_ps',\ |
_cairo_twin_charmap,'_cairo_twin_charmap',\ |
_cairo_twin_outlines,'_cairo_twin_outlines',\ |
_cairo_type1_fallback_fini,'_cairo_type1_fallback_fini',\ |
_cairo_type1_fallback_init_binary,'_cairo_type1_fallback_init_binary',\ |
_cairo_type1_fallback_init_hex,'_cairo_type1_fallback_init_hex',\ |
_cairo_type1_scaled_font_is_type1,'_cairo_type1_scaled_font_is_type1',\ |
_cairo_type1_subset_fini,'_cairo_type1_subset_fini',\ |
_cairo_type1_subset_init,'_cairo_type1_subset_init',\ |
_cairo_type2_charstrings_fini,'_cairo_type2_charstrings_fini',\ |
_cairo_type2_charstrings_init,'_cairo_type2_charstrings_init',\ |
_cairo_type3_glyph_surface_analyze_glyph,'_cairo_type3_glyph_surface_analyze_glyph',\ |
_cairo_type3_glyph_surface_create,'_cairo_type3_glyph_surface_create',\ |
_cairo_type3_glyph_surface_emit_glyph,'_cairo_type3_glyph_surface_emit_glyph',\ |
_cairo_type3_glyph_surface_set_font_subsets_callback,'_cairo_type3_glyph_surface_set_font_subsets_callback',\ |
_cairo_ucs4_to_utf8,'_cairo_ucs4_to_utf8',\ |
_cairo_uint128_add,'_cairo_uint128_add',\ |
_cairo_uint128_cmp,'_cairo_uint128_cmp',\ |
_cairo_uint128_divrem,'_cairo_uint128_divrem',\ |
_cairo_uint128_eq,'_cairo_uint128_eq',\ |
_cairo_uint128_lsl,'_cairo_uint128_lsl',\ |
_cairo_uint128_lt,'_cairo_uint128_lt',\ |
_cairo_uint128_mul,'_cairo_uint128_mul',\ |
_cairo_uint128_negate,'_cairo_uint128_negate',\ |
_cairo_uint128_not,'_cairo_uint128_not',\ |
_cairo_uint128_rsa,'_cairo_uint128_rsa',\ |
_cairo_uint128_rsl,'_cairo_uint128_rsl',\ |
_cairo_uint128_sub,'_cairo_uint128_sub',\ |
_cairo_uint32_to_uint128,'_cairo_uint32_to_uint128',\ |
_cairo_uint64_to_uint128,'_cairo_uint64_to_uint128',\ |
_cairo_uint64x64_128_mul,'_cairo_uint64x64_128_mul',\ |
_cairo_uint_96by64_32x64_divrem,'_cairo_uint_96by64_32x64_divrem',\ |
_cairo_unbounded_rectangle,'_cairo_unbounded_rectangle',\ |
_cairo_unicode_to_winansi,'_cairo_unicode_to_winansi',\ |
_cairo_unscaled_font_destroy,'_cairo_unscaled_font_destroy',\ |
_cairo_unscaled_font_init,'_cairo_unscaled_font_init',\ |
_cairo_unscaled_font_reference,'_cairo_unscaled_font_reference',\ |
_cairo_user_data_array_copy,'_cairo_user_data_array_copy',\ |
_cairo_user_data_array_fini,'_cairo_user_data_array_fini',\ |
_cairo_user_data_array_foreach,'_cairo_user_data_array_foreach',\ |
_cairo_user_data_array_get_data,'_cairo_user_data_array_get_data',\ |
_cairo_user_data_array_init,'_cairo_user_data_array_init',\ |
_cairo_user_data_array_set_data,'_cairo_user_data_array_set_data',\ |
_cairo_user_font_face_backend,'_cairo_user_font_face_backend',\ |
_cairo_utf8_get_char_validated,'_cairo_utf8_get_char_validated',\ |
_cairo_utf8_to_ucs4,'_cairo_utf8_to_ucs4',\ |
_cairo_utf8_to_utf16,'_cairo_utf8_to_utf16',\ |
_cairo_validate_text_clusters,'_cairo_validate_text_clusters',\ |
_cairo_winansi_to_glyphname,'_cairo_winansi_to_glyphname',\ |
_do_cairo_gstate_backend_to_user,'_do_cairo_gstate_backend_to_user',\ |
_do_cairo_gstate_backend_to_user_distance,'_do_cairo_gstate_backend_to_user_distance',\ |
_do_cairo_gstate_user_to_backend,'_do_cairo_gstate_user_to_backend',\ |
_do_cairo_gstate_user_to_backend_distance,'_do_cairo_gstate_user_to_backend_distance',\ |
_pixman_format_from_masks,'_pixman_format_from_masks',\ |
_pixman_format_to_masks,'_pixman_format_to_masks',\ |
_pixman_image_add_traps,'_pixman_image_add_traps',\ |
_pixman_image_add_tristrip,'_pixman_image_add_tristrip',\ |
_pixman_image_for_color,'_pixman_image_for_color',\ |
_pixman_image_for_pattern,'_pixman_image_for_pattern',\ |
cairo_append_path,'cairo_append_path',\ |
cairo_arc,'cairo_arc',\ |
cairo_arc_negative,'cairo_arc_negative',\ |
cairo_clip,'cairo_clip',\ |
cairo_clip_extents,'cairo_clip_extents',\ |
cairo_clip_preserve,'cairo_clip_preserve',\ |
cairo_close_path,'cairo_close_path',\ |
cairo_copy_clip_rectangle_list,'cairo_copy_clip_rectangle_list',\ |
cairo_copy_page,'cairo_copy_page',\ |
cairo_copy_path,'cairo_copy_path',\ |
cairo_copy_path_flat,'cairo_copy_path_flat',\ |
cairo_create,'cairo_create',\ |
cairo_curve_to,'cairo_curve_to',\ |
cairo_debug_reset_static_data,'cairo_debug_reset_static_data',\ |
cairo_destroy,'cairo_destroy',\ |
cairo_device_acquire,'cairo_device_acquire',\ |
cairo_device_destroy,'cairo_device_destroy',\ |
cairo_device_finish,'cairo_device_finish',\ |
cairo_device_flush,'cairo_device_flush',\ |
cairo_device_get_reference_count,'cairo_device_get_reference_count',\ |
cairo_device_get_type,'cairo_device_get_type',\ |
cairo_device_get_user_data,'cairo_device_get_user_data',\ |
cairo_device_reference,'cairo_device_reference',\ |
cairo_device_release,'cairo_device_release',\ |
cairo_device_set_user_data,'cairo_device_set_user_data',\ |
cairo_device_status,'cairo_device_status',\ |
cairo_device_to_user,'cairo_device_to_user',\ |
cairo_device_to_user_distance,'cairo_device_to_user_distance',\ |
cairo_fill,'cairo_fill',\ |
cairo_fill_extents,'cairo_fill_extents',\ |
cairo_fill_preserve,'cairo_fill_preserve',\ |
cairo_font_extents,'cairo_font_extents',\ |
cairo_font_face_destroy,'cairo_font_face_destroy',\ |
cairo_font_face_get_reference_count,'cairo_font_face_get_reference_count',\ |
cairo_font_face_get_type,'cairo_font_face_get_type',\ |
cairo_font_face_get_user_data,'cairo_font_face_get_user_data',\ |
cairo_font_face_reference,'cairo_font_face_reference',\ |
cairo_font_face_set_user_data,'cairo_font_face_set_user_data',\ |
cairo_font_face_status,'cairo_font_face_status',\ |
cairo_font_options_copy,'cairo_font_options_copy',\ |
cairo_font_options_create,'cairo_font_options_create',\ |
cairo_font_options_destroy,'cairo_font_options_destroy',\ |
cairo_font_options_equal,'cairo_font_options_equal',\ |
cairo_font_options_get_antialias,'cairo_font_options_get_antialias',\ |
cairo_font_options_get_hint_metrics,'cairo_font_options_get_hint_metrics',\ |
cairo_font_options_get_hint_style,'cairo_font_options_get_hint_style',\ |
cairo_font_options_get_subpixel_order,'cairo_font_options_get_subpixel_order',\ |
cairo_font_options_hash,'cairo_font_options_hash',\ |
cairo_font_options_merge,'cairo_font_options_merge',\ |
cairo_font_options_set_antialias,'cairo_font_options_set_antialias',\ |
cairo_font_options_set_hint_metrics,'cairo_font_options_set_hint_metrics',\ |
cairo_font_options_set_hint_style,'cairo_font_options_set_hint_style',\ |
cairo_font_options_set_subpixel_order,'cairo_font_options_set_subpixel_order',\ |
cairo_font_options_status,'cairo_font_options_status',\ |
cairo_format_stride_for_width,'cairo_format_stride_for_width',\ |
cairo_ft_font_face_create_for_ft_face,'cairo_ft_font_face_create_for_ft_face',\ |
cairo_ft_font_face_get_synthesize,'cairo_ft_font_face_get_synthesize',\ |
cairo_ft_font_face_set_synthesize,'cairo_ft_font_face_set_synthesize',\ |
cairo_ft_font_face_unset_synthesize,'cairo_ft_font_face_unset_synthesize',\ |
cairo_ft_scaled_font_lock_face,'cairo_ft_scaled_font_lock_face',\ |
cairo_ft_scaled_font_unlock_face,'cairo_ft_scaled_font_unlock_face',\ |
cairo_get_antialias,'cairo_get_antialias',\ |
cairo_get_current_point,'cairo_get_current_point',\ |
cairo_get_dash,'cairo_get_dash',\ |
cairo_get_dash_count,'cairo_get_dash_count',\ |
cairo_get_fill_rule,'cairo_get_fill_rule',\ |
cairo_get_font_face,'cairo_get_font_face',\ |
cairo_get_font_matrix,'cairo_get_font_matrix',\ |
cairo_get_font_options,'cairo_get_font_options',\ |
cairo_get_group_target,'cairo_get_group_target',\ |
cairo_get_line_cap,'cairo_get_line_cap',\ |
cairo_get_line_join,'cairo_get_line_join',\ |
cairo_get_line_width,'cairo_get_line_width',\ |
cairo_get_matrix,'cairo_get_matrix',\ |
cairo_get_miter_limit,'cairo_get_miter_limit',\ |
cairo_get_operator,'cairo_get_operator',\ |
cairo_get_reference_count,'cairo_get_reference_count',\ |
cairo_get_scaled_font,'cairo_get_scaled_font',\ |
cairo_get_source,'cairo_get_source',\ |
cairo_get_target,'cairo_get_target',\ |
cairo_get_tolerance,'cairo_get_tolerance',\ |
cairo_get_user_data,'cairo_get_user_data',\ |
cairo_glyph_allocate,'cairo_glyph_allocate',\ |
cairo_glyph_extents,'cairo_glyph_extents',\ |
cairo_glyph_free,'cairo_glyph_free',\ |
cairo_glyph_path,'cairo_glyph_path',\ |
cairo_has_current_point,'cairo_has_current_point',\ |
cairo_identity_matrix,'cairo_identity_matrix',\ |
cairo_image_surface_create,'cairo_image_surface_create',\ |
cairo_image_surface_create_for_data,'cairo_image_surface_create_for_data',\ |
cairo_image_surface_create_from_png,'cairo_image_surface_create_from_png',\ |
cairo_image_surface_create_from_png_stream,'cairo_image_surface_create_from_png_stream',\ |
cairo_image_surface_get_data,'cairo_image_surface_get_data',\ |
cairo_image_surface_get_format,'cairo_image_surface_get_format',\ |
cairo_image_surface_get_height,'cairo_image_surface_get_height',\ |
cairo_image_surface_get_stride,'cairo_image_surface_get_stride',\ |
cairo_image_surface_get_width,'cairo_image_surface_get_width',\ |
cairo_in_clip,'cairo_in_clip',\ |
cairo_in_fill,'cairo_in_fill',\ |
cairo_in_stroke,'cairo_in_stroke',\ |
cairo_line_to,'cairo_line_to',\ |
cairo_mask,'cairo_mask',\ |
cairo_mask_surface,'cairo_mask_surface',\ |
cairo_matrix_init,'cairo_matrix_init',\ |
cairo_matrix_init_identity,'cairo_matrix_init_identity',\ |
cairo_matrix_init_rotate,'cairo_matrix_init_rotate',\ |
cairo_matrix_init_scale,'cairo_matrix_init_scale',\ |
cairo_matrix_init_translate,'cairo_matrix_init_translate',\ |
cairo_matrix_invert,'cairo_matrix_invert',\ |
cairo_matrix_multiply,'cairo_matrix_multiply',\ |
cairo_matrix_rotate,'cairo_matrix_rotate',\ |
cairo_matrix_scale,'cairo_matrix_scale',\ |
cairo_matrix_transform_distance,'cairo_matrix_transform_distance',\ |
cairo_matrix_transform_point,'cairo_matrix_transform_point',\ |
cairo_matrix_translate,'cairo_matrix_translate',\ |
cairo_mesh_pattern_begin_patch,'cairo_mesh_pattern_begin_patch',\ |
cairo_mesh_pattern_curve_to,'cairo_mesh_pattern_curve_to',\ |
cairo_mesh_pattern_end_patch,'cairo_mesh_pattern_end_patch',\ |
cairo_mesh_pattern_get_control_point,'cairo_mesh_pattern_get_control_point',\ |
cairo_mesh_pattern_get_corner_color_rgba,'cairo_mesh_pattern_get_corner_color_rgba',\ |
cairo_mesh_pattern_get_patch_count,'cairo_mesh_pattern_get_patch_count',\ |
cairo_mesh_pattern_get_path,'cairo_mesh_pattern_get_path',\ |
cairo_mesh_pattern_line_to,'cairo_mesh_pattern_line_to',\ |
cairo_mesh_pattern_move_to,'cairo_mesh_pattern_move_to',\ |
cairo_mesh_pattern_set_control_point,'cairo_mesh_pattern_set_control_point',\ |
cairo_mesh_pattern_set_corner_color_rgb,'cairo_mesh_pattern_set_corner_color_rgb',\ |
cairo_mesh_pattern_set_corner_color_rgba,'cairo_mesh_pattern_set_corner_color_rgba',\ |
cairo_move_to,'cairo_move_to',\ |
cairo_new_path,'cairo_new_path',\ |
cairo_new_sub_path,'cairo_new_sub_path',\ |
cairo_paint,'cairo_paint',\ |
cairo_paint_with_alpha,'cairo_paint_with_alpha',\ |
cairo_path_destroy,'cairo_path_destroy',\ |
cairo_path_extents,'cairo_path_extents',\ |
cairo_pattern_add_color_stop_rgb,'cairo_pattern_add_color_stop_rgb',\ |
cairo_pattern_add_color_stop_rgba,'cairo_pattern_add_color_stop_rgba',\ |
cairo_pattern_create_for_surface,'cairo_pattern_create_for_surface',\ |
cairo_pattern_create_linear,'cairo_pattern_create_linear',\ |
cairo_pattern_create_mesh,'cairo_pattern_create_mesh',\ |
cairo_pattern_create_radial,'cairo_pattern_create_radial',\ |
cairo_pattern_create_raster_source,'cairo_pattern_create_raster_source',\ |
cairo_pattern_create_rgb,'cairo_pattern_create_rgb',\ |
cairo_pattern_create_rgba,'cairo_pattern_create_rgba',\ |
cairo_pattern_destroy,'cairo_pattern_destroy',\ |
cairo_pattern_get_color_stop_count,'cairo_pattern_get_color_stop_count',\ |
cairo_pattern_get_color_stop_rgba,'cairo_pattern_get_color_stop_rgba',\ |
cairo_pattern_get_extend,'cairo_pattern_get_extend',\ |
cairo_pattern_get_filter,'cairo_pattern_get_filter',\ |
cairo_pattern_get_linear_points,'cairo_pattern_get_linear_points',\ |
cairo_pattern_get_matrix,'cairo_pattern_get_matrix',\ |
cairo_pattern_get_radial_circles,'cairo_pattern_get_radial_circles',\ |
cairo_pattern_get_reference_count,'cairo_pattern_get_reference_count',\ |
cairo_pattern_get_rgba,'cairo_pattern_get_rgba',\ |
cairo_pattern_get_surface,'cairo_pattern_get_surface',\ |
cairo_pattern_get_type,'cairo_pattern_get_type',\ |
cairo_pattern_get_user_data,'cairo_pattern_get_user_data',\ |
cairo_pattern_reference,'cairo_pattern_reference',\ |
cairo_pattern_set_extend,'cairo_pattern_set_extend',\ |
cairo_pattern_set_filter,'cairo_pattern_set_filter',\ |
cairo_pattern_set_matrix,'cairo_pattern_set_matrix',\ |
cairo_pattern_set_user_data,'cairo_pattern_set_user_data',\ |
cairo_pattern_status,'cairo_pattern_status',\ |
cairo_pop_group,'cairo_pop_group',\ |
cairo_pop_group_to_source,'cairo_pop_group_to_source',\ |
cairo_push_group,'cairo_push_group',\ |
cairo_push_group_with_content,'cairo_push_group_with_content',\ |
cairo_raster_source_pattern_get_acquire,'cairo_raster_source_pattern_get_acquire',\ |
cairo_raster_source_pattern_get_callback_data,'cairo_raster_source_pattern_get_callback_data',\ |
cairo_raster_source_pattern_get_copy,'cairo_raster_source_pattern_get_copy',\ |
cairo_raster_source_pattern_get_finish,'cairo_raster_source_pattern_get_finish',\ |
cairo_raster_source_pattern_get_snapshot,'cairo_raster_source_pattern_get_snapshot',\ |
cairo_raster_source_pattern_set_acquire,'cairo_raster_source_pattern_set_acquire',\ |
cairo_raster_source_pattern_set_callback_data,'cairo_raster_source_pattern_set_callback_data',\ |
cairo_raster_source_pattern_set_copy,'cairo_raster_source_pattern_set_copy',\ |
cairo_raster_source_pattern_set_finish,'cairo_raster_source_pattern_set_finish',\ |
cairo_raster_source_pattern_set_snapshot,'cairo_raster_source_pattern_set_snapshot',\ |
cairo_recording_surface_create,'cairo_recording_surface_create',\ |
cairo_recording_surface_get_extents,'cairo_recording_surface_get_extents',\ |
cairo_recording_surface_ink_extents,'cairo_recording_surface_ink_extents',\ |
cairo_rectangle,'cairo_rectangle',\ |
cairo_rectangle_list_destroy,'cairo_rectangle_list_destroy',\ |
cairo_reference,'cairo_reference',\ |
cairo_region_contains_point,'cairo_region_contains_point',\ |
cairo_region_contains_rectangle,'cairo_region_contains_rectangle',\ |
cairo_region_copy,'cairo_region_copy',\ |
cairo_region_create,'cairo_region_create',\ |
cairo_region_create_rectangle,'cairo_region_create_rectangle',\ |
cairo_region_create_rectangles,'cairo_region_create_rectangles',\ |
cairo_region_destroy,'cairo_region_destroy',\ |
cairo_region_equal,'cairo_region_equal',\ |
cairo_region_get_extents,'cairo_region_get_extents',\ |
cairo_region_get_rectangle,'cairo_region_get_rectangle',\ |
cairo_region_intersect,'cairo_region_intersect',\ |
cairo_region_intersect_rectangle,'cairo_region_intersect_rectangle',\ |
cairo_region_is_empty,'cairo_region_is_empty',\ |
cairo_region_num_rectangles,'cairo_region_num_rectangles',\ |
cairo_region_reference,'cairo_region_reference',\ |
cairo_region_status,'cairo_region_status',\ |
cairo_region_subtract,'cairo_region_subtract',\ |
cairo_region_subtract_rectangle,'cairo_region_subtract_rectangle',\ |
cairo_region_translate,'cairo_region_translate',\ |
cairo_region_union,'cairo_region_union',\ |
cairo_region_union_rectangle,'cairo_region_union_rectangle',\ |
cairo_region_xor,'cairo_region_xor',\ |
cairo_region_xor_rectangle,'cairo_region_xor_rectangle',\ |
cairo_rel_curve_to,'cairo_rel_curve_to',\ |
cairo_rel_line_to,'cairo_rel_line_to',\ |
cairo_rel_move_to,'cairo_rel_move_to',\ |
cairo_reset_clip,'cairo_reset_clip',\ |
cairo_restore,'cairo_restore',\ |
cairo_rotate,'cairo_rotate',\ |
cairo_save,'cairo_save',\ |
cairo_scale,'cairo_scale',\ |
cairo_scaled_font_create,'cairo_scaled_font_create',\ |
cairo_scaled_font_destroy,'cairo_scaled_font_destroy',\ |
cairo_scaled_font_extents,'cairo_scaled_font_extents',\ |
cairo_scaled_font_get_ctm,'cairo_scaled_font_get_ctm',\ |
cairo_scaled_font_get_font_face,'cairo_scaled_font_get_font_face',\ |
cairo_scaled_font_get_font_matrix,'cairo_scaled_font_get_font_matrix',\ |
cairo_scaled_font_get_font_options,'cairo_scaled_font_get_font_options',\ |
cairo_scaled_font_get_reference_count,'cairo_scaled_font_get_reference_count',\ |
cairo_scaled_font_get_scale_matrix,'cairo_scaled_font_get_scale_matrix',\ |
cairo_scaled_font_get_type,'cairo_scaled_font_get_type',\ |
cairo_scaled_font_get_user_data,'cairo_scaled_font_get_user_data',\ |
cairo_scaled_font_glyph_extents,'cairo_scaled_font_glyph_extents',\ |
cairo_scaled_font_reference,'cairo_scaled_font_reference',\ |
cairo_scaled_font_set_user_data,'cairo_scaled_font_set_user_data',\ |
cairo_scaled_font_status,'cairo_scaled_font_status',\ |
cairo_scaled_font_text_extents,'cairo_scaled_font_text_extents',\ |
cairo_scaled_font_text_to_glyphs,'cairo_scaled_font_text_to_glyphs',\ |
cairo_script_create,'cairo_script_create',\ |
cairo_script_create_for_stream,'cairo_script_create_for_stream',\ |
cairo_script_from_recording_surface,'cairo_script_from_recording_surface',\ |
cairo_script_get_mode,'cairo_script_get_mode',\ |
cairo_script_set_mode,'cairo_script_set_mode',\ |
cairo_script_surface_create,'cairo_script_surface_create',\ |
cairo_script_surface_create_for_target,'cairo_script_surface_create_for_target',\ |
cairo_script_write_comment,'cairo_script_write_comment',\ |
cairo_select_font_face,'cairo_select_font_face',\ |
cairo_set_antialias,'cairo_set_antialias',\ |
cairo_set_dash,'cairo_set_dash',\ |
cairo_set_fill_rule,'cairo_set_fill_rule',\ |
cairo_set_font_face,'cairo_set_font_face',\ |
cairo_set_font_matrix,'cairo_set_font_matrix',\ |
cairo_set_font_options,'cairo_set_font_options',\ |
cairo_set_font_size,'cairo_set_font_size',\ |
cairo_set_line_cap,'cairo_set_line_cap',\ |
cairo_set_line_join,'cairo_set_line_join',\ |
cairo_set_line_width,'cairo_set_line_width',\ |
cairo_set_matrix,'cairo_set_matrix',\ |
cairo_set_miter_limit,'cairo_set_miter_limit',\ |
cairo_set_operator,'cairo_set_operator',\ |
cairo_set_scaled_font,'cairo_set_scaled_font',\ |
cairo_set_source,'cairo_set_source',\ |
cairo_set_source_rgb,'cairo_set_source_rgb',\ |
cairo_set_source_rgba,'cairo_set_source_rgba',\ |
cairo_set_source_surface,'cairo_set_source_surface',\ |
cairo_set_tolerance,'cairo_set_tolerance',\ |
cairo_set_user_data,'cairo_set_user_data',\ |
cairo_show_glyphs,'cairo_show_glyphs',\ |
cairo_show_page,'cairo_show_page',\ |
cairo_show_text,'cairo_show_text',\ |
cairo_show_text_glyphs,'cairo_show_text_glyphs',\ |
cairo_status,'cairo_status',\ |
cairo_status_to_string,'cairo_status_to_string',\ |
cairo_stroke,'cairo_stroke',\ |
cairo_stroke_extents,'cairo_stroke_extents',\ |
cairo_stroke_preserve,'cairo_stroke_preserve',\ |
cairo_surface_copy_page,'cairo_surface_copy_page',\ |
cairo_surface_create_for_rectangle,'cairo_surface_create_for_rectangle',\ |
cairo_surface_create_similar,'cairo_surface_create_similar',\ |
cairo_surface_create_similar_image,'cairo_surface_create_similar_image',\ |
cairo_surface_destroy,'cairo_surface_destroy',\ |
cairo_surface_finish,'cairo_surface_finish',\ |
cairo_surface_flush,'cairo_surface_flush',\ |
cairo_surface_get_content,'cairo_surface_get_content',\ |
cairo_surface_get_device,'cairo_surface_get_device',\ |
cairo_surface_get_device_offset,'cairo_surface_get_device_offset',\ |
cairo_surface_get_fallback_resolution,'cairo_surface_get_fallback_resolution',\ |
cairo_surface_get_font_options,'cairo_surface_get_font_options',\ |
cairo_surface_get_mime_data,'cairo_surface_get_mime_data',\ |
cairo_surface_get_reference_count,'cairo_surface_get_reference_count',\ |
cairo_surface_get_type,'cairo_surface_get_type',\ |
cairo_surface_get_user_data,'cairo_surface_get_user_data',\ |
cairo_surface_has_show_text_glyphs,'cairo_surface_has_show_text_glyphs',\ |
cairo_surface_map_to_image,'cairo_surface_map_to_image',\ |
cairo_surface_mark_dirty,'cairo_surface_mark_dirty',\ |
cairo_surface_mark_dirty_rectangle,'cairo_surface_mark_dirty_rectangle',\ |
cairo_surface_reference,'cairo_surface_reference',\ |
cairo_surface_set_device_offset,'cairo_surface_set_device_offset',\ |
cairo_surface_set_fallback_resolution,'cairo_surface_set_fallback_resolution',\ |
cairo_surface_set_mime_data,'cairo_surface_set_mime_data',\ |
cairo_surface_set_user_data,'cairo_surface_set_user_data',\ |
cairo_surface_show_page,'cairo_surface_show_page',\ |
cairo_surface_status,'cairo_surface_status',\ |
cairo_surface_supports_mime_type,'cairo_surface_supports_mime_type',\ |
cairo_surface_unmap_image,'cairo_surface_unmap_image',\ |
cairo_surface_write_to_png,'cairo_surface_write_to_png',\ |
cairo_surface_write_to_png_stream,'cairo_surface_write_to_png_stream',\ |
cairo_svg_get_versions,'cairo_svg_get_versions',\ |
cairo_svg_surface_create,'cairo_svg_surface_create',\ |
cairo_svg_surface_create_for_stream,'cairo_svg_surface_create_for_stream',\ |
cairo_svg_surface_restrict_to_version,'cairo_svg_surface_restrict_to_version',\ |
cairo_svg_version_to_string,'cairo_svg_version_to_string',\ |
cairo_text_cluster_allocate,'cairo_text_cluster_allocate',\ |
cairo_text_cluster_free,'cairo_text_cluster_free',\ |
cairo_text_extents,'cairo_text_extents',\ |
cairo_text_path,'cairo_text_path',\ |
cairo_toy_font_face_create,'cairo_toy_font_face_create',\ |
cairo_toy_font_face_get_family,'cairo_toy_font_face_get_family',\ |
cairo_toy_font_face_get_slant,'cairo_toy_font_face_get_slant',\ |
cairo_toy_font_face_get_weight,'cairo_toy_font_face_get_weight',\ |
cairo_transform,'cairo_transform',\ |
cairo_translate,'cairo_translate',\ |
cairo_user_font_face_create,'cairo_user_font_face_create',\ |
cairo_user_font_face_get_init_func,'cairo_user_font_face_get_init_func',\ |
cairo_user_font_face_get_render_glyph_func,'cairo_user_font_face_get_render_glyph_func',\ |
cairo_user_font_face_get_text_to_glyphs_func,'cairo_user_font_face_get_text_to_glyphs_func',\ |
cairo_user_font_face_get_unicode_to_glyph_func,'cairo_user_font_face_get_unicode_to_glyph_func',\ |
cairo_user_font_face_set_init_func,'cairo_user_font_face_set_init_func',\ |
cairo_user_font_face_set_render_glyph_func,'cairo_user_font_face_set_render_glyph_func',\ |
cairo_user_font_face_set_text_to_glyphs_func,'cairo_user_font_face_set_text_to_glyphs_func',\ |
cairo_user_font_face_set_unicode_to_glyph_func,'cairo_user_font_face_set_unicode_to_glyph_func',\ |
cairo_user_to_device,'cairo_user_to_device',\ |
cairo_user_to_device_distance,'cairo_user_to_device_distance',\ |
cairo_version,'cairo_version',\ |
cairo_version_string,'cairo_version_string' |
/contrib/sdk/sources/libc/sdk/fasm/include/import32.inc |
---|
0,0 → 1,68 |
; Macroinstructions for making import section |
macro library [name,string] |
{ common |
import.data: |
forward |
local _label |
if defined name#.redundant |
if ~ name#.redundant |
dd name#.lookup,0,0, _label, name#.address |
end if |
end if |
name#.referred = 1 |
common |
dd 0,0,0,0,0 |
forward |
if defined name#.redundant |
if ~ name#.redundant |
_label db string,0 |
rb $ and 1 |
end if |
end if } |
macro import name,[label,string] |
{ common |
rb (- $) and 3 |
if defined name#.referred |
name#.lookup: |
forward |
if used label |
if string eqtype '' |
local _label |
dd _label |
else |
dd 80000000h + string |
end if |
end if |
common |
if $ > name#.lookup |
name#.redundant = 0 |
dd 0 |
else |
name#.redundant = 1 |
end if |
name#.address: |
forward |
if used label |
if string eqtype '' |
label dd _label |
else |
label dd 80000000h + string |
end if |
end if |
common |
if ~ name#.redundant |
dd 0 |
end if |
forward |
if used label & string eqtype '' |
_label dw 0 |
db string,0 |
rb $ and 1 |
end if |
common |
end if } |
macro api [name] {} |
/contrib/sdk/sources/libc/sdk/fasm/include/libc.inc |
---|
0,0 → 1,674 |
import libc,\ |
__Balloc,'_Balloc',\ |
__Bfree,'_Bfree',\ |
__Exit,'_Exit',\ |
___ChkTTYIOMode,'__ChkTTYIOMode',\ |
___GetIOMode,'__GetIOMode',\ |
___SetIOMode,'__SetIOMode',\ |
___SetIOMode_nogrow,'__SetIOMode_nogrow',\ |
___allocPOSIXHandle,'__allocPOSIXHandle',\ |
___any_on,'__any_on',\ |
___ascii_mbtowc,'__ascii_mbtowc',\ |
___ascii_wctomb,'__ascii_wctomb',\ |
___assert_func,'__assert_func',\ |
___b2d,'__b2d',\ |
___call_exitprocs,'__call_exitprocs',\ |
___copybits,'__copybits',\ |
___cpu_features_init,'__cpu_features_init',\ |
___ctype_load_locale,'__ctype_load_locale',\ |
___ctype_ptr__,'__ctype_ptr__',\ |
___d2b,'__d2b',\ |
___dorand48,'__dorand48',\ |
___dtoa,'__dtoa',\ |
___emutls_get_address,'__emutls_get_address',\ |
___emutls_register_common,'__emutls_register_common',\ |
___errno,'__errno',\ |
___fp_lock_all,'__fp_lock_all',\ |
___fp_unlock_all,'__fp_unlock_all',\ |
___fpclassifyd,'__fpclassifyd',\ |
___fpclassifyf,'__fpclassifyf',\ |
___freePOSIXHandle,'__freePOSIXHandle',\ |
___getOSHandle,'__getOSHandle',\ |
___get_current_ctype_locale,'__get_current_ctype_locale',\ |
___gethex,'__gethex',\ |
___gettzinfo,'__gettzinfo',\ |
___growPOSIXHandles,'__growPOSIXHandles',\ |
___grow_iomode,'__grow_iomode',\ |
___gthread_once,'__gthread_once',\ |
___hexdig_init,'__hexdig_init',\ |
___hexnan,'__hexnan',\ |
___hi0bits,'__hi0bits',\ |
___i2b,'__i2b',\ |
___ieee754_acos,'__ieee754_acos',\ |
___ieee754_acosf,'__ieee754_acosf',\ |
___ieee754_acosh,'__ieee754_acosh',\ |
___ieee754_acoshf,'__ieee754_acoshf',\ |
___ieee754_asin,'__ieee754_asin',\ |
___ieee754_asinf,'__ieee754_asinf',\ |
___ieee754_atan2,'__ieee754_atan2',\ |
___ieee754_atan2f,'__ieee754_atan2f',\ |
___ieee754_atanh,'__ieee754_atanh',\ |
___ieee754_atanhf,'__ieee754_atanhf',\ |
___ieee754_cosh,'__ieee754_cosh',\ |
___ieee754_coshf,'__ieee754_coshf',\ |
___ieee754_exp,'__ieee754_exp',\ |
___ieee754_expf,'__ieee754_expf',\ |
___ieee754_fmod,'__ieee754_fmod',\ |
___ieee754_fmodf,'__ieee754_fmodf',\ |
___ieee754_gamma_r,'__ieee754_gamma_r',\ |
___ieee754_gammaf_r,'__ieee754_gammaf_r',\ |
___ieee754_hypot,'__ieee754_hypot',\ |
___ieee754_hypotf,'__ieee754_hypotf',\ |
___ieee754_j0,'__ieee754_j0',\ |
___ieee754_j0f,'__ieee754_j0f',\ |
___ieee754_j1,'__ieee754_j1',\ |
___ieee754_j1f,'__ieee754_j1f',\ |
___ieee754_jn,'__ieee754_jn',\ |
___ieee754_jnf,'__ieee754_jnf',\ |
___ieee754_lgamma_r,'__ieee754_lgamma_r',\ |
___ieee754_lgammaf_r,'__ieee754_lgammaf_r',\ |
___ieee754_log,'__ieee754_log',\ |
___ieee754_log10,'__ieee754_log10',\ |
___ieee754_log10f,'__ieee754_log10f',\ |
___ieee754_logf,'__ieee754_logf',\ |
___ieee754_pow,'__ieee754_pow',\ |
___ieee754_powf,'__ieee754_powf',\ |
___ieee754_rem_pio2,'__ieee754_rem_pio2',\ |
___ieee754_rem_pio2f,'__ieee754_rem_pio2f',\ |
___ieee754_remainder,'__ieee754_remainder',\ |
___ieee754_remainderf,'__ieee754_remainderf',\ |
___ieee754_scalb,'__ieee754_scalb',\ |
___ieee754_scalbf,'__ieee754_scalbf',\ |
___ieee754_sinh,'__ieee754_sinh',\ |
___ieee754_sinhf,'__ieee754_sinhf',\ |
___ieee754_sqrt,'__ieee754_sqrt',\ |
___ieee754_sqrtf,'__ieee754_sqrtf',\ |
___ieee754_y0,'__ieee754_y0',\ |
___ieee754_y0f,'__ieee754_y0f',\ |
___ieee754_y1,'__ieee754_y1',\ |
___ieee754_y1f,'__ieee754_y1f',\ |
___ieee754_yn,'__ieee754_yn',\ |
___ieee754_ynf,'__ieee754_ynf',\ |
___infinity,'__infinity',\ |
___infinityf,'__infinityf',\ |
___infinityld,'__infinityld',\ |
___init_mode,'__init_mode',\ |
___io_mode,'__io_mode',\ |
___isinfd,'__isinfd',\ |
___isinff,'__isinff',\ |
___isnand,'__isnand',\ |
___isnanf,'__isnanf',\ |
___kernel_cos,'__kernel_cos',\ |
___kernel_cosf,'__kernel_cosf',\ |
___kernel_rem_pio2,'__kernel_rem_pio2',\ |
___kernel_rem_pio2f,'__kernel_rem_pio2f',\ |
___kernel_sin,'__kernel_sin',\ |
___kernel_sinf,'__kernel_sinf',\ |
___kernel_standard,'__kernel_standard',\ |
___kernel_tan,'__kernel_tan',\ |
___kernel_tanf,'__kernel_tanf',\ |
___libc_getenv,'__libc_getenv',\ |
___lo0bits,'__lo0bits',\ |
___locale_charset,'__locale_charset',\ |
___locale_cjk_lang,'__locale_cjk_lang',\ |
___locale_mb_cur_max,'__locale_mb_cur_max',\ |
___locale_msgcharset,'__locale_msgcharset',\ |
___lshift,'__lshift',\ |
___malloc_lock,'__malloc_lock',\ |
___malloc_unlock,'__malloc_unlock',\ |
___mb_cur_max,'__mb_cur_max',\ |
___mbtowc,'__mbtowc',\ |
___mcmp,'__mcmp',\ |
___mdiff,'__mdiff',\ |
___mlocale_changed,'__mlocale_changed',\ |
___mprec_bigtens,'__mprec_bigtens',\ |
___mprec_tens,'__mprec_tens',\ |
___mprec_tinytens,'__mprec_tinytens',\ |
___multadd,'__multadd',\ |
___multiply,'__multiply',\ |
___mutex_lock,'__mutex_lock',\ |
___nlocale_changed,'__nlocale_changed',\ |
___pow5mult,'__pow5mult',\ |
___ratio,'__ratio',\ |
___register_exitproc,'__register_exitproc',\ |
___s2b,'__s2b',\ |
___sccl,'__sccl',\ |
___sclose,'__sclose',\ |
___seofread,'__seofread',\ |
___setOSHandle,'__setOSHandle',\ |
___set_handles,'__set_handles',\ |
___sflags,'__sflags',\ |
___sflush_r,'__sflush_r',\ |
___sfmoreglue,'__sfmoreglue',\ |
___sfp,'__sfp',\ |
___sfp_lock_acquire,'__sfp_lock_acquire',\ |
___sfp_lock_release,'__sfp_lock_release',\ |
___sfvwrite_r,'__sfvwrite_r',\ |
___shrink_iomode,'__shrink_iomode',\ |
___signbitd,'__signbitd',\ |
___signbitf,'__signbitf',\ |
___sigtramp,'__sigtramp',\ |
___sigtramp_r,'__sigtramp_r',\ |
___sinit,'__sinit',\ |
___sinit_lock_acquire,'__sinit_lock_acquire',\ |
___sinit_lock_release,'__sinit_lock_release',\ |
___smakebuf_r,'__smakebuf_r',\ |
___sprint_r,'__sprint_r',\ |
___sread,'__sread',\ |
___srefill_r,'__srefill_r',\ |
___srget,'__srget',\ |
___srget_r,'__srget_r',\ |
___sseek,'__sseek',\ |
___ssprint_r,'__ssprint_r',\ |
___ssrefill_r,'__ssrefill_r',\ |
___ssvfiscanf_r,'__ssvfiscanf_r',\ |
___ssvfscanf_r,'__ssvfscanf_r',\ |
___strtok_r,'__strtok_r',\ |
___submore,'__submore',\ |
___svfiscanf,'__svfiscanf',\ |
___svfiscanf_r,'__svfiscanf_r',\ |
___svfscanf,'__svfscanf',\ |
___svfscanf_r,'__svfscanf_r',\ |
___swbuf,'__swbuf',\ |
___swbuf_r,'__swbuf_r',\ |
___swrite,'__swrite',\ |
___swsetup_r,'__swsetup_r',\ |
___thread_startup,'__thread_startup',\ |
___tz_lock,'__tz_lock',\ |
___tz_unlock,'__tz_unlock',\ |
___tzcalc_limits,'__tzcalc_limits',\ |
___ulp,'__ulp',\ |
___wctomb,'__wctomb',\ |
__assert,'_assert',\ |
__atoi_r,'_atoi_r',\ |
__atol_r,'_atol_r',\ |
__buf_findstr,'_buf_findstr',\ |
__calloc_r,'_calloc_r',\ |
__cleanup,'_cleanup',\ |
__cleanup_r,'_cleanup_r',\ |
__close_r,'_close_r',\ |
__ctype_,'_ctype_',\ |
__daylight,'_daylight',\ |
__diprintf_r,'_diprintf_r',\ |
__dprintf_r,'_dprintf_r',\ |
__dtoa_r,'_dtoa_r',\ |
__exit,'_exit',\ |
__f_atan2,'_f_atan2',\ |
__f_atan2f,'_f_atan2f',\ |
__f_exp,'_f_exp',\ |
__f_expf,'_f_expf',\ |
__f_frexp,'_f_frexp',\ |
__f_frexpf,'_f_frexpf',\ |
__f_ldexp,'_f_ldexp',\ |
__f_ldexpf,'_f_ldexpf',\ |
__f_llrint,'_f_llrint',\ |
__f_llrintf,'_f_llrintf',\ |
__f_llrintl,'_f_llrintl',\ |
__f_log,'_f_log',\ |
__f_log10,'_f_log10',\ |
__f_log10f,'_f_log10f',\ |
__f_logf,'_f_logf',\ |
__f_lrint,'_f_lrint',\ |
__f_lrintf,'_f_lrintf',\ |
__f_lrintl,'_f_lrintl',\ |
__f_pow,'_f_pow',\ |
__f_powf,'_f_powf',\ |
__f_rint,'_f_rint',\ |
__f_rintf,'_f_rintf',\ |
__f_rintl,'_f_rintl',\ |
__f_tan,'_f_tan',\ |
__f_tanf,'_f_tanf',\ |
__fclose_r,'_fclose_r',\ |
__fdopen_r,'_fdopen_r',\ |
__fflush_r,'_fflush_r',\ |
__fgetc_r,'_fgetc_r',\ |
__fgets_r,'_fgets_r',\ |
__findenv,'_findenv',\ |
__fiprintf_r,'_fiprintf_r',\ |
__fiscanf_r,'_fiscanf_r',\ |
__fopen_r,'_fopen_r',\ |
__fprintf_r,'_fprintf_r',\ |
__fputc_r,'_fputc_r',\ |
__fputs_r,'_fputs_r',\ |
__fputwc_r,'_fputwc_r',\ |
__fread_r,'_fread_r',\ |
__free_r,'_free_r',\ |
__freopen_r,'_freopen_r',\ |
__fscanf_r,'_fscanf_r',\ |
__fseek_r,'_fseek_r',\ |
__fseeko_r,'_fseeko_r',\ |
__fstat_r,'_fstat_r',\ |
__ftell_r,'_ftell_r',\ |
__ftello_r,'_ftello_r',\ |
__fwalk,'_fwalk',\ |
__fwalk_reent,'_fwalk_reent',\ |
__fwrite_r,'_fwrite_r',\ |
__gettimeofday,'_gettimeofday',\ |
__gettimeofday_r,'_gettimeofday_r',\ |
__global_impure_ptr,'_global_impure_ptr',\ |
__grow_handles,'_grow_handles',\ |
__init_signal,'_init_signal',\ |
__init_signal_r,'_init_signal_r',\ |
__isatty,'_isatty',\ |
__isatty_r,'_isatty_r',\ |
__kill_r,'_kill_r',\ |
__localeconv_r,'_localeconv_r',\ |
__lseek_r,'_lseek_r',\ |
__malloc_r,'_malloc_r',\ |
__mbrtowc_r,'_mbrtowc_r',\ |
__mbtowc_r,'_mbtowc_r',\ |
__mktm_r,'_mktm_r',\ |
__mprec_log10,'_mprec_log10',\ |
__open_r,'_open_r',\ |
__printf_r,'_printf_r',\ |
__putc_r,'_putc_r',\ |
__putchar_r,'_putchar_r',\ |
__puts_r,'_puts_r',\ |
__raise_r,'_raise_r',\ |
__read,'_read',\ |
__read_r,'_read_r',\ |
__realloc_r,'_realloc_r',\ |
__remove_r,'_remove_r',\ |
__rename_r,'_rename_r',\ |
__seed48_r,'_seed48_r',\ |
__setlocale_r,'_setlocale_r',\ |
__sfread_r,'_sfread_r',\ |
__signal_r,'_signal_r',\ |
__siprintf_r,'_siprintf_r',\ |
__sniprintf_r,'_sniprintf_r',\ |
__snprintf_r,'_snprintf_r',\ |
__sprintf_r,'_sprintf_r',\ |
__srand48_r,'_srand48_r',\ |
__sscanf_r,'_sscanf_r',\ |
__strdup_r,'_strdup_r',\ |
__strerror_r,'_strerror_r',\ |
__strndup_r,'_strndup_r',\ |
__strtod_r,'_strtod_r',\ |
__strtol_r,'_strtol_r',\ |
__strtoll_r,'_strtoll_r',\ |
__strtoul_r,'_strtoul_r',\ |
__strtoull_r,'_strtoull_r',\ |
__sungetc_r,'_sungetc_r',\ |
__svfiprintf_r,'_svfiprintf_r',\ |
__svfprintf_r,'_svfprintf_r',\ |
__system_r,'_system_r',\ |
__tempnam_r,'_tempnam_r',\ |
__times_r,'_times_r',\ |
__timezone,'_timezone',\ |
__tls_map,'_tls_map',\ |
__tmpfile_r,'_tmpfile_r',\ |
__tmpnam_r,'_tmpnam_r',\ |
__towctrans_r,'_towctrans_r',\ |
__tzname,'_tzname',\ |
__ungetc_r,'_ungetc_r',\ |
__user_strerror,'_user_strerror',\ |
__vasniprintf_r,'_vasniprintf_r',\ |
__vasnprintf_r,'_vasnprintf_r',\ |
__vdiprintf_r,'_vdiprintf_r',\ |
__vdprintf_r,'_vdprintf_r',\ |
__vfiprintf_r,'_vfiprintf_r',\ |
__vfiscanf_r,'_vfiscanf_r',\ |
__vfprintf_r,'_vfprintf_r',\ |
__vfscanf_r,'_vfscanf_r',\ |
__vscanf_r,'_vscanf_r',\ |
__vsnprintf_r,'_vsnprintf_r',\ |
__vsprintf_r,'_vsprintf_r',\ |
__vsscanf_r,'_vsscanf_r',\ |
__wcrtomb_r,'_wcrtomb_r',\ |
__wctomb_r,'_wctomb_r',\ |
__wctrans_r,'_wctrans_r',\ |
__wctype_r,'_wctype_r',\ |
__write_r,'_write_r',\ |
_abort,'abort',\ |
_abs,'abs',\ |
_acos,'acos',\ |
_acosf,'acosf',\ |
_acosh,'acosh',\ |
_acoshf,'acoshf',\ |
_asctime,'asctime',\ |
_asctime_r,'asctime_r',\ |
_asin,'asin',\ |
_asinf,'asinf',\ |
_asinh,'asinh',\ |
_asinhf,'asinhf',\ |
_atan,'atan',\ |
_atan2,'atan2',\ |
_atan2f,'atan2f',\ |
_atanf,'atanf',\ |
_atanh,'atanh',\ |
_atanhf,'atanhf',\ |
_atof,'atof',\ |
_atoi,'atoi',\ |
_atol,'atol',\ |
_bsearch,'bsearch',\ |
_calloc,'calloc',\ |
_cbrt,'cbrt',\ |
_cbrtf,'cbrtf',\ |
_ceil,'ceil',\ |
_ceilf,'ceilf',\ |
_clearerr,'clearerr',\ |
_clock,'clock',\ |
_close,'close',\ |
_copysign,'copysign',\ |
_copysignf,'copysignf',\ |
_cos,'cos',\ |
_cosf,'cosf',\ |
_cosh,'cosh',\ |
_coshf,'coshf',\ |
_create_file,'create_file',\ |
_create_image,'create_image',\ |
_create_thread,'create_thread',\ |
_ctime,'ctime',\ |
_ctime_r,'ctime_r',\ |
_debugwrite,'debugwrite',\ |
_delete_file,'delete_file',\ |
_difftime,'difftime',\ |
_diprintf,'diprintf',\ |
_div,'div',\ |
_dprintf,'dprintf',\ |
_drem,'drem',\ |
_dremf,'dremf',\ |
_entry,'entry',\ |
_envz_get,'envz_get',\ |
_erf,'erf',\ |
_erfc,'erfc',\ |
_erfcf,'erfcf',\ |
_erff,'erff',\ |
_exit,'exit',\ |
_exp,'exp',\ |
_exp10,'exp10',\ |
_exp10f,'exp10f',\ |
_exp2,'exp2',\ |
_exp2f,'exp2f',\ |
_expf,'expf',\ |
_expm1,'expm1',\ |
_expm1f,'expm1f',\ |
_fabs,'fabs',\ |
_fabsf,'fabsf',\ |
_fclose,'fclose',\ |
_fdim,'fdim',\ |
_fdimf,'fdimf',\ |
_fdopen,'fdopen',\ |
_fflush,'fflush',\ |
_fgetc,'fgetc',\ |
_fgets,'fgets',\ |
_fileno,'fileno',\ |
_finite,'finite',\ |
_finitef,'finitef',\ |
_fiprintf,'fiprintf',\ |
_fiscanf,'fiscanf',\ |
_floor,'floor',\ |
_floorf,'floorf',\ |
_fma,'fma',\ |
_fmaf,'fmaf',\ |
_fmax,'fmax',\ |
_fmaxf,'fmaxf',\ |
_fmin,'fmin',\ |
_fminf,'fminf',\ |
_fmod,'fmod',\ |
_fmodf,'fmodf',\ |
_fopen,'fopen',\ |
_fprintf,'fprintf',\ |
_fputc,'fputc',\ |
_fputs,'fputs',\ |
_fputwc,'fputwc',\ |
_fread,'fread',\ |
_free,'free',\ |
_freopen,'freopen',\ |
_frexp,'frexp',\ |
_frexpf,'frexpf',\ |
_fscanf,'fscanf',\ |
_fseek,'fseek',\ |
_fseeko,'fseeko',\ |
_fstat,'fstat',\ |
_ftell,'ftell',\ |
_ftello,'ftello',\ |
_fwrite,'fwrite',\ |
_gamma,'gamma',\ |
_gamma_r,'gamma_r',\ |
_gammaf,'gammaf',\ |
_gammaf_r,'gammaf_r',\ |
_get_entry_point,'get_entry_point',\ |
_get_fileinfo,'get_fileinfo',\ |
_get_proc_address,'get_proc_address',\ |
_getenv,'getenv',\ |
_gettimeofday,'gettimeofday',\ |
_gmtime,'gmtime',\ |
_gmtime_r,'gmtime_r',\ |
_hypot,'hypot',\ |
_hypotf,'hypotf',\ |
_ilogb,'ilogb',\ |
_ilogbf,'ilogbf',\ |
_infinity,'infinity',\ |
_infinityf,'infinityf',\ |
_init_global_reent,'init_global_reent',\ |
_init_loader,'init_loader',\ |
_init_reent,'init_reent',\ |
_isalnum,'isalnum',\ |
_isalpha,'isalpha',\ |
_isascii,'isascii',\ |
_isblank,'isblank',\ |
_iscntrl,'iscntrl',\ |
_isdigit,'isdigit',\ |
_isgraph,'isgraph',\ |
_isinf,'isinf',\ |
_isinff,'isinff',\ |
_islower,'islower',\ |
_isnan,'isnan',\ |
_isnanf,'isnanf',\ |
_isprint,'isprint',\ |
_ispunct,'ispunct',\ |
_isspace,'isspace',\ |
_isupper,'isupper',\ |
_iswalnum,'iswalnum',\ |
_iswalpha,'iswalpha',\ |
_iswblank,'iswblank',\ |
_iswcntrl,'iswcntrl',\ |
_iswctype,'iswctype',\ |
_iswdigit,'iswdigit',\ |
_iswgraph,'iswgraph',\ |
_iswlower,'iswlower',\ |
_iswprint,'iswprint',\ |
_iswpunct,'iswpunct',\ |
_iswspace,'iswspace',\ |
_iswupper,'iswupper',\ |
_iswxdigit,'iswxdigit',\ |
_isxdigit,'isxdigit',\ |
_j0,'j0',\ |
_j0f,'j0f',\ |
_j1,'j1',\ |
_j1f,'j1f',\ |
_jn,'jn',\ |
_jnf,'jnf',\ |
_ldexp,'ldexp',\ |
_ldexpf,'ldexpf',\ |
_lgamma,'lgamma',\ |
_lgamma_r,'lgamma_r',\ |
_lgammaf,'lgammaf',\ |
_lgammaf_r,'lgammaf_r',\ |
_libc_crt_startup,'libc_crt_startup',\ |
_link_app,'link_app',\ |
_link_image,'link_image',\ |
_llrint,'llrint',\ |
_llrintf,'llrintf',\ |
_llrintl,'llrintl',\ |
_llround,'llround',\ |
_llroundf,'llroundf',\ |
_load_library,'load_library',\ |
_loader_env,'loader_env',\ |
_localeconv,'localeconv',\ |
_localtime,'localtime',\ |
_localtime_r,'localtime_r',\ |
_log,'log',\ |
_log10,'log10',\ |
_log10f,'log10f',\ |
_log1p,'log1p',\ |
_log1pf,'log1pf',\ |
_log2,'log2',\ |
_log2f,'log2f',\ |
_logb,'logb',\ |
_logbf,'logbf',\ |
_logf,'logf',\ |
_longjmp,'longjmp',\ |
_lrint,'lrint',\ |
_lrintf,'lrintf',\ |
_lrintl,'lrintl',\ |
_lround,'lround',\ |
_lroundf,'lroundf',\ |
_lseek,'lseek',\ |
_malloc,'malloc',\ |
_matherr,'matherr',\ |
_mbrtowc,'mbrtowc',\ |
_mbtowc,'mbtowc',\ |
_memalign,'memalign',\ |
_memchr,'memchr',\ |
_memcmp,'memcmp',\ |
_memcpy,'memcpy',\ |
_memmove,'memmove',\ |
_memset,'memset',\ |
_mktime,'mktime',\ |
_modf,'modf',\ |
_modff,'modff',\ |
_nan,'nan',\ |
_nanf,'nanf',\ |
_nearbyint,'nearbyint',\ |
_nearbyintf,'nearbyintf',\ |
_nextafter,'nextafter',\ |
_nextafterf,'nextafterf',\ |
_open,'open',\ |
_path_list,'path_list',\ |
_pow,'pow',\ |
_pow10,'pow10',\ |
_pow10f,'pow10f',\ |
_powf,'powf',\ |
_printf,'printf',\ |
_putc,'putc',\ |
_putchar,'putchar',\ |
_puts,'puts',\ |
_qsort,'qsort',\ |
_raise,'raise',\ |
_rand,'rand',\ |
_rand_r,'rand_r',\ |
_read,'read',\ |
_read_file,'read_file',\ |
_realloc,'realloc',\ |
_remainder,'remainder',\ |
_remainderf,'remainderf',\ |
_remove,'remove',\ |
_remquo,'remquo',\ |
_remquof,'remquof',\ |
_rename,'rename',\ |
_rint,'rint',\ |
_rintf,'rintf',\ |
_rintl,'rintl',\ |
_round,'round',\ |
_roundf,'roundf',\ |
_scalb,'scalb',\ |
_scalbf,'scalbf',\ |
_scalbln,'scalbln',\ |
_scalblnf,'scalblnf',\ |
_scalbn,'scalbn',\ |
_scalbnf,'scalbnf',\ |
_seed48,'seed48',\ |
_set_file_size,'set_file_size',\ |
_setjmp,'setjmp',\ |
_setlocale,'setlocale',\ |
_setvbuf,'setvbuf',\ |
_signal,'signal',\ |
_significand,'significand',\ |
_significandf,'significandf',\ |
_sin,'sin',\ |
_sincos,'sincos',\ |
_sincosf,'sincosf',\ |
_sinf,'sinf',\ |
_sinh,'sinh',\ |
_sinhf,'sinhf',\ |
_siprintf,'siprintf',\ |
_sniprintf,'sniprintf',\ |
_snprintf,'snprintf',\ |
_sprintf,'sprintf',\ |
_sqrt,'sqrt',\ |
_sqrtf,'sqrtf',\ |
_srand,'srand',\ |
_srand48,'srand48',\ |
_sscanf,'sscanf',\ |
_stpcpy,'stpcpy',\ |
_stpncpy,'stpncpy',\ |
_strcasecmp,'strcasecmp',\ |
_strcasestr,'strcasestr',\ |
_strcat,'strcat',\ |
_strchr,'strchr',\ |
_strcmp,'strcmp',\ |
_strcoll,'strcoll',\ |
_strcpy,'strcpy',\ |
_strcspn,'strcspn',\ |
_strdup,'strdup',\ |
_strerror,'strerror',\ |
_strftime,'strftime',\ |
_strlen,'strlen',\ |
_strncasecmp,'strncasecmp',\ |
_strncat,'strncat',\ |
_strncmp,'strncmp',\ |
_strncpy,'strncpy',\ |
_strndup,'strndup',\ |
_strnlen,'strnlen',\ |
_strpbrk,'strpbrk',\ |
_strrchr,'strrchr',\ |
_strsep,'strsep',\ |
_strspn,'strspn',\ |
_strstr,'strstr',\ |
_strtod,'strtod',\ |
_strtof,'strtof',\ |
_strtok,'strtok',\ |
_strtok_r,'strtok_r',\ |
_strtol,'strtol',\ |
_strtoll,'strtoll',\ |
_strtoul,'strtoul',\ |
_strtoull,'strtoull',\ |
_strupr,'strupr',\ |
_system,'system',\ |
_tan,'tan',\ |
_tanf,'tanf',\ |
_tanh,'tanh',\ |
_tanhf,'tanhf',\ |
_tempnam,'tempnam',\ |
_tgamma,'tgamma',\ |
_tgammaf,'tgammaf',\ |
_time,'time',\ |
_tls_alloc,'tls_alloc',\ |
_tmpfile,'tmpfile',\ |
_tmpnam,'tmpnam',\ |
_toascii,'toascii',\ |
_tolower,'tolower',\ |
_toupper,'toupper',\ |
_towctrans,'towctrans',\ |
_towlower,'towlower',\ |
_towupper,'towupper',\ |
_trunc,'trunc',\ |
_truncf,'truncf',\ |
_ungetc,'ungetc',\ |
_user_alloc,'user_alloc',\ |
_validate_pe,'validate_pe',\ |
_vasniprintf,'vasniprintf',\ |
_vasnprintf,'vasnprintf',\ |
_vdiprintf,'vdiprintf',\ |
_vdprintf,'vdprintf',\ |
_vfiprintf,'vfiprintf',\ |
_vfiscanf,'vfiscanf',\ |
_vfprintf,'vfprintf',\ |
_vfscanf,'vfscanf',\ |
_vscanf,'vscanf',\ |
_vsnprintf,'vsnprintf',\ |
_vsprintf,'vsprintf',\ |
_vsscanf,'vsscanf',\ |
_wcrtomb,'wcrtomb',\ |
_wctrans,'wctrans',\ |
_wctype,'wctype',\ |
_write,'write',\ |
_write_file,'write_file',\ |
_y0,'y0',\ |
_y0f,'y0f',\ |
_y1,'y1',\ |
_y1f,'y1f',\ |
_yn,'yn',\ |
_ynf,'ynf' |
/contrib/sdk/sources/libc/sdk/fasm/include/libfreetype.inc |
---|
0,0 → 1,348 |
import libfreetype,\ |
FTC_CMapCache_Lookup,'FTC_CMapCache_Lookup',\ |
FTC_CMapCache_New,'FTC_CMapCache_New',\ |
FTC_ImageCache_Lookup,'FTC_ImageCache_Lookup',\ |
FTC_ImageCache_LookupScaler,'FTC_ImageCache_LookupScaler',\ |
FTC_ImageCache_New,'FTC_ImageCache_New',\ |
FTC_Manager_Done,'FTC_Manager_Done',\ |
FTC_Manager_LookupFace,'FTC_Manager_LookupFace',\ |
FTC_Manager_LookupSize,'FTC_Manager_LookupSize',\ |
FTC_Manager_New,'FTC_Manager_New',\ |
FTC_Manager_RemoveFaceID,'FTC_Manager_RemoveFaceID',\ |
FTC_Manager_Reset,'FTC_Manager_Reset',\ |
FTC_Node_Unref,'FTC_Node_Unref',\ |
FTC_SBitCache_Lookup,'FTC_SBitCache_Lookup',\ |
FTC_SBitCache_LookupScaler,'FTC_SBitCache_LookupScaler',\ |
FTC_SBitCache_New,'FTC_SBitCache_New',\ |
FT_Activate_Size,'FT_Activate_Size',\ |
FT_Add_Default_Modules,'FT_Add_Default_Modules',\ |
FT_Add_Module,'FT_Add_Module',\ |
FT_Angle_Diff,'FT_Angle_Diff',\ |
FT_Atan2,'FT_Atan2',\ |
FT_Attach_File,'FT_Attach_File',\ |
FT_Attach_Stream,'FT_Attach_Stream',\ |
FT_Bitmap_Convert,'FT_Bitmap_Convert',\ |
FT_Bitmap_Copy,'FT_Bitmap_Copy',\ |
FT_Bitmap_Done,'FT_Bitmap_Done',\ |
FT_Bitmap_Embolden,'FT_Bitmap_Embolden',\ |
FT_Bitmap_New,'FT_Bitmap_New',\ |
FT_CMap_Done,'FT_CMap_Done',\ |
FT_CMap_New,'FT_CMap_New',\ |
FT_CeilFix,'FT_CeilFix',\ |
FT_ClassicKern_Free,'FT_ClassicKern_Free',\ |
FT_ClassicKern_Validate,'FT_ClassicKern_Validate',\ |
FT_Cos,'FT_Cos',\ |
FT_DivFix,'FT_DivFix',\ |
FT_Done_Face,'FT_Done_Face',\ |
FT_Done_FreeType,'FT_Done_FreeType',\ |
FT_Done_Glyph,'FT_Done_Glyph',\ |
FT_Done_GlyphSlot,'FT_Done_GlyphSlot',\ |
FT_Done_Library,'FT_Done_Library',\ |
FT_Done_Memory,'FT_Done_Memory',\ |
FT_Done_Size,'FT_Done_Size',\ |
FT_Face_CheckTrueTypePatents,'FT_Face_CheckTrueTypePatents',\ |
FT_Face_GetCharVariantIndex,'FT_Face_GetCharVariantIndex',\ |
FT_Face_GetCharVariantIsDefault,'FT_Face_GetCharVariantIsDefault',\ |
FT_Face_GetCharsOfVariant,'FT_Face_GetCharsOfVariant',\ |
FT_Face_GetVariantSelectors,'FT_Face_GetVariantSelectors',\ |
FT_Face_GetVariantsOfChar,'FT_Face_GetVariantsOfChar',\ |
FT_Face_SetUnpatentedHinting,'FT_Face_SetUnpatentedHinting',\ |
FT_FloorFix,'FT_FloorFix',\ |
FT_Get_Advance,'FT_Get_Advance',\ |
FT_Get_Advances,'FT_Get_Advances',\ |
FT_Get_BDF_Charset_ID,'FT_Get_BDF_Charset_ID',\ |
FT_Get_BDF_Property,'FT_Get_BDF_Property',\ |
FT_Get_CID_From_Glyph_Index,'FT_Get_CID_From_Glyph_Index',\ |
FT_Get_CID_Is_Internally_CID_Keyed,'FT_Get_CID_Is_Internally_CID_Keyed',\ |
FT_Get_CID_Registry_Ordering_Supplement,'FT_Get_CID_Registry_Ordering_Supplement',\ |
FT_Get_CMap_Format,'FT_Get_CMap_Format',\ |
FT_Get_CMap_Language_ID,'FT_Get_CMap_Language_ID',\ |
FT_Get_Char_Index,'FT_Get_Char_Index',\ |
FT_Get_Charmap_Index,'FT_Get_Charmap_Index',\ |
FT_Get_FSType_Flags,'FT_Get_FSType_Flags',\ |
FT_Get_First_Char,'FT_Get_First_Char',\ |
FT_Get_Gasp,'FT_Get_Gasp',\ |
FT_Get_Glyph,'FT_Get_Glyph',\ |
FT_Get_Glyph_Name,'FT_Get_Glyph_Name',\ |
FT_Get_Kerning,'FT_Get_Kerning',\ |
FT_Get_MM_Var,'FT_Get_MM_Var',\ |
FT_Get_Module,'FT_Get_Module',\ |
FT_Get_Module_Interface,'FT_Get_Module_Interface',\ |
FT_Get_Multi_Master,'FT_Get_Multi_Master',\ |
FT_Get_Name_Index,'FT_Get_Name_Index',\ |
FT_Get_Next_Char,'FT_Get_Next_Char',\ |
FT_Get_PFR_Advance,'FT_Get_PFR_Advance',\ |
FT_Get_PFR_Kerning,'FT_Get_PFR_Kerning',\ |
FT_Get_PFR_Metrics,'FT_Get_PFR_Metrics',\ |
FT_Get_PS_Font_Info,'FT_Get_PS_Font_Info',\ |
FT_Get_PS_Font_Private,'FT_Get_PS_Font_Private',\ |
FT_Get_PS_Font_Value,'FT_Get_PS_Font_Value',\ |
FT_Get_Postscript_Name,'FT_Get_Postscript_Name',\ |
FT_Get_Renderer,'FT_Get_Renderer',\ |
FT_Get_Sfnt_Name,'FT_Get_Sfnt_Name',\ |
FT_Get_Sfnt_Name_Count,'FT_Get_Sfnt_Name_Count',\ |
FT_Get_Sfnt_Table,'FT_Get_Sfnt_Table',\ |
FT_Get_SubGlyph_Info,'FT_Get_SubGlyph_Info',\ |
FT_Get_Track_Kerning,'FT_Get_Track_Kerning',\ |
FT_Get_TrueType_Engine_Type,'FT_Get_TrueType_Engine_Type',\ |
FT_GlyphLoader_Add,'FT_GlyphLoader_Add',\ |
FT_GlyphLoader_CheckPoints,'FT_GlyphLoader_CheckPoints',\ |
FT_GlyphLoader_CheckSubGlyphs,'FT_GlyphLoader_CheckSubGlyphs',\ |
FT_GlyphLoader_CopyPoints,'FT_GlyphLoader_CopyPoints',\ |
FT_GlyphLoader_CreateExtra,'FT_GlyphLoader_CreateExtra',\ |
FT_GlyphLoader_Done,'FT_GlyphLoader_Done',\ |
FT_GlyphLoader_New,'FT_GlyphLoader_New',\ |
FT_GlyphLoader_Prepare,'FT_GlyphLoader_Prepare',\ |
FT_GlyphLoader_Reset,'FT_GlyphLoader_Reset',\ |
FT_GlyphLoader_Rewind,'FT_GlyphLoader_Rewind',\ |
FT_GlyphSlot_Embolden,'FT_GlyphSlot_Embolden',\ |
FT_GlyphSlot_Oblique,'FT_GlyphSlot_Oblique',\ |
FT_GlyphSlot_Own_Bitmap,'FT_GlyphSlot_Own_Bitmap',\ |
FT_Glyph_Copy,'FT_Glyph_Copy',\ |
FT_Glyph_Get_CBox,'FT_Glyph_Get_CBox',\ |
FT_Glyph_Stroke,'FT_Glyph_Stroke',\ |
FT_Glyph_StrokeBorder,'FT_Glyph_StrokeBorder',\ |
FT_Glyph_To_Bitmap,'FT_Glyph_To_Bitmap',\ |
FT_Glyph_Transform,'FT_Glyph_Transform',\ |
FT_Has_PS_Glyph_Names,'FT_Has_PS_Glyph_Names',\ |
FT_Hypot,'FT_Hypot',\ |
FT_Init_FreeType,'FT_Init_FreeType',\ |
FT_Library_SetLcdFilter,'FT_Library_SetLcdFilter',\ |
FT_Library_SetLcdFilterWeights,'FT_Library_SetLcdFilterWeights',\ |
FT_Library_Version,'FT_Library_Version',\ |
FT_List_Add,'FT_List_Add',\ |
FT_List_Finalize,'FT_List_Finalize',\ |
FT_List_Find,'FT_List_Find',\ |
FT_List_Insert,'FT_List_Insert',\ |
FT_List_Iterate,'FT_List_Iterate',\ |
FT_List_Remove,'FT_List_Remove',\ |
FT_List_Up,'FT_List_Up',\ |
FT_Load_Char,'FT_Load_Char',\ |
FT_Load_Glyph,'FT_Load_Glyph',\ |
FT_Load_Sfnt_Table,'FT_Load_Sfnt_Table',\ |
FT_Lookup_Renderer,'FT_Lookup_Renderer',\ |
FT_MSB,'FT_MSB',\ |
FT_Match_Size,'FT_Match_Size',\ |
FT_Matrix_Invert,'FT_Matrix_Invert',\ |
FT_Matrix_Multiply,'FT_Matrix_Multiply',\ |
FT_Matrix_Multiply_Scaled,'FT_Matrix_Multiply_Scaled',\ |
FT_MulDiv,'FT_MulDiv',\ |
FT_MulDiv_No_Round,'FT_MulDiv_No_Round',\ |
FT_MulFix,'FT_MulFix',\ |
FT_New_Face,'FT_New_Face',\ |
FT_New_GlyphSlot,'FT_New_GlyphSlot',\ |
FT_New_Library,'FT_New_Library',\ |
FT_New_Memory,'FT_New_Memory',\ |
FT_New_Memory_Face,'FT_New_Memory_Face',\ |
FT_New_Size,'FT_New_Size',\ |
FT_OpenType_Free,'FT_OpenType_Free',\ |
FT_OpenType_Validate,'FT_OpenType_Validate',\ |
FT_Open_Face,'FT_Open_Face',\ |
FT_Outline_Check,'FT_Outline_Check',\ |
FT_Outline_Copy,'FT_Outline_Copy',\ |
FT_Outline_Decompose,'FT_Outline_Decompose',\ |
FT_Outline_Done,'FT_Outline_Done',\ |
FT_Outline_Done_Internal,'FT_Outline_Done_Internal',\ |
FT_Outline_Embolden,'FT_Outline_Embolden',\ |
FT_Outline_EmboldenXY,'FT_Outline_EmboldenXY',\ |
FT_Outline_GetInsideBorder,'FT_Outline_GetInsideBorder',\ |
FT_Outline_GetOutsideBorder,'FT_Outline_GetOutsideBorder',\ |
FT_Outline_Get_BBox,'FT_Outline_Get_BBox',\ |
FT_Outline_Get_Bitmap,'FT_Outline_Get_Bitmap',\ |
FT_Outline_Get_CBox,'FT_Outline_Get_CBox',\ |
FT_Outline_Get_Orientation,'FT_Outline_Get_Orientation',\ |
FT_Outline_New,'FT_Outline_New',\ |
FT_Outline_New_Internal,'FT_Outline_New_Internal',\ |
FT_Outline_Render,'FT_Outline_Render',\ |
FT_Outline_Reverse,'FT_Outline_Reverse',\ |
FT_Outline_Transform,'FT_Outline_Transform',\ |
FT_Outline_Translate,'FT_Outline_Translate',\ |
FT_Property_Get,'FT_Property_Get',\ |
FT_Property_Set,'FT_Property_Set',\ |
FT_Raccess_Get_DataOffsets,'FT_Raccess_Get_DataOffsets',\ |
FT_Raccess_Get_HeaderInfo,'FT_Raccess_Get_HeaderInfo',\ |
FT_Raccess_Guess,'FT_Raccess_Guess',\ |
FT_Reference_Face,'FT_Reference_Face',\ |
FT_Reference_Library,'FT_Reference_Library',\ |
FT_Remove_Module,'FT_Remove_Module',\ |
FT_Render_Glyph,'FT_Render_Glyph',\ |
FT_Render_Glyph_Internal,'FT_Render_Glyph_Internal',\ |
FT_Request_Metrics,'FT_Request_Metrics',\ |
FT_Request_Size,'FT_Request_Size',\ |
FT_RoundFix,'FT_RoundFix',\ |
FT_Select_Charmap,'FT_Select_Charmap',\ |
FT_Select_Metrics,'FT_Select_Metrics',\ |
FT_Select_Size,'FT_Select_Size',\ |
FT_Set_Char_Size,'FT_Set_Char_Size',\ |
FT_Set_Charmap,'FT_Set_Charmap',\ |
FT_Set_Debug_Hook,'FT_Set_Debug_Hook',\ |
FT_Set_MM_Blend_Coordinates,'FT_Set_MM_Blend_Coordinates',\ |
FT_Set_MM_Design_Coordinates,'FT_Set_MM_Design_Coordinates',\ |
FT_Set_Pixel_Sizes,'FT_Set_Pixel_Sizes',\ |
FT_Set_Renderer,'FT_Set_Renderer',\ |
FT_Set_Transform,'FT_Set_Transform',\ |
FT_Set_Var_Blend_Coordinates,'FT_Set_Var_Blend_Coordinates',\ |
FT_Set_Var_Design_Coordinates,'FT_Set_Var_Design_Coordinates',\ |
FT_Sfnt_Table_Info,'FT_Sfnt_Table_Info',\ |
FT_Sin,'FT_Sin',\ |
FT_SqrtFixed,'FT_SqrtFixed',\ |
FT_Stream_Close,'FT_Stream_Close',\ |
FT_Stream_EnterFrame,'FT_Stream_EnterFrame',\ |
FT_Stream_ExitFrame,'FT_Stream_ExitFrame',\ |
FT_Stream_ExtractFrame,'FT_Stream_ExtractFrame',\ |
FT_Stream_Free,'FT_Stream_Free',\ |
FT_Stream_GetChar,'FT_Stream_GetChar',\ |
FT_Stream_GetULong,'FT_Stream_GetULong',\ |
FT_Stream_GetULongLE,'FT_Stream_GetULongLE',\ |
FT_Stream_GetUOffset,'FT_Stream_GetUOffset',\ |
FT_Stream_GetUShort,'FT_Stream_GetUShort',\ |
FT_Stream_GetUShortLE,'FT_Stream_GetUShortLE',\ |
FT_Stream_New,'FT_Stream_New',\ |
FT_Stream_Open,'FT_Stream_Open',\ |
FT_Stream_OpenBzip2,'FT_Stream_OpenBzip2',\ |
FT_Stream_OpenGzip,'FT_Stream_OpenGzip',\ |
FT_Stream_OpenLZW,'FT_Stream_OpenLZW',\ |
FT_Stream_OpenMemory,'FT_Stream_OpenMemory',\ |
FT_Stream_Pos,'FT_Stream_Pos',\ |
FT_Stream_Read,'FT_Stream_Read',\ |
FT_Stream_ReadAt,'FT_Stream_ReadAt',\ |
FT_Stream_ReadChar,'FT_Stream_ReadChar',\ |
FT_Stream_ReadFields,'FT_Stream_ReadFields',\ |
FT_Stream_ReadULong,'FT_Stream_ReadULong',\ |
FT_Stream_ReadULongLE,'FT_Stream_ReadULongLE',\ |
FT_Stream_ReadUOffset,'FT_Stream_ReadUOffset',\ |
FT_Stream_ReadUShort,'FT_Stream_ReadUShort',\ |
FT_Stream_ReadUShortLE,'FT_Stream_ReadUShortLE',\ |
FT_Stream_ReleaseFrame,'FT_Stream_ReleaseFrame',\ |
FT_Stream_Seek,'FT_Stream_Seek',\ |
FT_Stream_Skip,'FT_Stream_Skip',\ |
FT_Stream_TryRead,'FT_Stream_TryRead',\ |
FT_Stroker_BeginSubPath,'FT_Stroker_BeginSubPath',\ |
FT_Stroker_ConicTo,'FT_Stroker_ConicTo',\ |
FT_Stroker_CubicTo,'FT_Stroker_CubicTo',\ |
FT_Stroker_Done,'FT_Stroker_Done',\ |
FT_Stroker_EndSubPath,'FT_Stroker_EndSubPath',\ |
FT_Stroker_Export,'FT_Stroker_Export',\ |
FT_Stroker_ExportBorder,'FT_Stroker_ExportBorder',\ |
FT_Stroker_GetBorderCounts,'FT_Stroker_GetBorderCounts',\ |
FT_Stroker_GetCounts,'FT_Stroker_GetCounts',\ |
FT_Stroker_LineTo,'FT_Stroker_LineTo',\ |
FT_Stroker_New,'FT_Stroker_New',\ |
FT_Stroker_ParseOutline,'FT_Stroker_ParseOutline',\ |
FT_Stroker_Rewind,'FT_Stroker_Rewind',\ |
FT_Stroker_Set,'FT_Stroker_Set',\ |
FT_Tan,'FT_Tan',\ |
FT_Trace_Get_Count,'FT_Trace_Get_Count',\ |
FT_Trace_Get_Name,'FT_Trace_Get_Name',\ |
FT_TrueTypeGX_Free,'FT_TrueTypeGX_Free',\ |
FT_TrueTypeGX_Validate,'FT_TrueTypeGX_Validate',\ |
FT_Vector_From_Polar,'FT_Vector_From_Polar',\ |
FT_Vector_Length,'FT_Vector_Length',\ |
FT_Vector_Polarize,'FT_Vector_Polarize',\ |
FT_Vector_Rotate,'FT_Vector_Rotate',\ |
FT_Vector_Transform,'FT_Vector_Transform',\ |
FT_Vector_Transform_Scaled,'FT_Vector_Transform_Scaled',\ |
FT_Vector_Unit,'FT_Vector_Unit',\ |
TT_New_Context,'TT_New_Context',\ |
TT_RunIns,'TT_RunIns',\ |
af_autofitter_interface,'af_autofitter_interface',\ |
af_cjk_script_class,'af_cjk_script_class',\ |
af_dummy_script_class,'af_dummy_script_class',\ |
af_glyph_hints_dump_edges,'af_glyph_hints_dump_edges',\ |
af_glyph_hints_dump_points,'af_glyph_hints_dump_points',\ |
af_glyph_hints_dump_segments,'af_glyph_hints_dump_segments',\ |
af_glyph_hints_get_num_segments,'af_glyph_hints_get_num_segments',\ |
af_glyph_hints_get_segment_offset,'af_glyph_hints_get_segment_offset',\ |
af_indic_script_class,'af_indic_script_class',\ |
af_latin_script_class,'af_latin_script_class',\ |
af_property_get,'af_property_get',\ |
af_property_get_face_globals,'af_property_get_face_globals',\ |
af_property_set,'af_property_set',\ |
afm_parser_funcs,'afm_parser_funcs',\ |
autofit_module_class,'autofit_module_class',\ |
bdf_cmap_class,'bdf_cmap_class',\ |
bdf_driver_class,'bdf_driver_class',\ |
cff_cmap_encoding_class_rec,'cff_cmap_encoding_class_rec',\ |
cff_cmap_unicode_class_rec,'cff_cmap_unicode_class_rec',\ |
cff_driver_class,'cff_driver_class',\ |
ft_bitmap_glyph_class,'ft_bitmap_glyph_class',\ |
ft_corner_is_flat,'ft_corner_is_flat',\ |
ft_corner_orientation,'ft_corner_orientation',\ |
ft_debug_init,'ft_debug_init',\ |
ft_glyphslot_alloc_bitmap,'ft_glyphslot_alloc_bitmap',\ |
ft_glyphslot_free_bitmap,'ft_glyphslot_free_bitmap',\ |
ft_glyphslot_set_bitmap,'ft_glyphslot_set_bitmap',\ |
ft_gray_for_premultiplied_srgb_bgra,'ft_gray_for_premultiplied_srgb_bgra',\ |
ft_grays_raster,'ft_grays_raster',\ |
ft_highpow2,'ft_highpow2',\ |
ft_lzwstate_done,'ft_lzwstate_done',\ |
ft_lzwstate_init,'ft_lzwstate_init',\ |
ft_lzwstate_io,'ft_lzwstate_io',\ |
ft_lzwstate_reset,'ft_lzwstate_reset',\ |
ft_mem_alloc,'ft_mem_alloc',\ |
ft_mem_dup,'ft_mem_dup',\ |
ft_mem_free,'ft_mem_free',\ |
ft_mem_qalloc,'ft_mem_qalloc',\ |
ft_mem_qrealloc,'ft_mem_qrealloc',\ |
ft_mem_realloc,'ft_mem_realloc',\ |
ft_mem_strcpyn,'ft_mem_strcpyn',\ |
ft_mem_strdup,'ft_mem_strdup',\ |
ft_module_get_service,'ft_module_get_service',\ |
ft_outline_glyph_class,'ft_outline_glyph_class',\ |
ft_property_do,'ft_property_do',\ |
ft_raccess_guess_table,'ft_raccess_guess_table',\ |
ft_raster1_renderer_class,'ft_raster1_renderer_class',\ |
ft_raster5_renderer_class,'ft_raster5_renderer_class',\ |
ft_service_list_lookup,'ft_service_list_lookup',\ |
ft_smooth_lcd_renderer_class,'ft_smooth_lcd_renderer_class',\ |
ft_smooth_lcdv_renderer_class,'ft_smooth_lcdv_renderer_class',\ |
ft_smooth_renderer_class,'ft_smooth_renderer_class',\ |
ft_standard_raster,'ft_standard_raster',\ |
ft_synthesize_vertical_metrics,'ft_synthesize_vertical_metrics',\ |
ft_validator_error,'ft_validator_error',\ |
ft_validator_init,'ft_validator_init',\ |
ft_validator_run,'ft_validator_run',\ |
ftc_basic_image_cache_class,'ftc_basic_image_cache_class',\ |
ftc_basic_image_family_class,'ftc_basic_image_family_class',\ |
ftc_basic_sbit_cache_class,'ftc_basic_sbit_cache_class',\ |
ftc_basic_sbit_family_class,'ftc_basic_sbit_family_class',\ |
ftc_cmap_cache_class,'ftc_cmap_cache_class',\ |
ftc_face_list_class,'ftc_face_list_class',\ |
ftc_size_list_class,'ftc_size_list_class',\ |
longjmp,'longjmp',\ |
otv_module_class,'otv_module_class',\ |
pcf_cmap_class,'pcf_cmap_class',\ |
pcf_driver_class,'pcf_driver_class',\ |
pfr_cmap_class_rec,'pfr_cmap_class_rec',\ |
pfr_driver_class,'pfr_driver_class',\ |
pfr_metrics_service_rec,'pfr_metrics_service_rec',\ |
ps_hints_apply,'ps_hints_apply',\ |
ps_parser_funcs,'ps_parser_funcs',\ |
ps_table_funcs,'ps_table_funcs',\ |
psaux_module_class,'psaux_module_class',\ |
pshinter_module_class,'pshinter_module_class',\ |
psnames_module_class,'psnames_module_class',\ |
setjmp,'setjmp',\ |
sfnt_module_class,'sfnt_module_class',\ |
t1_builder_funcs,'t1_builder_funcs',\ |
t1_cmap_classes,'t1_cmap_classes',\ |
t1_cmap_custom_class_rec,'t1_cmap_custom_class_rec',\ |
t1_cmap_expert_class_rec,'t1_cmap_expert_class_rec',\ |
t1_cmap_standard_class_rec,'t1_cmap_standard_class_rec',\ |
t1_cmap_unicode_class_rec,'t1_cmap_unicode_class_rec',\ |
t1_decoder_funcs,'t1_decoder_funcs',\ |
t1_driver_class,'t1_driver_class',\ |
t1cid_driver_class,'t1cid_driver_class',\ |
t42_driver_class,'t42_driver_class',\ |
tt_cmap0_class_rec,'tt_cmap0_class_rec',\ |
tt_cmap10_class_rec,'tt_cmap10_class_rec',\ |
tt_cmap12_class_rec,'tt_cmap12_class_rec',\ |
tt_cmap13_class_rec,'tt_cmap13_class_rec',\ |
tt_cmap14_class_rec,'tt_cmap14_class_rec',\ |
tt_cmap2_class_rec,'tt_cmap2_class_rec',\ |
tt_cmap4_class_rec,'tt_cmap4_class_rec',\ |
tt_cmap6_class_rec,'tt_cmap6_class_rec',\ |
tt_cmap8_class_rec,'tt_cmap8_class_rec',\ |
tt_default_graphics_state,'tt_default_graphics_state',\ |
tt_driver_class,'tt_driver_class',\ |
winfnt_driver_class,'winfnt_driver_class' |
/contrib/sdk/sources/libc/sdk/fasm/include/libmpg123.inc |
---|
0,0 → 1,113 |
import libmpg123,\ |
mpg123_add_string,'mpg123_add_string',\ |
mpg123_add_substring,'mpg123_add_substring',\ |
mpg123_chomp_string,'mpg123_chomp_string',\ |
mpg123_clip,'mpg123_clip',\ |
mpg123_close,'mpg123_close',\ |
mpg123_copy_string,'mpg123_copy_string',\ |
mpg123_current_decoder,'mpg123_current_decoder',\ |
mpg123_decode,'mpg123_decode',\ |
mpg123_decode_frame,'mpg123_decode_frame',\ |
mpg123_decode_frame_32,'mpg123_decode_frame_32',\ |
mpg123_decoder,'mpg123_decoder',\ |
mpg123_decoders,'mpg123_decoders',\ |
mpg123_delete,'mpg123_delete',\ |
mpg123_delete_pars,'mpg123_delete_pars',\ |
mpg123_enc_from_id3,'mpg123_enc_from_id3',\ |
mpg123_encodings,'mpg123_encodings',\ |
mpg123_encsize,'mpg123_encsize',\ |
mpg123_eq,'mpg123_eq',\ |
mpg123_errcode,'mpg123_errcode',\ |
mpg123_exit,'mpg123_exit',\ |
mpg123_feature,'mpg123_feature',\ |
mpg123_feed,'mpg123_feed',\ |
mpg123_feedseek,'mpg123_feedseek',\ |
mpg123_feedseek_32,'mpg123_feedseek_32',\ |
mpg123_fmt,'mpg123_fmt',\ |
mpg123_fmt_all,'mpg123_fmt_all',\ |
mpg123_fmt_none,'mpg123_fmt_none',\ |
mpg123_fmt_support,'mpg123_fmt_support',\ |
mpg123_format,'mpg123_format',\ |
mpg123_format_all,'mpg123_format_all',\ |
mpg123_format_none,'mpg123_format_none',\ |
mpg123_format_support,'mpg123_format_support',\ |
mpg123_framebyframe_decode,'mpg123_framebyframe_decode',\ |
mpg123_framebyframe_decode_32,'mpg123_framebyframe_decode_32',\ |
mpg123_framebyframe_next,'mpg123_framebyframe_next',\ |
mpg123_framedata,'mpg123_framedata',\ |
mpg123_framepos,'mpg123_framepos',\ |
mpg123_framepos_32,'mpg123_framepos_32',\ |
mpg123_free_string,'mpg123_free_string',\ |
mpg123_geteq,'mpg123_geteq',\ |
mpg123_getformat,'mpg123_getformat',\ |
mpg123_getpar,'mpg123_getpar',\ |
mpg123_getparam,'mpg123_getparam',\ |
mpg123_getstate,'mpg123_getstate',\ |
mpg123_getvolume,'mpg123_getvolume',\ |
mpg123_grow_string,'mpg123_grow_string',\ |
mpg123_icy,'mpg123_icy',\ |
mpg123_icy2utf8,'mpg123_icy2utf8',\ |
mpg123_id3,'mpg123_id3',\ |
mpg123_index,'mpg123_index',\ |
mpg123_index_32,'mpg123_index_32',\ |
mpg123_info,'mpg123_info',\ |
mpg123_init,'mpg123_init',\ |
mpg123_init_string,'mpg123_init_string',\ |
mpg123_length,'mpg123_length',\ |
mpg123_length_32,'mpg123_length_32',\ |
mpg123_meta_check,'mpg123_meta_check',\ |
mpg123_meta_free,'mpg123_meta_free',\ |
mpg123_new,'mpg123_new',\ |
mpg123_new_pars,'mpg123_new_pars',\ |
mpg123_noise,'mpg123_noise',\ |
mpg123_open,'mpg123_open',\ |
mpg123_open_32,'mpg123_open_32',\ |
mpg123_open_fd,'mpg123_open_fd',\ |
mpg123_open_fd_32,'mpg123_open_fd_32',\ |
mpg123_open_feed,'mpg123_open_feed',\ |
mpg123_open_handle,'mpg123_open_handle',\ |
mpg123_open_handle_32,'mpg123_open_handle_32',\ |
mpg123_outblock,'mpg123_outblock',\ |
mpg123_par,'mpg123_par',\ |
mpg123_param,'mpg123_param',\ |
mpg123_parnew,'mpg123_parnew',\ |
mpg123_plain_strerror,'mpg123_plain_strerror',\ |
mpg123_position,'mpg123_position',\ |
mpg123_position_32,'mpg123_position_32',\ |
mpg123_rates,'mpg123_rates',\ |
mpg123_read,'mpg123_read',\ |
mpg123_replace_buffer,'mpg123_replace_buffer',\ |
mpg123_replace_reader,'mpg123_replace_reader',\ |
mpg123_replace_reader_32,'mpg123_replace_reader_32',\ |
mpg123_replace_reader_handle,'mpg123_replace_reader_handle',\ |
mpg123_replace_reader_handle_32,'mpg123_replace_reader_handle_32',\ |
mpg123_reset_eq,'mpg123_reset_eq',\ |
mpg123_resize_string,'mpg123_resize_string',\ |
mpg123_safe_buffer,'mpg123_safe_buffer',\ |
mpg123_scan,'mpg123_scan',\ |
mpg123_seek,'mpg123_seek',\ |
mpg123_seek_32,'mpg123_seek_32',\ |
mpg123_seek_frame,'mpg123_seek_frame',\ |
mpg123_seek_frame_32,'mpg123_seek_frame_32',\ |
mpg123_set_filesize,'mpg123_set_filesize',\ |
mpg123_set_filesize_32,'mpg123_set_filesize_32',\ |
mpg123_set_index,'mpg123_set_index',\ |
mpg123_set_index_32,'mpg123_set_index_32',\ |
mpg123_set_string,'mpg123_set_string',\ |
mpg123_set_substring,'mpg123_set_substring',\ |
mpg123_spf,'mpg123_spf',\ |
mpg123_store_utf8,'mpg123_store_utf8',\ |
mpg123_strerror,'mpg123_strerror',\ |
mpg123_strlen,'mpg123_strlen',\ |
mpg123_supported_decoders,'mpg123_supported_decoders',\ |
mpg123_tell,'mpg123_tell',\ |
mpg123_tell_32,'mpg123_tell_32',\ |
mpg123_tell_stream,'mpg123_tell_stream',\ |
mpg123_tell_stream_32,'mpg123_tell_stream_32',\ |
mpg123_tellframe,'mpg123_tellframe',\ |
mpg123_tellframe_32,'mpg123_tellframe_32',\ |
mpg123_timeframe,'mpg123_timeframe',\ |
mpg123_timeframe_32,'mpg123_timeframe_32',\ |
mpg123_tpf,'mpg123_tpf',\ |
mpg123_volume,'mpg123_volume',\ |
mpg123_volume_change,'mpg123_volume_change' |
/contrib/sdk/sources/libc/sdk/fasm/include/libpng.inc |
---|
0,0 → 1,243 |
EXPORTS,'EXPORTS',\ |
import libpng16,\ |
png_access_version_number,'png_access_version_number',\ |
png_set_sig_bytes,'png_set_sig_bytes',\ |
png_sig_cmp,'png_sig_cmp',\ |
png_create_read_struct,'png_create_read_struct',\ |
png_create_write_struct,'png_create_write_struct',\ |
png_get_compression_buffer_size,'png_get_compression_buffer_size',\ |
png_set_compression_buffer_size,'png_set_compression_buffer_size',\ |
png_set_longjmp_fn,'png_set_longjmp_fn',\ |
png_longjmp,'png_longjmp',\ |
png_reset_zstream,'png_reset_zstream',\ |
png_create_read_struct_2,'png_create_read_struct_2',\ |
png_create_write_struct_2,'png_create_write_struct_2',\ |
png_write_sig,'png_write_sig',\ |
png_write_chunk,'png_write_chunk',\ |
png_write_chunk_start,'png_write_chunk_start',\ |
png_write_chunk_data,'png_write_chunk_data',\ |
png_write_chunk_end,'png_write_chunk_end',\ |
png_create_info_struct,'png_create_info_struct',\ |
png_info_init_3,'png_info_init_3',\ |
png_write_info_before_PLTE,'png_write_info_before_PLTE',\ |
png_write_info,'png_write_info',\ |
png_read_info,'png_read_info',\ |
png_convert_to_rfc1123,'png_convert_to_rfc1123',\ |
png_convert_to_rfc1123_buffer,'png_convert_to_rfc1123_buffer',\ |
png_convert_from_struct_tm,'png_convert_from_struct_tm',\ |
png_convert_from_time_t,'png_convert_from_time_t',\ |
png_set_expand,'png_set_expand',\ |
png_set_expand_gray_1_2_4_to_8,'png_set_expand_gray_1_2_4_to_8',\ |
png_set_palette_to_rgb,'png_set_palette_to_rgb',\ |
png_set_tRNS_to_alpha,'png_set_tRNS_to_alpha',\ |
png_set_expand_16,'png_set_expand_16',\ |
png_set_bgr,'png_set_bgr',\ |
png_set_gray_to_rgb,'png_set_gray_to_rgb',\ |
png_set_rgb_to_gray,'png_set_rgb_to_gray',\ |
png_set_rgb_to_gray_fixed,'png_set_rgb_to_gray_fixed',\ |
png_get_rgb_to_gray_status,'png_get_rgb_to_gray_status',\ |
png_build_grayscale_palette,'png_build_grayscale_palette',\ |
png_set_alpha_mode,'png_set_alpha_mode',\ |
png_set_alpha_mode_fixed,'png_set_alpha_mode_fixed',\ |
png_set_strip_alpha,'png_set_strip_alpha',\ |
png_set_swap_alpha,'png_set_swap_alpha',\ |
png_set_invert_alpha,'png_set_invert_alpha',\ |
png_set_filler,'png_set_filler',\ |
png_set_add_alpha,'png_set_add_alpha',\ |
png_set_swap,'png_set_swap',\ |
png_set_packing,'png_set_packing',\ |
png_set_packswap,'png_set_packswap',\ |
png_set_shift,'png_set_shift',\ |
png_set_interlace_handling,'png_set_interlace_handling',\ |
png_set_invert_mono,'png_set_invert_mono',\ |
png_set_background,'png_set_background',\ |
png_set_background_fixed,'png_set_background_fixed',\ |
png_set_scale_16,'png_set_scale_16',\ |
png_set_strip_16,'png_set_strip_16',\ |
png_set_quantize,'png_set_quantize',\ |
png_set_gamma,'png_set_gamma',\ |
png_set_gamma_fixed,'png_set_gamma_fixed',\ |
png_set_flush,'png_set_flush',\ |
png_write_flush,'png_write_flush',\ |
png_start_read_image,'png_start_read_image',\ |
png_read_update_info,'png_read_update_info',\ |
png_read_rows,'png_read_rows',\ |
png_read_row,'png_read_row',\ |
png_read_image,'png_read_image',\ |
png_write_row,'png_write_row',\ |
png_write_rows,'png_write_rows',\ |
png_write_image,'png_write_image',\ |
png_write_end,'png_write_end',\ |
png_read_end,'png_read_end',\ |
png_destroy_info_struct,'png_destroy_info_struct',\ |
png_destroy_read_struct,'png_destroy_read_struct',\ |
png_destroy_write_struct,'png_destroy_write_struct',\ |
png_set_crc_action,'png_set_crc_action',\ |
png_set_filter,'png_set_filter',\ |
png_set_filter_heuristics,'png_set_filter_heuristics',\ |
png_set_filter_heuristics_fixed,'png_set_filter_heuristics_fixed',\ |
png_set_compression_level,'png_set_compression_level',\ |
png_set_compression_mem_level,'png_set_compression_mem_level',\ |
png_set_compression_strategy,'png_set_compression_strategy',\ |
png_set_compression_window_bits,'png_set_compression_window_bits',\ |
png_set_compression_method,'png_set_compression_method',\ |
png_set_text_compression_level,'png_set_text_compression_level',\ |
png_set_text_compression_mem_level,'png_set_text_compression_mem_level',\ |
png_set_text_compression_strategy,'png_set_text_compression_strategy',\ |
png_set_text_compression_window_bits,'png_set_text_compression_window_bits',\ |
png_set_text_compression_method,'png_set_text_compression_method',\ |
png_init_io,'png_init_io',\ |
png_set_error_fn,'png_set_error_fn',\ |
png_get_error_ptr,'png_get_error_ptr',\ |
png_set_write_fn,'png_set_write_fn',\ |
png_set_read_fn,'png_set_read_fn',\ |
png_get_io_ptr,'png_get_io_ptr',\ |
png_set_read_status_fn,'png_set_read_status_fn',\ |
png_set_write_status_fn,'png_set_write_status_fn',\ |
png_set_mem_fn,'png_set_mem_fn',\ |
png_get_mem_ptr,'png_get_mem_ptr',\ |
png_set_read_user_transform_fn,'png_set_read_user_transform_fn',\ |
png_set_write_user_transform_fn,'png_set_write_user_transform_fn',\ |
png_set_user_transform_info,'png_set_user_transform_info',\ |
png_get_user_transform_ptr,'png_get_user_transform_ptr',\ |
png_get_current_row_number,'png_get_current_row_number',\ |
png_get_current_pass_number,'png_get_current_pass_number',\ |
png_set_read_user_chunk_fn,'png_set_read_user_chunk_fn',\ |
png_get_user_chunk_ptr,'png_get_user_chunk_ptr',\ |
png_set_progressive_read_fn,'png_set_progressive_read_fn',\ |
png_get_progressive_ptr,'png_get_progressive_ptr',\ |
png_process_data,'png_process_data',\ |
png_process_data_pause,'png_process_data_pause',\ |
png_process_data_skip,'png_process_data_skip',\ |
png_progressive_combine_row,'png_progressive_combine_row',\ |
png_malloc,'png_malloc',\ |
png_calloc,'png_calloc',\ |
png_malloc_warn,'png_malloc_warn',\ |
png_free,'png_free',\ |
png_free_data,'png_free_data',\ |
png_data_freer,'png_data_freer',\ |
png_malloc_default,'png_malloc_default',\ |
png_free_default,'png_free_default',\ |
png_error,'png_error',\ |
png_chunk_error,'png_chunk_error',\ |
png_warning,'png_warning',\ |
png_chunk_warning,'png_chunk_warning',\ |
png_benign_error,'png_benign_error',\ |
png_chunk_benign_error,'png_chunk_benign_error',\ |
png_set_benign_errors,'png_set_benign_errors',\ |
png_get_valid,'png_get_valid',\ |
png_get_rowbytes,'png_get_rowbytes',\ |
png_get_rows,'png_get_rows',\ |
png_set_rows,'png_set_rows',\ |
png_get_channels,'png_get_channels',\ |
png_get_image_width,'png_get_image_width',\ |
png_get_image_height,'png_get_image_height',\ |
png_get_bit_depth,'png_get_bit_depth',\ |
png_get_color_type,'png_get_color_type',\ |
png_get_filter_type,'png_get_filter_type',\ |
png_get_interlace_type,'png_get_interlace_type',\ |
png_get_compression_type,'png_get_compression_type',\ |
png_get_pixels_per_meter,'png_get_pixels_per_meter',\ |
png_get_x_pixels_per_meter,'png_get_x_pixels_per_meter',\ |
png_get_y_pixels_per_meter,'png_get_y_pixels_per_meter',\ |
png_get_pixel_aspect_ratio,'png_get_pixel_aspect_ratio',\ |
png_get_pixel_aspect_ratio_fixed,'png_get_pixel_aspect_ratio_fixed',\ |
png_get_x_offset_pixels,'png_get_x_offset_pixels',\ |
png_get_y_offset_pixels,'png_get_y_offset_pixels',\ |
png_get_x_offset_microns,'png_get_x_offset_microns',\ |
png_get_y_offset_microns,'png_get_y_offset_microns',\ |
png_get_signature,'png_get_signature',\ |
png_get_bKGD,'png_get_bKGD',\ |
png_set_bKGD,'png_set_bKGD',\ |
png_get_cHRM,'png_get_cHRM',\ |
png_get_cHRM_XYZ,'png_get_cHRM_XYZ',\ |
png_get_cHRM_fixed,'png_get_cHRM_fixed',\ |
png_get_cHRM_XYZ_fixed,'png_get_cHRM_XYZ_fixed',\ |
png_set_cHRM,'png_set_cHRM',\ |
png_set_cHRM_XYZ,'png_set_cHRM_XYZ',\ |
png_set_cHRM_fixed,'png_set_cHRM_fixed',\ |
png_set_cHRM_XYZ_fixed,'png_set_cHRM_XYZ_fixed',\ |
png_get_gAMA,'png_get_gAMA',\ |
png_get_gAMA_fixed,'png_get_gAMA_fixed',\ |
png_set_gAMA,'png_set_gAMA',\ |
png_set_gAMA_fixed,'png_set_gAMA_fixed',\ |
png_get_hIST,'png_get_hIST',\ |
png_set_hIST,'png_set_hIST',\ |
png_get_IHDR,'png_get_IHDR',\ |
png_set_IHDR,'png_set_IHDR',\ |
png_get_oFFs,'png_get_oFFs',\ |
png_set_oFFs,'png_set_oFFs',\ |
png_get_pCAL,'png_get_pCAL',\ |
png_set_pCAL,'png_set_pCAL',\ |
png_get_pHYs,'png_get_pHYs',\ |
png_set_pHYs,'png_set_pHYs',\ |
png_get_PLTE,'png_get_PLTE',\ |
png_set_PLTE,'png_set_PLTE',\ |
png_get_sBIT,'png_get_sBIT',\ |
png_set_sBIT,'png_set_sBIT',\ |
png_get_sRGB,'png_get_sRGB',\ |
png_set_sRGB,'png_set_sRGB',\ |
png_set_sRGB_gAMA_and_cHRM,'png_set_sRGB_gAMA_and_cHRM',\ |
png_get_iCCP,'png_get_iCCP',\ |
png_set_iCCP,'png_set_iCCP',\ |
png_get_sPLT,'png_get_sPLT',\ |
png_set_sPLT,'png_set_sPLT',\ |
png_get_text,'png_get_text',\ |
png_set_text,'png_set_text',\ |
png_get_tIME,'png_get_tIME',\ |
png_set_tIME,'png_set_tIME',\ |
png_get_tRNS,'png_get_tRNS',\ |
png_set_tRNS,'png_set_tRNS',\ |
png_get_sCAL,'png_get_sCAL',\ |
png_get_sCAL_fixed,'png_get_sCAL_fixed',\ |
png_get_sCAL_s,'png_get_sCAL_s',\ |
png_set_sCAL,'png_set_sCAL',\ |
png_set_sCAL_fixed,'png_set_sCAL_fixed',\ |
png_set_sCAL_s,'png_set_sCAL_s',\ |
png_set_keep_unknown_chunks,'png_set_keep_unknown_chunks',\ |
png_handle_as_unknown,'png_handle_as_unknown',\ |
png_set_unknown_chunks,'png_set_unknown_chunks',\ |
png_set_unknown_chunk_location,'png_set_unknown_chunk_location',\ |
png_get_unknown_chunks,'png_get_unknown_chunks',\ |
png_set_invalid,'png_set_invalid',\ |
png_read_png,'png_read_png',\ |
png_write_png,'png_write_png',\ |
png_get_copyright,'png_get_copyright',\ |
png_get_header_ver,'png_get_header_ver',\ |
png_get_header_version,'png_get_header_version',\ |
png_get_libpng_ver,'png_get_libpng_ver',\ |
png_permit_mng_features,'png_permit_mng_features',\ |
png_set_user_limits,'png_set_user_limits',\ |
png_get_user_width_max,'png_get_user_width_max',\ |
png_get_user_height_max,'png_get_user_height_max',\ |
png_set_chunk_cache_max,'png_set_chunk_cache_max',\ |
png_get_chunk_cache_max,'png_get_chunk_cache_max',\ |
png_set_chunk_malloc_max,'png_set_chunk_malloc_max',\ |
png_get_chunk_malloc_max,'png_get_chunk_malloc_max',\ |
png_get_pixels_per_inch,'png_get_pixels_per_inch',\ |
png_get_x_pixels_per_inch,'png_get_x_pixels_per_inch',\ |
png_get_y_pixels_per_inch,'png_get_y_pixels_per_inch',\ |
png_get_x_offset_inches,'png_get_x_offset_inches',\ |
png_get_x_offset_inches_fixed,'png_get_x_offset_inches_fixed',\ |
png_get_y_offset_inches,'png_get_y_offset_inches',\ |
png_get_y_offset_inches_fixed,'png_get_y_offset_inches_fixed',\ |
png_get_pHYs_dpi,'png_get_pHYs_dpi',\ |
png_get_io_state,'png_get_io_state',\ |
png_get_io_chunk_type,'png_get_io_chunk_type',\ |
png_get_uint_32,'png_get_uint_32',\ |
png_get_uint_16,'png_get_uint_16',\ |
png_get_int_32,'png_get_int_32',\ |
png_get_uint_31,'png_get_uint_31',\ |
png_save_uint_32,'png_save_uint_32',\ |
png_save_int_32,'png_save_int_32',\ |
png_save_uint_16,'png_save_uint_16',\ |
png_image_begin_read_from_file,'png_image_begin_read_from_file',\ |
png_image_begin_read_from_stdio,'png_image_begin_read_from_stdio',\ |
png_image_begin_read_from_memory,'png_image_begin_read_from_memory',\ |
png_image_finish_read,'png_image_finish_read',\ |
png_image_free,'png_image_free',\ |
png_image_write_to_file,'png_image_write_to_file',\ |
png_image_write_to_stdio,'png_image_write_to_stdio',\ |
png_set_check_for_invalid_index,'png_set_check_for_invalid_index',\ |
png_get_palette_max,'png_get_palette_max',\ |
png_set_option,'png_set_option' |
/contrib/sdk/sources/libc/sdk/fasm/include/pixman-1.inc |
---|
0,0 → 1,148 |
import pixman-1,\ |
_pixman_internal_only_get_implementation,'_pixman_internal_only_get_implementation',\ |
pixman_add_trapezoids,'pixman_add_trapezoids',\ |
pixman_add_traps,'pixman_add_traps',\ |
pixman_add_triangles,'pixman_add_triangles',\ |
pixman_blt,'pixman_blt',\ |
pixman_composite_glyphs,'pixman_composite_glyphs',\ |
pixman_composite_glyphs_no_mask,'pixman_composite_glyphs_no_mask',\ |
pixman_composite_trapezoids,'pixman_composite_trapezoids',\ |
pixman_composite_triangles,'pixman_composite_triangles',\ |
pixman_compute_composite_region,'pixman_compute_composite_region',\ |
pixman_disable_out_of_bounds_workaround,'pixman_disable_out_of_bounds_workaround',\ |
pixman_edge_init,'pixman_edge_init',\ |
pixman_edge_step,'pixman_edge_step',\ |
pixman_f_transform_bounds,'pixman_f_transform_bounds',\ |
pixman_f_transform_from_pixman_transform,'pixman_f_transform_from_pixman_transform',\ |
pixman_f_transform_init_identity,'pixman_f_transform_init_identity',\ |
pixman_f_transform_init_rotate,'pixman_f_transform_init_rotate',\ |
pixman_f_transform_init_scale,'pixman_f_transform_init_scale',\ |
pixman_f_transform_init_translate,'pixman_f_transform_init_translate',\ |
pixman_f_transform_invert,'pixman_f_transform_invert',\ |
pixman_f_transform_multiply,'pixman_f_transform_multiply',\ |
pixman_f_transform_point,'pixman_f_transform_point',\ |
pixman_f_transform_point_3d,'pixman_f_transform_point_3d',\ |
pixman_f_transform_rotate,'pixman_f_transform_rotate',\ |
pixman_f_transform_scale,'pixman_f_transform_scale',\ |
pixman_f_transform_translate,'pixman_f_transform_translate',\ |
pixman_fill,'pixman_fill',\ |
pixman_filter_create_separable_convolution,'pixman_filter_create_separable_convolution',\ |
pixman_format_supported_destination,'pixman_format_supported_destination',\ |
pixman_format_supported_source,'pixman_format_supported_source',\ |
pixman_glyph_cache_create,'pixman_glyph_cache_create',\ |
pixman_glyph_cache_destroy,'pixman_glyph_cache_destroy',\ |
pixman_glyph_cache_freeze,'pixman_glyph_cache_freeze',\ |
pixman_glyph_cache_insert,'pixman_glyph_cache_insert',\ |
pixman_glyph_cache_lookup,'pixman_glyph_cache_lookup',\ |
pixman_glyph_cache_remove,'pixman_glyph_cache_remove',\ |
pixman_glyph_cache_thaw,'pixman_glyph_cache_thaw',\ |
pixman_glyph_get_extents,'pixman_glyph_get_extents',\ |
pixman_glyph_get_mask_format,'pixman_glyph_get_mask_format',\ |
pixman_image_composite,'pixman_image_composite',\ |
pixman_image_composite32,'pixman_image_composite32',\ |
pixman_image_create_bits,'pixman_image_create_bits',\ |
pixman_image_create_bits_no_clear,'pixman_image_create_bits_no_clear',\ |
pixman_image_create_conical_gradient,'pixman_image_create_conical_gradient',\ |
pixman_image_create_linear_gradient,'pixman_image_create_linear_gradient',\ |
pixman_image_create_radial_gradient,'pixman_image_create_radial_gradient',\ |
pixman_image_create_solid_fill,'pixman_image_create_solid_fill',\ |
pixman_image_fill_boxes,'pixman_image_fill_boxes',\ |
pixman_image_fill_rectangles,'pixman_image_fill_rectangles',\ |
pixman_image_get_component_alpha,'pixman_image_get_component_alpha',\ |
pixman_image_get_data,'pixman_image_get_data',\ |
pixman_image_get_depth,'pixman_image_get_depth',\ |
pixman_image_get_destroy_data,'pixman_image_get_destroy_data',\ |
pixman_image_get_format,'pixman_image_get_format',\ |
pixman_image_get_height,'pixman_image_get_height',\ |
pixman_image_get_stride,'pixman_image_get_stride',\ |
pixman_image_get_width,'pixman_image_get_width',\ |
pixman_image_ref,'pixman_image_ref',\ |
pixman_image_set_accessors,'pixman_image_set_accessors',\ |
pixman_image_set_alpha_map,'pixman_image_set_alpha_map',\ |
pixman_image_set_clip_region,'pixman_image_set_clip_region',\ |
pixman_image_set_clip_region32,'pixman_image_set_clip_region32',\ |
pixman_image_set_component_alpha,'pixman_image_set_component_alpha',\ |
pixman_image_set_destroy_function,'pixman_image_set_destroy_function',\ |
pixman_image_set_filter,'pixman_image_set_filter',\ |
pixman_image_set_has_client_clip,'pixman_image_set_has_client_clip',\ |
pixman_image_set_indexed,'pixman_image_set_indexed',\ |
pixman_image_set_repeat,'pixman_image_set_repeat',\ |
pixman_image_set_source_clipping,'pixman_image_set_source_clipping',\ |
pixman_image_set_transform,'pixman_image_set_transform',\ |
pixman_image_unref,'pixman_image_unref',\ |
pixman_line_fixed_edge_init,'pixman_line_fixed_edge_init',\ |
pixman_rasterize_edges,'pixman_rasterize_edges',\ |
pixman_rasterize_trapezoid,'pixman_rasterize_trapezoid',\ |
pixman_region32_clear,'pixman_region32_clear',\ |
pixman_region32_contains_point,'pixman_region32_contains_point',\ |
pixman_region32_contains_rectangle,'pixman_region32_contains_rectangle',\ |
pixman_region32_copy,'pixman_region32_copy',\ |
pixman_region32_equal,'pixman_region32_equal',\ |
pixman_region32_extents,'pixman_region32_extents',\ |
pixman_region32_fini,'pixman_region32_fini',\ |
pixman_region32_init,'pixman_region32_init',\ |
pixman_region32_init_from_image,'pixman_region32_init_from_image',\ |
pixman_region32_init_rect,'pixman_region32_init_rect',\ |
pixman_region32_init_rects,'pixman_region32_init_rects',\ |
pixman_region32_init_with_extents,'pixman_region32_init_with_extents',\ |
pixman_region32_intersect,'pixman_region32_intersect',\ |
pixman_region32_intersect_rect,'pixman_region32_intersect_rect',\ |
pixman_region32_inverse,'pixman_region32_inverse',\ |
pixman_region32_n_rects,'pixman_region32_n_rects',\ |
pixman_region32_not_empty,'pixman_region32_not_empty',\ |
pixman_region32_rectangles,'pixman_region32_rectangles',\ |
pixman_region32_reset,'pixman_region32_reset',\ |
pixman_region32_selfcheck,'pixman_region32_selfcheck',\ |
pixman_region32_subtract,'pixman_region32_subtract',\ |
pixman_region32_translate,'pixman_region32_translate',\ |
pixman_region32_union,'pixman_region32_union',\ |
pixman_region32_union_rect,'pixman_region32_union_rect',\ |
pixman_region_clear,'pixman_region_clear',\ |
pixman_region_contains_point,'pixman_region_contains_point',\ |
pixman_region_contains_rectangle,'pixman_region_contains_rectangle',\ |
pixman_region_copy,'pixman_region_copy',\ |
pixman_region_equal,'pixman_region_equal',\ |
pixman_region_extents,'pixman_region_extents',\ |
pixman_region_fini,'pixman_region_fini',\ |
pixman_region_init,'pixman_region_init',\ |
pixman_region_init_from_image,'pixman_region_init_from_image',\ |
pixman_region_init_rect,'pixman_region_init_rect',\ |
pixman_region_init_rects,'pixman_region_init_rects',\ |
pixman_region_init_with_extents,'pixman_region_init_with_extents',\ |
pixman_region_intersect,'pixman_region_intersect',\ |
pixman_region_intersect_rect,'pixman_region_intersect_rect',\ |
pixman_region_inverse,'pixman_region_inverse',\ |
pixman_region_n_rects,'pixman_region_n_rects',\ |
pixman_region_not_empty,'pixman_region_not_empty',\ |
pixman_region_rectangles,'pixman_region_rectangles',\ |
pixman_region_reset,'pixman_region_reset',\ |
pixman_region_selfcheck,'pixman_region_selfcheck',\ |
pixman_region_set_static_pointers,'pixman_region_set_static_pointers',\ |
pixman_region_subtract,'pixman_region_subtract',\ |
pixman_region_translate,'pixman_region_translate',\ |
pixman_region_union,'pixman_region_union',\ |
pixman_region_union_rect,'pixman_region_union_rect',\ |
pixman_sample_ceil_y,'pixman_sample_ceil_y',\ |
pixman_sample_floor_y,'pixman_sample_floor_y',\ |
pixman_transform_bounds,'pixman_transform_bounds',\ |
pixman_transform_from_pixman_f_transform,'pixman_transform_from_pixman_f_transform',\ |
pixman_transform_init_identity,'pixman_transform_init_identity',\ |
pixman_transform_init_rotate,'pixman_transform_init_rotate',\ |
pixman_transform_init_scale,'pixman_transform_init_scale',\ |
pixman_transform_init_translate,'pixman_transform_init_translate',\ |
pixman_transform_invert,'pixman_transform_invert',\ |
pixman_transform_is_identity,'pixman_transform_is_identity',\ |
pixman_transform_is_int_translate,'pixman_transform_is_int_translate',\ |
pixman_transform_is_inverse,'pixman_transform_is_inverse',\ |
pixman_transform_is_scale,'pixman_transform_is_scale',\ |
pixman_transform_multiply,'pixman_transform_multiply',\ |
pixman_transform_point,'pixman_transform_point',\ |
pixman_transform_point_31_16,'pixman_transform_point_31_16',\ |
pixman_transform_point_31_16_3d,'pixman_transform_point_31_16_3d',\ |
pixman_transform_point_31_16_affine,'pixman_transform_point_31_16_affine',\ |
pixman_transform_point_3d,'pixman_transform_point_3d',\ |
pixman_transform_rotate,'pixman_transform_rotate',\ |
pixman_transform_scale,'pixman_transform_scale',\ |
pixman_transform_translate,'pixman_transform_translate',\ |
pixman_version,'pixman_version',\ |
pixman_version_string,'pixman_version_string' |
/contrib/sdk/sources/libc/sdk/fasm/include/proc32.inc |
---|
0,0 → 1,301 |
; Macroinstructions for defining and calling procedures |
macro stdcall proc,[arg] ; directly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call proc } |
macro invoke proc,[arg] ; indirectly call STDCALL procedure |
{ common |
if ~ arg eq |
reverse |
pushd arg |
common |
end if |
call [proc] } |
macro ccall proc,[arg] ; directly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call proc |
if size@ccall |
add esp,size@ccall |
end if } |
macro cinvoke proc,[arg] ; indirectly call CDECL procedure |
{ common |
size@ccall = 0 |
if ~ arg eq |
reverse |
pushd arg |
size@ccall = size@ccall+4 |
common |
end if |
call [proc] |
if size@ccall |
add esp,size@ccall |
end if } |
macro proc [args] ; define procedure |
{ common |
match name params, args> |
\{ define@proc name,<params \} } |
prologue@proc equ prologuedef |
macro prologuedef procname,flag,parmbytes,localbytes,reglist |
{ local loc |
loc = (localbytes+3) and (not 3) |
parmbase@proc equ ebp+8 |
localbase@proc equ ebp-loc |
if parmbytes | localbytes |
push ebp |
mov ebp,esp |
if localbytes |
sub esp,loc |
end if |
end if |
irps reg, reglist \{ push reg \} } |
epilogue@proc equ epiloguedef |
macro epiloguedef procname,flag,parmbytes,localbytes,reglist |
{ irps reg, reglist \{ reverse pop reg \} |
if parmbytes | localbytes |
leave |
end if |
if flag and 10000b |
retn |
else |
retn parmbytes |
end if } |
close@proc equ |
macro define@proc name,statement |
{ local params,flag,regs,parmbytes,localbytes,current |
if used name |
name: |
match =stdcall args, statement \{ params equ args |
flag = 11b \} |
match =stdcall, statement \{ params equ |
flag = 11b \} |
match =c args, statement \{ params equ args |
flag = 10001b \} |
match =c, statement \{ params equ |
flag = 10001b \} |
match =params, params \{ params equ statement |
flag = 0 \} |
match =uses reglist=,args, params \{ regs equ reglist |
params equ args \} |
match =regs =uses reglist, regs params \{ regs equ reglist |
params equ \} |
match =regs, regs \{ regs equ \} |
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \} |
virtual at parmbase@proc |
match =,args, params \{ defargs@proc args \} |
match =args@proc args, args@proc params \{ defargs@proc args \} |
parmbytes = $-(parmbase@proc) |
end virtual |
name # % = parmbytes/4 |
all@vars equ |
current = 0 |
macro locals |
\{ virtual at localbase@proc+current |
macro label def \\{ match . type,def> \\\{ deflocal@proc .,label,<type \\\} \\} |
struc db [val] \\{ \common deflocal@proc .,db,val \\} |
struc du [val] \\{ \common deflocal@proc .,du,val \\} |
struc dw [val] \\{ \common deflocal@proc .,dw,val \\} |
struc dp [val] \\{ \common deflocal@proc .,dp,val \\} |
struc dd [val] \\{ \common deflocal@proc .,dd,val \\} |
struc dt [val] \\{ \common deflocal@proc .,dt,val \\} |
struc dq [val] \\{ \common deflocal@proc .,dq,val \\} |
struc rb cnt \\{ deflocal@proc .,rb cnt, \\} |
struc rw cnt \\{ deflocal@proc .,rw cnt, \\} |
struc rp cnt \\{ deflocal@proc .,rp cnt, \\} |
struc rd cnt \\{ deflocal@proc .,rd cnt, \\} |
struc rt cnt \\{ deflocal@proc .,rt cnt, \\} |
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} |
macro endl |
\{ purge label |
restruc db,du,dw,dp,dd,dt,dq |
restruc rb,rw,rp,rd,rt,rq |
current = $-(localbase@proc) |
end virtual \} |
macro ret operand |
\{ match any, operand \\{ retn operand \\} |
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> \\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} |
macro finish@proc |
\{ localbytes = current |
match close:reglist, close@proc:<regs> \\{ close name,flag,parmbytes,localbytes,reglist \\} |
end if \} } |
macro defargs@proc [arg] |
{ common |
if ~ arg eq |
forward |
local ..arg,current@arg |
match argname:type, arg |
\{ current@arg equ argname |
label ..arg type |
argname equ ..arg |
if qqword eq type |
dd ?,?,?,?,?,?,?,? |
else if dqword eq type |
dd ?,?,?,? |
else if tbyte eq type |
dd ?,?,? |
else if qword eq type | pword eq type |
dd ?,? |
else |
dd ? |
end if \} |
match =current@arg,current@arg |
\{ current@arg equ arg |
arg equ ..arg |
..arg dd ? \} |
common |
args@proc equ current@arg |
forward |
restore current@arg |
common |
end if } |
macro deflocal@proc name,def,[val] { name def val } |
macro deflocal@proc name,def,[val] |
{ common |
match vars, all@vars \{ all@vars equ all@vars, \} |
all@vars equ all@vars name |
forward |
local ..var,..tmp |
..var def val |
match =?, val \{ ..tmp equ \} |
match any =?, val \{ ..tmp equ \} |
match any (=?), val \{ ..tmp equ \} |
match =label, def \{ ..tmp equ \} |
match tmp : value, ..tmp : val |
\{ tmp: end virtual |
initlocal@proc ..var,def value |
virtual at tmp\} |
common |
match first rest, ..var, \{ name equ first \} } |
struc label type { label . type } |
macro initlocal@proc name,def |
{ virtual at name |
def |
size@initlocal = $ - name |
end virtual |
position@initlocal = 0 |
while size@initlocal > position@initlocal |
virtual at name |
def |
if size@initlocal - position@initlocal < 2 |
current@initlocal = 1 |
load byte@initlocal byte from name+position@initlocal |
else if size@initlocal - position@initlocal < 4 |
current@initlocal = 2 |
load word@initlocal word from name+position@initlocal |
else |
current@initlocal = 4 |
load dword@initlocal dword from name+position@initlocal |
end if |
end virtual |
if current@initlocal = 1 |
mov byte [name+position@initlocal],byte@initlocal |
else if current@initlocal = 2 |
mov word [name+position@initlocal],word@initlocal |
else |
mov dword [name+position@initlocal],dword@initlocal |
end if |
position@initlocal = position@initlocal + current@initlocal |
end while } |
macro endp |
{ purge ret,locals,endl |
finish@proc |
purge finish@proc |
restore regs@proc |
match all,args@proc \{ restore all \} |
restore args@proc |
match all,all@vars \{ restore all \} } |
macro local [var] |
{ common |
locals |
forward done@local equ |
match varname[count]:vartype, var |
\{ match =BYTE, vartype \\{ varname rb count |
restore done@local \\} |
match =WORD, vartype \\{ varname rw count |
restore done@local \\} |
match =DWORD, vartype \\{ varname rd count |
restore done@local \\} |
match =PWORD, vartype \\{ varname rp count |
restore done@local \\} |
match =QWORD, vartype \\{ varname rq count |
restore done@local \\} |
match =TBYTE, vartype \\{ varname rt count |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
rq count*2 |
restore done@local \\} |
match =QQWORD, vartype \\{ label varname qqword |
rq count*4 |
restore done@local \\} |
match =XWORD, vartype \\{ label varname xword |
rq count*2 |
restore done@local \\} |
match =YWORD, vartype \\{ label varname yword |
rq count*4 |
restore done@local \\} |
match , done@local \\{ virtual |
varname vartype |
end virtual |
rb count*sizeof.\#vartype |
restore done@local \\} \} |
match :varname:vartype, done@local:var |
\{ match =BYTE, vartype \\{ varname db ? |
restore done@local \\} |
match =WORD, vartype \\{ varname dw ? |
restore done@local \\} |
match =DWORD, vartype \\{ varname dd ? |
restore done@local \\} |
match =PWORD, vartype \\{ varname dp ? |
restore done@local \\} |
match =QWORD, vartype \\{ varname dq ? |
restore done@local \\} |
match =TBYTE, vartype \\{ varname dt ? |
restore done@local \\} |
match =DQWORD, vartype \\{ label varname dqword |
dq ?,? |
restore done@local \\} |
match =QQWORD, vartype \\{ label varname qqword |
dq ?,?,?,? |
restore done@local \\} |
match =XWORD, vartype \\{ label varname xword |
dq ?,? |
restore done@local \\} |
match =YWORD, vartype \\{ label varname yword |
dq ?,?,?,? |
restore done@local \\} |
match , done@local \\{ varname vartype |
restore done@local \\} \} |
match ,done@local |
\{ var |
restore done@local \} |
common |
endl } |
/contrib/sdk/sources/libc/sdk/fasm/include/struct.inc |
---|
0,0 → 1,240 |
; Macroinstructions for defining data structures |
macro struct name |
{ virtual at 0 |
fields@struct equ name |
match child parent, name \{ fields@struct equ child,fields@\#parent \} |
sub@struct equ |
struc db [val] \{ \common define field@struct .,db,<val> |
fields@struct equ fields@struct,field@struct \} |
struc dw [val] \{ \common define field@struct .,dw,<val> |
fields@struct equ fields@struct,field@struct \} |
struc du [val] \{ \common define field@struct .,du,<val> |
fields@struct equ fields@struct,field@struct \} |
struc dd [val] \{ \common define field@struct .,dd,<val> |
fields@struct equ fields@struct,field@struct \} |
struc dp [val] \{ \common define field@struct .,dp,<val> |
fields@struct equ fields@struct,field@struct \} |
struc dq [val] \{ \common define field@struct .,dq,<val> |
fields@struct equ fields@struct,field@struct \} |
struc dt [val] \{ \common define field@struct .,dt,<val> |
fields@struct equ fields@struct,field@struct \} |
struc rb count \{ define field@struct .,db,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
struc rw count \{ define field@struct .,dw,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
struc rd count \{ define field@struct .,dd,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
struc rp count \{ define field@struct .,dp,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
struc rq count \{ define field@struct .,dq,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
struc rt count \{ define field@struct .,dt,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro db [val] \{ \common \local anonymous |
define field@struct anonymous,db,<val> |
fields@struct equ fields@struct,field@struct \} |
macro dw [val] \{ \common \local anonymous |
define field@struct anonymous,dw,<val> |
fields@struct equ fields@struct,field@struct \} |
macro du [val] \{ \common \local anonymous |
define field@struct anonymous,du,<val> |
fields@struct equ fields@struct,field@struct \} |
macro dd [val] \{ \common \local anonymous |
define field@struct anonymous,dd,<val> |
fields@struct equ fields@struct,field@struct \} |
macro dp [val] \{ \common \local anonymous |
define field@struct anonymous,dp,<val> |
fields@struct equ fields@struct,field@struct \} |
macro dq [val] \{ \common \local anonymous |
define field@struct anonymous,dq,<val> |
fields@struct equ fields@struct,field@struct \} |
macro dt [val] \{ \common \local anonymous |
define field@struct anonymous,dt,<val> |
fields@struct equ fields@struct,field@struct \} |
macro rb count \{ \local anonymous |
define field@struct anonymous,db,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro rw count \{ \local anonymous |
define field@struct anonymous,dw,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro rd count \{ \local anonymous |
define field@struct anonymous,dd,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro rp count \{ \local anonymous |
define field@struct anonymous,dp,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro rq count \{ \local anonymous |
define field@struct anonymous,dq,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro rt count \{ \local anonymous |
define field@struct anonymous,dt,count dup (?) |
fields@struct equ fields@struct,field@struct \} |
macro union \{ fields@struct equ fields@struct,,union,< |
sub@struct equ union \} |
macro struct \{ fields@struct equ fields@struct,,substruct,< |
sub@struct equ substruct \} } |
macro ends |
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt |
restruc rb,rw,rd,rp,rq,rt |
purge db,dw,du,dd,dp,dq,dt |
purge rb,rw,rd,rp,rq,rt |
purge union,struct |
match name tail,fields@struct, \\{ if $ |
display 'Error: definition of ',\\`name,' contains illegal instructions.',0Dh,0Ah |
err |
end if \\} |
match name=,fields,fields@struct \\{ fields@struct equ |
make@struct name,fields |
define fields@\\#name fields \\} |
end virtual \} |
match any, sub@struct \{ fields@struct equ fields@struct> \} |
restore sub@struct } |
macro make@struct name,[field,type,def] |
{ common |
local define |
define equ name |
forward |
local sub |
match , field \{ make@substruct type,name,sub def |
define equ define,.,sub, \} |
match any, field \{ define equ define,.#field,type,<def> \} |
common |
match fields, define \{ define@struct fields \} } |
macro define@struct name,[field,type,def] |
{ common |
virtual |
db `name |
load initial@struct byte from 0 |
if initial@struct = '.' |
display 'Error: name of structure should not begin with a dot.',0Dh,0Ah |
err |
end if |
end virtual |
local list |
list equ |
forward |
if ~ field eq . |
name#field type def |
sizeof.#name#field = $ - name#field |
else |
label name#.#type |
rb sizeof.#type |
end if |
local value |
match any, list \{ list equ list, \} |
list equ list <value> |
common |
sizeof.#name = $ |
restruc name |
match values, list \{ |
struc name value \\{ \\local \\..base |
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\} |
match , fields@struct \\\{ label \\..base |
forward |
match , value \\\\{ field type def \\\\} |
match any, value \\\\{ field type value |
if ~ field eq . |
rb sizeof.#name#field - ($-field) |
end if \\\\} |
common label . at \\..base \\\} |
\\} |
macro name value \\{ |
match any, fields@struct \\\{ \\\local anonymous |
fields@struct equ fields@struct,anonymous,name,<values> \\\} |
match , fields@struct \\\{ |
forward |
match , value \\\\{ type def \\\\} |
match any, value \\\\{ \\\\local ..field |
..field = $ |
type value |
if ~ field eq . |
rb sizeof.#name#field - ($-..field) |
end if \\\\} |
common \\\} \\} \} } |
macro enable@substruct |
{ macro make@substruct substruct,parent,name,[field,type,def] |
\{ \common |
\local define |
define equ parent,name |
\forward |
\local sub |
match , field \\{ match any, type \\\{ enable@substruct |
make@substruct type,parent,sub def |
purge make@substruct |
define equ define,.,sub, \\\} \\} |
match any, field \\{ define equ define,.\#field,type,<def> \\} |
\common |
match fields, define \\{ define@\#substruct fields \\} \} } |
enable@substruct |
macro define@union parent,name,[field,type,def] |
{ common |
virtual at parent#.#name |
forward |
if ~ field eq . |
virtual at parent#.#name |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
end virtual |
if sizeof.#parent#field > $ - parent#.#name |
rb sizeof.#parent#field - ($ - parent#.#name) |
end if |
else |
virtual at parent#.#name |
label parent#.#type |
type def |
end virtual |
label name#.#type at parent#.#name |
if sizeof.#type > $ - parent#.#name |
rb sizeof.#type - ($ - parent#.#name) |
end if |
end if |
common |
sizeof.#name = $ - parent#.#name |
end virtual |
struc name [value] \{ \common |
label .\#name |
last@union equ |
forward |
match any, last@union \\{ virtual at .\#name |
field type def |
end virtual \\} |
match , last@union \\{ match , value \\\{ field type def \\\} |
match any, value \\\{ field type value \\\} \\} |
last@union equ field |
common rb sizeof.#name - ($ - .\#name) \} |
macro name [value] \{ \common \local ..anonymous |
..anonymous name value \} } |
macro define@substruct parent,name,[field,type,def] |
{ common |
virtual at parent#.#name |
forward |
if ~ field eq . |
parent#field type def |
sizeof.#parent#field = $ - parent#field |
else |
label parent#.#type |
rb sizeof.#type |
end if |
common |
sizeof.#name = $ - parent#.#name |
end virtual |
struc name value \{ |
label .\#name |
forward |
match , value \\{ field type def \\} |
match any, value \\{ field type value |
if ~ field eq . |
rb sizeof.#parent#field - ($-field) |
end if \\} |
common \} |
macro name value \{ \local ..anonymous |
..anonymous name \} } |
/contrib/sdk/sources/libc/sdk/fasm/include/swresample-0.inc |
---|
0,0 → 1,93 |
import swresample-0, \ |
ff_float_to_int16_a_sse2,'ff_float_to_int16_a_sse2',\,'ff_float_to_int16_a_sse2',\ |
ff_float_to_int16_u_sse2,'ff_float_to_int16_u_sse2',\,'ff_float_to_int16_u_sse2',\ |
ff_float_to_int32_a_sse2,'ff_float_to_int32_a_sse2',\,'ff_float_to_int32_a_sse2',\ |
ff_float_to_int32_u_sse2,'ff_float_to_int32_u_sse2',\,'ff_float_to_int32_u_sse2',\ |
ff_int16_to_float_a_sse2,'ff_int16_to_float_a_sse2',\,'ff_int16_to_float_a_sse2',\ |
ff_int16_to_float_u_sse2,'ff_int16_to_float_u_sse2',\,'ff_int16_to_float_u_sse2',\ |
ff_int16_to_int32_a_mmx,'ff_int16_to_int32_a_mmx',\,'ff_int16_to_int32_a_mmx',\ |
ff_int16_to_int32_a_sse2,'ff_int16_to_int32_a_sse2',\,'ff_int16_to_int32_a_sse2',\ |
ff_int16_to_int32_u_mmx,'ff_int16_to_int32_u_mmx',\,'ff_int16_to_int32_u_mmx',\ |
ff_int16_to_int32_u_sse2,'ff_int16_to_int32_u_sse2',\,'ff_int16_to_int32_u_sse2',\ |
ff_int32_to_float_a_sse2,'ff_int32_to_float_a_sse2',\,'ff_int32_to_float_a_sse2',\ |
ff_int32_to_float_u_sse2,'ff_int32_to_float_u_sse2',\,'ff_int32_to_float_u_sse2',\ |
ff_int32_to_int16_a_mmx,'ff_int32_to_int16_a_mmx',\,'ff_int32_to_int16_a_mmx',\ |
ff_int32_to_int16_a_sse2,'ff_int32_to_int16_a_sse2',\,'ff_int32_to_int16_a_sse2',\ |
ff_int32_to_int16_u_mmx,'ff_int32_to_int16_u_mmx',\,'ff_int32_to_int16_u_mmx',\ |
ff_int32_to_int16_u_sse2,'ff_int32_to_int16_u_sse2',\,'ff_int32_to_int16_u_sse2',\ |
ff_log2_tab,'ff_log2_tab',\,'ff_log2_tab',\ |
ff_mix_1_1_a_float_sse,'ff_mix_1_1_a_float_sse',\,'ff_mix_1_1_a_float_sse',\ |
ff_mix_1_1_a_int16_mmx,'ff_mix_1_1_a_int16_mmx',\,'ff_mix_1_1_a_int16_mmx',\ |
ff_mix_1_1_a_int16_sse2,'ff_mix_1_1_a_int16_sse2',\,'ff_mix_1_1_a_int16_sse2',\ |
ff_mix_1_1_u_float_sse,'ff_mix_1_1_u_float_sse',\,'ff_mix_1_1_u_float_sse',\ |
ff_mix_1_1_u_int16_mmx,'ff_mix_1_1_u_int16_mmx',\,'ff_mix_1_1_u_int16_mmx',\ |
ff_mix_1_1_u_int16_sse2,'ff_mix_1_1_u_int16_sse2',\,'ff_mix_1_1_u_int16_sse2',\ |
ff_mix_2_1_a_float_sse,'ff_mix_2_1_a_float_sse',\,'ff_mix_2_1_a_float_sse',\ |
ff_mix_2_1_a_int16_mmx,'ff_mix_2_1_a_int16_mmx',\,'ff_mix_2_1_a_int16_mmx',\ |
ff_mix_2_1_a_int16_sse2,'ff_mix_2_1_a_int16_sse2',\,'ff_mix_2_1_a_int16_sse2',\ |
ff_mix_2_1_u_float_sse,'ff_mix_2_1_u_float_sse',\,'ff_mix_2_1_u_float_sse',\ |
ff_mix_2_1_u_int16_mmx,'ff_mix_2_1_u_int16_mmx',\,'ff_mix_2_1_u_int16_mmx',\ |
ff_mix_2_1_u_int16_sse2,'ff_mix_2_1_u_int16_sse2',\,'ff_mix_2_1_u_int16_sse2',\ |
ff_pack_2ch_float_to_int16_a_sse2,'ff_pack_2ch_float_to_int16_a_sse2',\,'ff_pack_2ch_float_to_int16_a_sse2',\ |
ff_pack_2ch_float_to_int16_u_sse2,'ff_pack_2ch_float_to_int16_u_sse2',\,'ff_pack_2ch_float_to_int16_u_sse2',\ |
ff_pack_2ch_float_to_int32_a_sse2,'ff_pack_2ch_float_to_int32_a_sse2',\,'ff_pack_2ch_float_to_int32_a_sse2',\ |
ff_pack_2ch_float_to_int32_u_sse2,'ff_pack_2ch_float_to_int32_u_sse2',\,'ff_pack_2ch_float_to_int32_u_sse2',\ |
ff_pack_2ch_int16_to_float_a_sse2,'ff_pack_2ch_int16_to_float_a_sse2',\,'ff_pack_2ch_int16_to_float_a_sse2',\ |
ff_pack_2ch_int16_to_float_u_sse2,'ff_pack_2ch_int16_to_float_u_sse2',\,'ff_pack_2ch_int16_to_float_u_sse2',\ |
ff_pack_2ch_int16_to_int16_a_sse2,'ff_pack_2ch_int16_to_int16_a_sse2',\,'ff_pack_2ch_int16_to_int16_a_sse2',\ |
ff_pack_2ch_int16_to_int16_u_sse2,'ff_pack_2ch_int16_to_int16_u_sse2',\,'ff_pack_2ch_int16_to_int16_u_sse2',\ |
ff_pack_2ch_int16_to_int32_a_sse2,'ff_pack_2ch_int16_to_int32_a_sse2',\,'ff_pack_2ch_int16_to_int32_a_sse2',\ |
ff_pack_2ch_int16_to_int32_u_sse2,'ff_pack_2ch_int16_to_int32_u_sse2',\,'ff_pack_2ch_int16_to_int32_u_sse2',\ |
ff_pack_2ch_int32_to_float_a_sse2,'ff_pack_2ch_int32_to_float_a_sse2',\,'ff_pack_2ch_int32_to_float_a_sse2',\ |
ff_pack_2ch_int32_to_float_u_sse2,'ff_pack_2ch_int32_to_float_u_sse2',\,'ff_pack_2ch_int32_to_float_u_sse2',\ |
ff_pack_2ch_int32_to_int16_a_sse2,'ff_pack_2ch_int32_to_int16_a_sse2',\,'ff_pack_2ch_int32_to_int16_a_sse2',\ |
ff_pack_2ch_int32_to_int16_u_sse2,'ff_pack_2ch_int32_to_int16_u_sse2',\,'ff_pack_2ch_int32_to_int16_u_sse2',\ |
ff_pack_2ch_int32_to_int32_a_sse2,'ff_pack_2ch_int32_to_int32_a_sse2',\,'ff_pack_2ch_int32_to_int32_a_sse2',\ |
ff_pack_2ch_int32_to_int32_u_sse2,'ff_pack_2ch_int32_to_int32_u_sse2',\,'ff_pack_2ch_int32_to_int32_u_sse2',\ |
ff_pack_6ch_float_to_float_a_mmx,'ff_pack_6ch_float_to_float_a_mmx',\,'ff_pack_6ch_float_to_float_a_mmx',\ |
ff_pack_6ch_float_to_float_a_sse4,'ff_pack_6ch_float_to_float_a_sse4',\,'ff_pack_6ch_float_to_float_a_sse4',\ |
ff_pack_6ch_float_to_float_u_mmx,'ff_pack_6ch_float_to_float_u_mmx',\,'ff_pack_6ch_float_to_float_u_mmx',\ |
ff_pack_6ch_float_to_float_u_sse4,'ff_pack_6ch_float_to_float_u_sse4',\,'ff_pack_6ch_float_to_float_u_sse4',\ |
ff_pack_6ch_float_to_int32_a_sse4,'ff_pack_6ch_float_to_int32_a_sse4',\,'ff_pack_6ch_float_to_int32_a_sse4',\ |
ff_pack_6ch_float_to_int32_u_sse4,'ff_pack_6ch_float_to_int32_u_sse4',\,'ff_pack_6ch_float_to_int32_u_sse4',\ |
ff_pack_6ch_int32_to_float_a_sse4,'ff_pack_6ch_int32_to_float_a_sse4',\,'ff_pack_6ch_int32_to_float_a_sse4',\ |
ff_pack_6ch_int32_to_float_u_sse4,'ff_pack_6ch_int32_to_float_u_sse4',\,'ff_pack_6ch_int32_to_float_u_sse4',\ |
ff_resample_int16_rounder,'ff_resample_int16_rounder',\,'ff_resample_int16_rounder',\ |
ff_unpack_2ch_float_to_int16_a_sse2,'ff_unpack_2ch_float_to_int16_a_sse2',\,'ff_unpack_2ch_float_to_int16_a_sse2',\ |
ff_unpack_2ch_float_to_int16_u_sse2,'ff_unpack_2ch_float_to_int16_u_sse2',\,'ff_unpack_2ch_float_to_int16_u_sse2',\ |
ff_unpack_2ch_float_to_int32_a_sse2,'ff_unpack_2ch_float_to_int32_a_sse2',\,'ff_unpack_2ch_float_to_int32_a_sse2',\ |
ff_unpack_2ch_float_to_int32_u_sse2,'ff_unpack_2ch_float_to_int32_u_sse2',\,'ff_unpack_2ch_float_to_int32_u_sse2',\ |
ff_unpack_2ch_int16_to_float_a_sse2,'ff_unpack_2ch_int16_to_float_a_sse2',\,'ff_unpack_2ch_int16_to_float_a_sse2',\ |
ff_unpack_2ch_int16_to_float_a_ssse3,'ff_unpack_2ch_int16_to_float_a_ssse3',\,'ff_unpack_2ch_int16_to_float_a_ssse3',\ |
ff_unpack_2ch_int16_to_float_u_sse2,'ff_unpack_2ch_int16_to_float_u_sse2',\,'ff_unpack_2ch_int16_to_float_u_sse2',\ |
ff_unpack_2ch_int16_to_float_u_ssse3,'ff_unpack_2ch_int16_to_float_u_ssse3',\,'ff_unpack_2ch_int16_to_float_u_ssse3',\ |
ff_unpack_2ch_int16_to_int16_a_sse2,'ff_unpack_2ch_int16_to_int16_a_sse2',\,'ff_unpack_2ch_int16_to_int16_a_sse2',\ |
ff_unpack_2ch_int16_to_int16_a_ssse3,'ff_unpack_2ch_int16_to_int16_a_ssse3',\,'ff_unpack_2ch_int16_to_int16_a_ssse3',\ |
ff_unpack_2ch_int16_to_int16_u_sse2,'ff_unpack_2ch_int16_to_int16_u_sse2',\,'ff_unpack_2ch_int16_to_int16_u_sse2',\ |
ff_unpack_2ch_int16_to_int16_u_ssse3,'ff_unpack_2ch_int16_to_int16_u_ssse3',\,'ff_unpack_2ch_int16_to_int16_u_ssse3',\ |
ff_unpack_2ch_int16_to_int32_a_sse2,'ff_unpack_2ch_int16_to_int32_a_sse2',\,'ff_unpack_2ch_int16_to_int32_a_sse2',\ |
ff_unpack_2ch_int16_to_int32_a_ssse3,'ff_unpack_2ch_int16_to_int32_a_ssse3',\,'ff_unpack_2ch_int16_to_int32_a_ssse3',\ |
ff_unpack_2ch_int16_to_int32_u_sse2,'ff_unpack_2ch_int16_to_int32_u_sse2',\,'ff_unpack_2ch_int16_to_int32_u_sse2',\ |
ff_unpack_2ch_int16_to_int32_u_ssse3,'ff_unpack_2ch_int16_to_int32_u_ssse3',\,'ff_unpack_2ch_int16_to_int32_u_ssse3',\ |
ff_unpack_2ch_int32_to_float_a_sse2,'ff_unpack_2ch_int32_to_float_a_sse2',\,'ff_unpack_2ch_int32_to_float_a_sse2',\ |
ff_unpack_2ch_int32_to_float_u_sse2,'ff_unpack_2ch_int32_to_float_u_sse2',\,'ff_unpack_2ch_int32_to_float_u_sse2',\ |
ff_unpack_2ch_int32_to_int16_a_sse2,'ff_unpack_2ch_int32_to_int16_a_sse2',\,'ff_unpack_2ch_int32_to_int16_a_sse2',\ |
ff_unpack_2ch_int32_to_int16_u_sse2,'ff_unpack_2ch_int32_to_int16_u_sse2',\,'ff_unpack_2ch_int32_to_int16_u_sse2',\ |
ff_unpack_2ch_int32_to_int32_a_sse2,'ff_unpack_2ch_int32_to_int32_a_sse2',\,'ff_unpack_2ch_int32_to_int32_a_sse2',\ |
ff_unpack_2ch_int32_to_int32_u_sse2,'ff_unpack_2ch_int32_to_int32_u_sse2',\,'ff_unpack_2ch_int32_to_int32_u_sse2',\ |
swr_alloc,'swr_alloc',\,'swr_alloc',\ |
swr_alloc_set_opts,'swr_alloc_set_opts',\,'swr_alloc_set_opts',\ |
swr_convert,'swr_convert',\,'swr_convert',\ |
swr_drop_output,'swr_drop_output',\,'swr_drop_output',\ |
swr_free,'swr_free',\,'swr_free',\ |
swr_get_class,'swr_get_class',\,'swr_get_class',\ |
swr_get_delay,'swr_get_delay',\,'swr_get_delay',\ |
swr_init,'swr_init',\,'swr_init',\ |
swr_inject_silence,'swr_inject_silence',\,'swr_inject_silence',\ |
swr_next_pts,'swr_next_pts',\,'swr_next_pts',\ |
swr_set_channel_mapping,'swr_set_channel_mapping',\,'swr_set_channel_mapping',\ |
swr_set_compensation,'swr_set_compensation',\,'swr_set_compensation',\ |
swr_set_matrix,'swr_set_matrix',\,'swr_set_matrix',\ |
swresample_configuration,'swresample_configuration',\,'swresample_configuration',\ |
swresample_license,'swresample_license',\,'swresample_license',\ |
swresample_version,'swresample_version',\,'swresample_version' |
/contrib/sdk/sources/libc/sdk/fasm/include/swscale-2.inc |
---|
0,0 → 1,36 |
import swscale-2,\ |
sws_addVec,'sws_addVec',\,'sws_addVec',\ |
sws_allocVec,'sws_allocVec',\,'sws_allocVec',\ |
sws_alloc_context,'sws_alloc_context',\,'sws_alloc_context',\ |
sws_cloneVec,'sws_cloneVec',\,'sws_cloneVec',\ |
sws_context_class,'sws_context_class',\,'sws_context_class',\ DATA |
sws_convVec,'sws_convVec',\,'sws_convVec',\ |
sws_convertPalette8ToPacked24,'sws_convertPalette8ToPacked24',\,'sws_convertPalette8ToPacked24',\ |
sws_convertPalette8ToPacked32,'sws_convertPalette8ToPacked32',\,'sws_convertPalette8ToPacked32',\ |
sws_format_name,'sws_format_name',\,'sws_format_name',\ |
sws_freeContext,'sws_freeContext',\,'sws_freeContext',\ |
sws_freeFilter,'sws_freeFilter',\,'sws_freeFilter',\ |
sws_freeVec,'sws_freeVec',\,'sws_freeVec',\ |
sws_getCachedContext,'sws_getCachedContext',\,'sws_getCachedContext',\ |
sws_getCoefficients,'sws_getCoefficients',\,'sws_getCoefficients',\ |
sws_getColorspaceDetails,'sws_getColorspaceDetails',\,'sws_getColorspaceDetails',\ |
sws_getConstVec,'sws_getConstVec',\,'sws_getConstVec',\ |
sws_getContext,'sws_getContext',\,'sws_getContext',\ |
sws_getDefaultFilter,'sws_getDefaultFilter',\,'sws_getDefaultFilter',\ |
sws_getGaussianVec,'sws_getGaussianVec',\,'sws_getGaussianVec',\ |
sws_getIdentityVec,'sws_getIdentityVec',\,'sws_getIdentityVec',\ |
sws_get_class,'sws_get_class',\,'sws_get_class',\ |
sws_init_context,'sws_init_context',\,'sws_init_context',\ |
sws_isSupportedInput,'sws_isSupportedInput',\,'sws_isSupportedInput',\ |
sws_isSupportedOutput,'sws_isSupportedOutput',\,'sws_isSupportedOutput',\ |
sws_normalizeVec,'sws_normalizeVec',\,'sws_normalizeVec',\ |
sws_printVec2,'sws_printVec2',\,'sws_printVec2',\ |
sws_rgb2rgb_init,'sws_rgb2rgb_init',\,'sws_rgb2rgb_init',\ |
sws_scale,'sws_scale',\,'sws_scale',\ |
sws_scaleVec,'sws_scaleVec',\,'sws_scaleVec',\ |
sws_setColorspaceDetails,'sws_setColorspaceDetails',\,'sws_setColorspaceDetails',\ |
sws_shiftVec,'sws_shiftVec',\,'sws_shiftVec',\ |
sws_subVec,'sws_subVec',\,'sws_subVec',\ |
swscale_configuration,'swscale_configuration',\,'swscale_configuration',\ |
swscale_license,'swscale_license',\,'swscale_license',\ |
swscale_version,'swscale_version',\,'swscale_version' |
/contrib/sdk/sources/libc/sdk/fasm/include/zlib.inc |
---|
0,0 → 1,66 |
import zlib,\ |
zlibVersion,'zlibVersion',\ |
deflate,'deflate',\ |
deflateEnd,'deflateEnd',\ |
inflate,'inflate',\ |
inflateEnd,'inflateEnd',\ |
deflateSetDictionary,'deflateSetDictionary',\ |
deflateCopy,'deflateCopy',\ |
deflateReset,'deflateReset',\ |
deflateParams,'deflateParams',\ |
deflateTune,'deflateTune',\ |
deflateBound,'deflateBound',\ |
deflatePrime,'deflatePrime',\ |
deflateSetHeader,'deflateSetHeader',\ |
inflateSetDictionary,'inflateSetDictionary',\ |
inflateSync,'inflateSync',\ |
inflateCopy,'inflateCopy',\ |
inflateReset,'inflateReset',\ |
inflateReset2,'inflateReset2',\ |
inflatePrime,'inflatePrime',\ |
inflateMark,'inflateMark',\ |
inflateGetHeader,'inflateGetHeader',\ |
inflateBack,'inflateBack',\ |
inflateBackEnd,'inflateBackEnd',\ |
zlibCompileFlags,'zlibCompileFlags',\ |
compress,'compress',\ |
compress2,'compress2',\ |
compressBound,'compressBound',\ |
uncompress,'uncompress',\ |
gzopen,'gzopen',\ |
gzdopen,'gzdopen',\ |
gzbuffer,'gzbuffer',\ |
gzsetparams,'gzsetparams',\ |
gzread,'gzread',\ |
gzwrite,'gzwrite',\ |
gzprintf,'gzprintf',\ |
gzputs,'gzputs',\ |
gzgets,'gzgets',\ |
gzputc,'gzputc',\ |
gzgetc,'gzgetc',\ |
gzungetc,'gzungetc',\ |
gzflush,'gzflush',\ |
gzseek,'gzseek',\ |
gzrewind,'gzrewind',\ |
gztell,'gztell',\ |
gzoffset,'gzoffset',\ |
gzeof,'gzeof',\ |
gzdirect,'gzdirect',\ |
gzclose,'gzclose',\ |
gzclose_r,'gzclose_r',\ |
gzclose_w,'gzclose_w',\ |
gzerror,'gzerror',\ |
gzclearerr,'gzclearerr',\ |
adler32,'adler32',\ |
crc32,'crc32',\ |
adler32_combine,'adler32_combine',\ |
crc32_combine,'crc32_combine',\ |
deflateInit_,'deflateInit_',\ |
deflateInit2_,'deflateInit2_',\ |
inflateInit_,'inflateInit_',\ |
inflateInit2_,'inflateInit2_',\ |
inflateBackInit_,'inflateBackInit_',\ |
zError,'zError',\ |
inflateSyncPoint,'inflateSyncPoint',\ |
get_crc_table,'get_crc_table',\ |
inflateUndermine,'inflateUndermine' |
/contrib/sdk/sources/libc/sdk/fasm/mpg123 |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/contrib/sdk/sources/libc/sdk/fasm/mpg123.asm |
---|
0,0 → 1,667 |
STACK_SIZE equ 4096 |
include "include/app.inc" |
align 8 |
main: |
.argc equ ebp+8 |
.argv equ ebp+12 |
.envp equ ebp+16 |
; int3 |
push ebp |
mov ebp, esp |
push ebx |
mov eax, [.argc] |
cmp eax, 2 |
jae @F |
call _get_moviefile |
mov [input_file], eax |
@@: |
call [mpg123_init] |
test eax, eax |
jz @F |
push eax |
call [mpg123_plain_strerror] |
mov [esp], eax |
push msg_init_fail |
call [_printf] |
add esp, 4 |
jmp .fail |
@@: |
push dword error |
push 0 |
call [mpg123_new] |
add esp, 8 |
mov [mh], eax |
mov ebx, eax |
test eax, eax |
jz .err_1 |
push [input_file] |
push eax |
call [mpg123_open] |
add esp, 8 |
test eax, eax |
jnz .err_1 |
push encoding |
push channels |
push rate |
push ebx |
call [mpg123_getformat] |
add esp, 16 |
test eax, eax |
jnz .err_1 |
push ebx |
call [mpg123_scan] |
test eax, eax |
jz @F |
call [mpg123_strerror] |
mov [esp], eax |
push msg_print |
call [_printf] |
add esp, 8 |
jmp .fail |
@@: |
call [mpg123_format_none] |
mov ecx, [encoding] |
mov [esp], ecx |
push [channels] |
push [rate] |
push ebx |
call [mpg123_format] |
add esp, 16 |
push error |
stdcall InitSound |
test eax, eax |
jz @F |
cinvoke _printf, msg_sound |
jmp .fail |
@@: |
mov eax, [rate] |
mov ecx, [channels] |
mov [whdr.riff_id], 0x46464952 |
mov [whdr.riff_format], 0x45564157 |
mov [whdr.wFormatTag], 0x01 |
mov [whdr.nSamplesPerSec], eax |
mov [whdr.nChannels], cx |
mov [whdr.wBitsPerSample], 16 |
stdcall test_wav, whdr |
stdcall CreateBuffer, eax, 0, hBuff |
test eax, eax |
jz @F |
cinvoke _printf, msg_buffer |
jmp .fail |
@@: |
mov eax, [hBuff] |
push esi |
push edi |
mov ecx, 0x40000 |
mov eax, 68 |
mov ebx, 12 |
int 0x40 |
push eax ;buffer esp+16 |
push count ;&count esp+12 |
push 0x40000 ;remain esp+8 |
push eax ;outPtr esp+4 |
push [mh] ;mh esp |
xor ebx, ebx ;totalcount |
.inner: |
; int3 |
mov [count], 0 |
call [mpg123_read] |
mov ebx, [count] |
test eax, eax |
jz @F |
test ebx, ebx |
jz .done |
@@: |
.write_out: |
add ebx, 4095 |
and ebx, -4096 |
mov esi, [esp+16] |
stdcall WaveOut, [hBuff], esi, ebx |
mov [esp+8], dword 0x40000 |
mov edi, [esp+16] |
mov [esp+4], edi |
jmp .inner |
.done: |
mov edi, [esp+16] |
mov ecx, 4096 |
xor eax, eax |
rep stosd |
mov esi, [esp+16] |
stdcall WaveOut, [hBuff], esi, 16384 |
add esp, 20 |
pop edi |
pop esi |
xor eax, eax |
pop ebx |
mov esp, ebp |
pop ebp |
ret |
.err_1: |
test ebx, ebx |
jnz @F |
push [error] |
call [mpg123_plain_strerror] |
jmp .err_2 |
@@: |
push ebx |
call [mpg123_strerror] |
.err_2: |
mov [esp], eax |
push msg_trouble |
call [_printf] |
add esp, 8 |
.fail: |
mov eax, -1 |
pop ebx |
mov esp, ebp |
pop ebp |
ret |
align 4 |
getprocaddress: |
mov edx, [esp + 8] ; hlib |
xor eax, eax |
test edx, edx ; If hlib = 0 then goto .end |
jz .end |
.next: |
cmp [edx], dword 0 ; If end of export table then goto .end |
jz .end |
xor eax, eax |
mov esi, [edx] |
mov edi, [esp + 4] ; name |
.next_: |
lodsb |
scasb |
jne .fail |
or al, al |
jnz .next_ |
jmp .ok |
.fail: |
add edx, 8 |
jmp .next |
.ok: ; return address |
mov eax, [edx + 4] |
.end: |
ret 8 |
align 8 |
_get_moviefile: |
pushad |
mov eax, 68 |
mov ebx, 19 |
mov ecx, sz_proc_lib |
int 0x40 |
mov [proclib], eax |
test eax, eax |
jz .fail |
push [proclib] |
push sz_OpenDialog_init |
call getprocaddress |
mov [opendialog_init], eax |
push dword[proclib] |
push sz_OpenDialog_start |
call getprocaddress |
mov [opendialog_start], eax |
mov eax, 68 |
mov ebx, 12 |
mov ecx, 4096*3 |
int 0x40 |
mov [od.procinfo], eax |
add eax, 1024 |
mov [od.filename_area], eax |
add eax, 3072 |
mov [od.opendir_path], eax |
add eax, 4096 |
mov [od.openfile_path], eax |
push od |
call [opendialog_init] |
mov eax, [od.openfile_path] |
mov [eax], byte 0 ; end of ASCIIZ-string(may be don't need?) |
push od |
call [opendialog_start] |
popad |
mov eax, [od.openfile_path]; selected filePath |
ret |
.fail: |
xor eax, eax |
ret |
align 4 |
fake_on_redraw: |
ret |
SRV_GETVERSION equ 0 |
SND_CREATE_BUFF equ 1 |
SND_DESTROY_BUFF equ 2 |
SND_SETFORMAT equ 3 |
SND_GETFORMAT equ 4 |
SND_RESET equ 5 |
SND_SETPOS equ 6 |
SND_GETPOS equ 7 |
SND_SETBUFF equ 8 |
SND_OUT equ 9 |
SND_PLAY equ 10 |
SND_STOP equ 11 |
SND_SETVOLUME equ 12 |
SND_GETVOLUME equ 13 |
SND_SETPAN equ 14 |
SND_GETPAN equ 15 |
SND_GETBUFFSIZE equ 16 |
SND_GETFREESPACE equ 17 |
SND_SETTIMEBASE equ 18 |
SND_GETTIMESTAMP equ 19 |
align 4 |
InitSound: ;p_ver:dword |
push ebx |
push ecx |
mov eax, 68 |
mov ebx, 16 |
mov ecx, szInfinity |
int 0x40 |
mov [hSound], eax |
test eax, eax |
jz .fail |
mov eax, 68 |
mov ebx, 16 |
mov ecx, szSound |
int 0x40 |
mov [hrdwSound], eax |
lea eax, [esp+12] ;p_ver |
xor ebx, ebx |
push 4 ;.out_size |
push eax ;.output |
push ebx ;.inp_size |
push ebx ;.input |
push SRV_GETVERSION ;.code |
push [hSound] ;.handle |
mov eax, 68 |
mov ebx, 17 |
mov ecx, esp ;[handle] |
int 0x40 |
add esp, 24 |
pop ecx |
pop ebx |
ret 4 |
.fail: |
or eax, -1 |
pop ecx |
pop ebx |
ret 4 |
align 4 |
CreateBuffer: ;format:dword,size:dword,p_str:dword |
push ebx |
push ecx |
lea eax, [esp+20] ;p_str |
lea ebx, [esp+12] ;format |
push 4 ;.out_size |
push eax ;.output |
push 8 ;.inp_size |
push ebx ;.input |
push SND_CREATE_BUFF;.code |
push [hSound] ;.handle |
mov eax, 68 |
mov ebx, 17 |
mov ecx, esp |
int 0x40 |
add esp, 24 ;io_cintrol |
pop ecx |
pop ebx |
ret 12 |
align 4 |
proc test_wav stdcall, hdr:dword |
mov eax, [hdr] |
cmp dword [eax], 0x46464952 |
jne .fail |
cmp dword [eax+8], 0x45564157 |
jne .fail |
cmp word [eax+20], 1 |
jne .fail |
mov ecx, dword [eax+24] |
mov edx, 22050 |
cmp ecx, edx |
ja .high |
je .l_22 |
cmp ecx, 8000 |
je .l_8 |
cmp ecx, 11025 |
je .l_11 |
cmp ecx, 12000 |
je .l_12 |
cmp ecx, 16000 |
je .l_16 |
.fail: |
xor eax, eax |
ret |
.high: |
cmp ecx, 24000 |
je .LN56 |
cmp ecx, 32000 |
je .LN65 |
cmp ecx, 44100 |
je .LN74 |
cmp ecx, 48000 |
jne .fail |
movzx ecx, word [eax+22] |
dec ecx |
je .LN79 |
dec ecx |
jne .LN74 |
mov edx, 19 |
jmp .done |
.LN79: |
mov edx, 20 |
jmp .done |
.LN74: |
movzx ecx, word [eax+22] |
dec ecx |
je .LN70 |
dec ecx |
jne .LN65 |
mov edx, 21 |
jmp .done |
.LN70: |
mov edx, 22 |
jmp .done |
.LN65: |
movzx ecx, word [eax+22] |
dec ecx |
je .LN61 |
dec ecx |
jne .LN56 |
mov edx, 23 |
jmp .done |
.LN61: |
mov edx, 24 |
jmp .done |
.LN56: |
movzx ecx, word [eax+22] |
dec ecx |
je .LN52 |
dec ecx |
je .LN50 |
.l_22: |
movzx ecx, word [eax+22] |
dec ecx |
je .LN43 |
dec ecx |
je .LN41 |
.l_16: |
movzx ecx, word [eax+22] |
dec ecx |
je .LN34 |
dec ecx |
je .LN32 |
.l_12: |
movzx ecx, word [eax+22] |
dec ecx |
je .LN25 |
dec ecx |
je .LN23 |
.l_11: |
movzx ecx, word [eax+22] |
dec ecx |
je .LN16 |
dec ecx |
je .LN14 |
.l_8: |
movzx ecx, word [eax+22] |
dec ecx |
je .LN7 |
dec ecx |
jne .fail |
mov edx, 35 |
jmp .done |
.LN7: |
mov edx, 36 |
jmp .done |
.LN14: |
mov edx, 33 |
jmp .done |
.LN16: |
mov edx, 34 |
jmp .done |
.LN23: |
mov edx, 31 |
jmp .done |
.LN25: |
mov edx, 32 |
jmp .done |
.LN32: |
mov edx, 29 |
jmp .done |
.LN34: |
mov edx, 30 |
jmp .done |
.LN41: |
mov edx, 27 |
jmp .done |
.LN43: |
mov edx, 28 |
jmp .done |
.LN50: |
mov edx, 25 |
jmp .done |
.LN52: |
mov edx, 26 |
.done: |
xor ecx, ecx |
cmp word [eax+34], 16 |
setne cl |
dec ecx |
and ecx, -18 |
add ecx, edx |
mov eax, ecx |
ret |
endp |
align 4 |
WaveOut: ;str:dword, src:dword, size:dword |
push ebx |
push ecx |
xor eax, eax |
lea ebx, [esp+12] ;[stream] |
push eax ;.out_size |
push eax ;.output |
push 12 ;.inp_size |
push ebx ;.input |
push SND_OUT ;.code |
push dword [hSound] ;.handle |
mov eax, 68 |
mov ebx, 17 |
mov ecx, esp |
int 0x40 |
add esp, 24 |
pop ecx |
pop ebx |
ret 12 |
align 4 |
hSound dd ? |
hrdwSound dd ? |
szInfinity db 'INFINITY',0 |
szSound db 'SOUND',0 |
align 4 |
od: |
.mode dd 0 |
.procinfo dd 0 |
.com_area_name dd sz_com_area_name |
.com_area dd 0 |
.opendir_path dd 0 |
.dir_default_path dd sz_dir_default_path |
.start_path dd sz_start_path |
.draw_window dd fake_on_redraw |
.status dd 0 |
.openfile_path dd 0 |
.filename_area dd 0 |
.filter_area dd filefilter |
.x_size dw 512 |
.x_start dw 512 |
.y_size dw 512 |
.y_start dw 512 |
filefilter: |
dd filefilter.end - filefilter |
db 'mp3',0 |
; db 'flv',0 |
; db 'mov',0 |
; db 'mpg',0 |
; db 'mpeg',0 |
; db 'mkv',0 |
; db 'mp4',0 |
; db 'webm',0 |
; db 'wmv',0 |
.end: |
db 0 |
sz_proc_lib db "/rd/1/lib/proc_lib.obj",0 |
sz_OpenDialog_init db "OpenDialog_init",0 |
sz_OpenDialog_start db "OpenDialog_start",0 |
sz_com_area_name db "FFFFFFFF_open_dialog",0 |
sz_dir_default_path db "/rd/1",0 |
sz_start_path db "/rd/1/File managers/opendial",0 |
msg_print db '%s',0x0D,0x0A,0 |
msg_init_fail db 'Cannot initialize mpg123 library: %s', 0x0D,0x0A,0 |
msg_trouble db 'Trouble with mpg123: %s', 0x0D,0x0A,0 |
msg_sound db 'Sound service not installed', 0x0D,0x0A,0 |
msg_buffer db 'Unable to create a sound buffer',0x0D,0x0A,0 |
align 16 |
__idata_start: |
library libc,'libc.dll', \ |
libmpg123, 'libmpg123.dll' |
include 'include/libc.inc' |
include 'include/libmpg123.inc' |
__idata_end: |
__iend: |
align 4 |
whdr: |
.riff_id rd 1 |
.riff_size rd 1 |
.riff_format rd 1 |
.fmt_id rd 1 |
.fmt_size rd 1 |
.wFormatTag rw 1 |
.nChannels rw 1 |
.nSamplesPerSec rd 1 |
.nAvgBytesPerSec rd 1 |
.nBlockAlign rw 1 |
.wBitsPerSample rw 1 |
.data_id rd 1 |
.data_size rd 1 |
proclib rd 1 |
opendialog_init rd 1 |
opendialog_start rd 1 |
input_file rd 1 |
mh rd 1 |
encoding rd 1 |
channels rd 1 |
rate rd 1 |
hBuff rd 1 |
count rd 1 |
done rd 1 |
error rd 1 |
__cmdline: rb 256 |
__pgmname: rb 1024 |
rb 16 |
__stack: |
__bssend: |
/contrib/sdk/sources/libc/search/bsearch.c |
---|
0,0 → 1,102 |
/* |
* bsearch.c |
* Original Author: G. Haley |
* Rewritten by: G. Noer |
* |
* Searches an array of nmemb members, the initial member of which is pointed |
* to by base, for a member that matches the object pointed to by key. The |
* contents of the array shall be in ascending order according to a comparison |
* function pointed to by compar. The function shall return an integer less |
* than, equal to or greater than zero if the first argument is considered to be |
* respectively less than, equal to or greater than the second. Returns a |
* pointer to the matching member of the array, or a null pointer if no match |
* is found. |
*/ |
/* |
FUNCTION |
<<bsearch>>---binary search |
INDEX |
bsearch |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void *bsearch(const void *<[key]>, const void *<[base]>, |
size_t <[nmemb]>, size_t <[size]>, |
int (*<[compar]>)(const void *, const void *)); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
char *bsearch(<[key]>, <[base]>, <[nmemb]>, <[size]>, <[compar]>) |
char *<[key]>; |
char *<[base]>; |
size_t <[nmemb]>, <[size]>; |
int (*<[compar]>)(); |
DESCRIPTION |
<<bsearch>> searches an array beginning at <[base]> for any element |
that matches <[key]>, using binary search. <[nmemb]> is the element |
count of the array; <[size]> is the size of each element. |
The array must be sorted in ascending order with respect to the |
comparison function <[compar]> (which you supply as the last argument of |
<<bsearch>>). |
You must define the comparison function <<(*<[compar]>)>> to have two |
arguments; its result must be negative if the first argument is |
less than the second, zero if the two arguments match, and |
positive if the first argument is greater than the second (where |
``less than'' and ``greater than'' refer to whatever arbitrary |
ordering is appropriate). |
RETURNS |
Returns a pointer to an element of <[array]> that matches <[key]>. If |
more than one matching element is available, the result may point to |
any of them. |
PORTABILITY |
<<bsearch>> is ANSI. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdlib.h> |
_PTR |
_DEFUN (bsearch, (key, base, nmemb, size, compar), |
_CONST _PTR key _AND |
_CONST _PTR base _AND |
size_t nmemb _AND |
size_t size _AND |
int _EXFNPTR(compar, (const _PTR, const _PTR))) |
{ |
_PTR current; |
size_t lower = 0; |
size_t upper = nmemb; |
size_t index; |
int result; |
if (nmemb == 0 || size == 0) |
return NULL; |
while (lower < upper) |
{ |
index = (lower + upper) / 2; |
current = (_PTR) (((char *) base) + (index * size)); |
result = compar (key, current); |
if (result < 0) |
upper = index; |
else if (result > 0) |
lower = index + 1; |
else |
return current; |
} |
return NULL; |
} |
/contrib/sdk/sources/libc/search/qsort.c |
---|
0,0 → 1,222 |
/* |
FUNCTION |
<<qsort>>---sort an array |
INDEX |
qsort |
ANSI_SYNOPSIS |
#include <stdlib.h> |
void qsort(void *<[base]>, size_t <[nmemb]>, size_t <[size]>, |
int (*<[compar]>)(const void *, const void *) ); |
TRAD_SYNOPSIS |
#include <stdlib.h> |
qsort(<[base]>, <[nmemb]>, <[size]>, <[compar]> ) |
char *<[base]>; |
size_t <[nmemb]>; |
size_t <[size]>; |
int (*<[compar]>)(); |
DESCRIPTION |
<<qsort>> sorts an array (beginning at <[base]>) of <[nmemb]> objects. |
<[size]> describes the size of each element of the array. |
You must supply a pointer to a comparison function, using the argument |
shown as <[compar]>. (This permits sorting objects of unknown |
properties.) Define the comparison function to accept two arguments, |
each a pointer to an element of the array starting at <[base]>. The |
result of <<(*<[compar]>)>> must be negative if the first argument is |
less than the second, zero if the two arguments match, and positive if |
the first argument is greater than the second (where ``less than'' and |
``greater than'' refer to whatever arbitrary ordering is appropriate). |
The array is sorted in place; that is, when <<qsort>> returns, the |
array elements beginning at <[base]> have been reordered. |
RETURNS |
<<qsort>> does not return a result. |
PORTABILITY |
<<qsort>> is required by ANSI (without specifying the sorting algorithm). |
*/ |
/*- |
* Copyright (c) 1992, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <_ansi.h> |
#include <stdlib.h> |
#ifndef __GNUC__ |
#define inline |
#endif |
static inline char *med3 _PARAMS((char *, char *, char *, int (*)())); |
static inline void swapfunc _PARAMS((char *, char *, int, int)); |
#define min(a, b) (a) < (b) ? a : b |
/* |
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". |
*/ |
#define swapcode(TYPE, parmi, parmj, n) { \ |
long i = (n) / sizeof (TYPE); \ |
register TYPE *pi = (TYPE *) (parmi); \ |
register TYPE *pj = (TYPE *) (parmj); \ |
do { \ |
register TYPE t = *pi; \ |
*pi++ = *pj; \ |
*pj++ = t; \ |
} while (--i > 0); \ |
} |
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ |
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; |
static inline void |
_DEFUN(swapfunc, (a, b, n, swaptype), |
char *a _AND |
char *b _AND |
int n _AND |
int swaptype) |
{ |
if(swaptype <= 1) |
swapcode(long, a, b, n) |
else |
swapcode(char, a, b, n) |
} |
#define swap(a, b) \ |
if (swaptype == 0) { \ |
long t = *(long *)(a); \ |
*(long *)(a) = *(long *)(b); \ |
*(long *)(b) = t; \ |
} else \ |
swapfunc(a, b, es, swaptype) |
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) |
static inline char * |
_DEFUN(med3, (a, b, c, cmp), |
char *a _AND |
char *b _AND |
char *c _AND |
int (*cmp)()) |
{ |
return cmp(a, b) < 0 ? |
(cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a )) |
:(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c )); |
} |
void |
_DEFUN(qsort, (a, n, es, cmp), |
void *a _AND |
size_t n _AND |
size_t es _AND |
int (*cmp)()) |
{ |
char *pa, *pb, *pc, *pd, *pl, *pm, *pn; |
int d, r, swaptype, swap_cnt; |
loop: SWAPINIT(a, es); |
swap_cnt = 0; |
if (n < 7) { |
for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es) |
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; |
pl -= es) |
swap(pl, pl - es); |
return; |
} |
pm = (char *) a + (n / 2) * es; |
if (n > 7) { |
pl = a; |
pn = (char *) a + (n - 1) * es; |
if (n > 40) { |
d = (n / 8) * es; |
pl = med3(pl, pl + d, pl + 2 * d, cmp); |
pm = med3(pm - d, pm, pm + d, cmp); |
pn = med3(pn - 2 * d, pn - d, pn, cmp); |
} |
pm = med3(pl, pm, pn, cmp); |
} |
swap(a, pm); |
pa = pb = (char *) a + es; |
pc = pd = (char *) a + (n - 1) * es; |
for (;;) { |
while (pb <= pc && (r = cmp(pb, a)) <= 0) { |
if (r == 0) { |
swap_cnt = 1; |
swap(pa, pb); |
pa += es; |
} |
pb += es; |
} |
while (pb <= pc && (r = cmp(pc, a)) >= 0) { |
if (r == 0) { |
swap_cnt = 1; |
swap(pc, pd); |
pd -= es; |
} |
pc -= es; |
} |
if (pb > pc) |
break; |
swap(pb, pc); |
swap_cnt = 1; |
pb += es; |
pc -= es; |
} |
if (swap_cnt == 0) { /* Switch to insertion sort */ |
for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es) |
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; |
pl -= es) |
swap(pl, pl - es); |
return; |
} |
pn = (char *) a + n * es; |
r = min(pa - (char *)a, pb - pa); |
vecswap(a, pb - r, r); |
r = min(pd - pc, pn - pd - es); |
vecswap(pb, pn - r, r); |
if ((r = pb - pa) > es) |
qsort(a, r / es, es, cmp); |
if ((r = pd - pc) > es) { |
/* Iterate rather than recurse to save stack space */ |
a = pn - r; |
n = r / es; |
goto loop; |
} |
/* qsort(pn - r, r / es, es, cmp);*/ |
} |
/contrib/sdk/sources/libc/signal/signal.c |
---|
0,0 → 1,260 |
/* |
FUNCTION |
<<signal>>---specify handler subroutine for a signal |
INDEX |
signal |
INDEX |
_signal_r |
ANSI_SYNOPSIS |
#include <signal.h> |
void (*signal(int <[sig]>, void(*<[func]>)(int))) (int); |
void (*_signal_r(void *<[reent]>, int <[sig]>, void(*<[func]>)(int))) (int); |
TRAD_SYNOPSIS |
#include <signal.h> |
char ( * signal(<[sig]>, <[func]>) )() |
int <[sig]>; |
char ( * <[func]> )(); |
char ( * _signal_r(<[reent]>, <[sig]>, <[func]>) )() |
char *<[reent]>; |
int <[sig]>; |
char ( * <[func]> )(); |
DESCRIPTION |
<<signal>> provides a simple signal-handling implementation for embedded |
targets. |
<<signal>> allows you to request changed treatment for a particular |
signal <[sig]>. You can use one of the predefined macros <<SIG_DFL>> |
(select system default handling) or <<SIG_IGN>> (ignore this signal) |
as the value of <[func]>; otherwise, <[func]> is a function pointer |
that identifies a subroutine in your program as the handler for this signal. |
Some of the execution environment for signal handlers is |
unpredictable; notably, the only library function required to work |
correctly from within a signal handler is <<signal>> itself, and |
only when used to redefine the handler for the current signal value. |
Static storage is likewise unreliable for signal handlers, with one |
exception: if you declare a static storage location as `<<volatile |
sig_atomic_t>>', then you may use that location in a signal handler to |
store signal values. |
If your signal handler terminates using <<return>> (or implicit |
return), your program's execution continues at the point |
where it was when the signal was raised (whether by your program |
itself, or by an external event). Signal handlers can also |
use functions such as <<exit>> and <<abort>> to avoid returning. |
The alternate function <<_signal_r>> is the reentrant version. |
The extra argument <[reent]> is a pointer to a reentrancy structure. |
@c FIXME: do we have setjmp.h and assoc fns? |
RETURNS |
If your request for a signal handler cannot be honored, the result is |
<<SIG_ERR>>; a specific error number is also recorded in <<errno>>. |
Otherwise, the result is the previous handler (a function pointer or |
one of the predefined macros). |
PORTABILITY |
ANSI C requires <<signal>>. |
No supporting OS subroutines are required to link with <<signal>>, but |
it will not have any useful effects, except for software generated signals, |
without an operating system that can actually raise exceptions. |
*/ |
/* |
* signal.c |
* Original Author: G. Haley |
* |
* signal associates the function pointed to by func with the signal sig. When |
* a signal occurs, the value of func determines the action taken as follows: |
* if func is SIG_DFL, the default handling for that signal will occur; if func |
* is SIG_IGN, the signal will be ignored; otherwise, the default handling for |
* the signal is restored (SIG_DFL), and the function func is called with sig |
* as its argument. Returns the value of func for the previous call to signal |
* for the signal sig, or SIG_ERR if the request fails. |
*/ |
/* _init_signal initialises the signal handlers for each signal. This function |
is called by crt0 at program startup. */ |
#ifdef SIGNAL_PROVIDED |
int _dummy_simulated_signal; |
#else |
#include <errno.h> |
#include <signal.h> |
#include <stddef.h> |
#include <stdlib.h> |
#include <reent.h> |
#include <_syslist.h> |
int |
_DEFUN (_init_signal_r, (ptr), |
struct _reent *ptr) |
{ |
int i; |
if (ptr->_sig_func == NULL) |
{ |
ptr->_sig_func = (_sig_func_ptr *)_malloc_r (ptr, sizeof (_sig_func_ptr) * NSIG); |
if (ptr->_sig_func == NULL) |
return -1; |
for (i = 0; i < NSIG; i++) |
ptr->_sig_func[i] = SIG_DFL; |
} |
return 0; |
} |
_sig_func_ptr |
_DEFUN (_signal_r, (ptr, sig, func), |
struct _reent *ptr _AND |
int sig _AND |
_sig_func_ptr func) |
{ |
_sig_func_ptr old_func; |
if (sig < 0 || sig >= NSIG) |
{ |
ptr->_errno = EINVAL; |
return SIG_ERR; |
} |
if (ptr->_sig_func == NULL && _init_signal_r (ptr) != 0) |
return SIG_ERR; |
old_func = ptr->_sig_func[sig]; |
ptr->_sig_func[sig] = func; |
return old_func; |
} |
int |
_DEFUN (_raise_r, (ptr, sig), |
struct _reent *ptr _AND |
int sig) |
{ |
_sig_func_ptr func; |
if (sig < 0 || sig >= NSIG) |
{ |
ptr->_errno = EINVAL; |
return -1; |
} |
if (ptr->_sig_func == NULL) |
func = SIG_DFL; |
else |
func = ptr->_sig_func[sig]; |
if (func == SIG_DFL) |
return _kill_r (ptr, _getpid_r (ptr), sig); |
else if (func == SIG_IGN) |
return 0; |
else if (func == SIG_ERR) |
{ |
ptr->_errno = EINVAL; |
return 1; |
} |
else |
{ |
ptr->_sig_func[sig] = SIG_DFL; |
func (sig); |
return 0; |
} |
} |
int |
_DEFUN (__sigtramp_r, (ptr, sig), |
struct _reent *ptr _AND |
int sig) |
{ |
_sig_func_ptr func; |
if (sig < 0 || sig >= NSIG) |
{ |
return -1; |
} |
if (ptr->_sig_func == NULL && _init_signal_r (ptr) != 0) |
return -1; |
func = ptr->_sig_func[sig]; |
if (func == SIG_DFL) |
return 1; |
else if (func == SIG_ERR) |
return 2; |
else if (func == SIG_IGN) |
return 3; |
else |
{ |
ptr->_sig_func[sig] = SIG_DFL; |
func (sig); |
return 0; |
} |
} |
int _DEFUN (_kill_r, (ptr, pid, sig), |
struct _reent *ptr _AND |
int pid _AND |
int sig) |
{ |
// int ret; |
// errno = 0; |
// if ((ret = _kill (pid, sig)) == -1 && errno != 0) |
// ptr->_errno = errno; |
// return ret; |
/* sorry, guys */ |
ptr->_errno = EPERM; |
return -1; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN (raise, (sig), |
int sig) |
{ |
return _raise_r (_REENT, sig); |
} |
_sig_func_ptr |
_DEFUN (signal, (sig, func), |
int sig _AND |
_sig_func_ptr func) |
{ |
return _signal_r (_REENT, sig, func); |
} |
int |
_DEFUN_VOID (_init_signal) |
{ |
return _init_signal_r (_REENT); |
} |
int |
_DEFUN (__sigtramp, (sig), int sig) |
{ |
return __sigtramp_r (_REENT, sig); |
} |
#endif |
#endif /* !SIGNAL_PROVIDED */ |
/contrib/sdk/sources/libc/static.lds |
---|
0,0 → 1,112 |
/*OUTPUT_FORMAT("binary")*/ |
ENTRY(__start) |
SECTIONS |
{ |
.text 0x000000: |
{ |
LONG(0x554e454D); |
LONG(0x32305445); |
LONG(1); |
LONG(__start); |
LONG(___iend); |
LONG(___memsize); |
LONG(___stacktop); |
LONG(___cmdline); |
LONG(___pgmname); /* full path */ |
LONG(0); /*FIXME tls data */ |
*(.init) |
*(.text) |
*(SORT(.text$*)) |
*(.text.*) |
*(.glue_7t) |
*(.glue_7) |
___CTOR_LIST__ = .; __CTOR_LIST__ = . ; |
LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); |
___DTOR_LIST__ = .; __DTOR_LIST__ = . ; |
LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); |
*(.fini) |
/* ??? Why is .gcc_exc here? */ |
*(.gcc_exc) |
PROVIDE (etext = .); |
*(.gcc_except_table) |
} |
.rdata ALIGN(64) : |
{ |
*(.rdata) |
*(SORT(.rdata$*)) |
___RUNTIME_PSEUDO_RELOC_LIST__ = .; |
__RUNTIME_PSEUDO_RELOC_LIST__ = .; |
*(.rdata_runtime_pseudo_reloc) |
___RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
__RUNTIME_PSEUDO_RELOC_LIST_END__ = .; |
} |
.CRT ALIGN(64) : |
{ |
___crt_xc_start__ = . ; |
*(SORT(.CRT$XC*)) /* C initialization */ |
___crt_xc_end__ = . ; |
___crt_xi_start__ = . ; |
*(SORT(.CRT$XI*)) /* C++ initialization */ |
___crt_xi_end__ = . ; |
___crt_xl_start__ = . ; |
*(SORT(.CRT$XL*)) /* TLS callbacks */ |
/* ___crt_xl_end__ is defined in the TLS Directory support code */ |
___crt_xp_start__ = . ; |
*(SORT(.CRT$XP*)) /* Pre-termination */ |
___crt_xp_end__ = . ; |
___crt_xt_start__ = . ; |
*(SORT(.CRT$XT*)) /* Termination */ |
___crt_xt_end__ = . ; |
} |
.data ALIGN(64) : |
{ |
PROVIDE ( __data_start__ = .) ; |
*(.data) |
*(.data2) |
*(SORT(.data$*)) |
*(.jcr) |
__CRT_MT = .; |
LONG(0); |
PROVIDE ( __data_end__ = .) ; |
*(.data_cygwin_nocopy) |
___iend = . ; |
} |
bss ALIGN(64): |
{ |
*(.bss) |
*(COMMON) |
. = ALIGN(16); |
___cmdline = .; |
. = . + 256; |
___pgmname = .; |
. = . + 1024 + 16; |
___stacktop = .; |
___memsize = . ; |
} |
/DISCARD/ : |
{ |
*(.debug$S) |
*(.debug$T) |
*(.debug$F) |
*(.drectve) |
*(.note.GNU-stack) |
*(.eh_frame) |
*(.comment) |
*(.debug_abbrev) |
*(.debug_info) |
*(.debug_line) |
*(.debug_frame) |
*(.debug_loc) |
*(.debug_pubnames) |
*(.debug_aranges) |
*(.debug_ranges) |
} |
} |
/contrib/sdk/sources/libc/stdio/clearerr.c |
---|
0,0 → 1,71 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<clearerr>>---clear file or stream error indicator |
INDEX |
clearerr |
ANSI_SYNOPSIS |
#include <stdio.h> |
void clearerr(FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
void clearerr(<[fp]>) |
FILE *<[fp]>; |
DESCRIPTION |
The <<stdio>> functions maintain an error indicator with each file |
pointer <[fp]>, to record whether any read or write errors have |
occurred on the associated file or stream. Similarly, it maintains an |
end-of-file indicator to record whether there is no more data in the |
file. |
Use <<clearerr>> to reset both of these indicators. |
See <<ferror>> and <<feof>> to query the two indicators. |
RETURNS |
<<clearerr>> does not return a result. |
PORTABILITY |
ANSI C requires <<clearerr>>. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include "local.h" |
/* A subroutine version of the macro clearerr. */ |
#undef clearerr |
_VOID |
_DEFUN(clearerr, (fp), |
FILE * fp) |
{ |
CHECK_INIT(_REENT, fp); |
_flockfile (fp); |
__sclearerr (fp); |
_funlockfile (fp); |
} |
/contrib/sdk/sources/libc/stdio/diprintf.c |
---|
0,0 → 1,82 |
/* Copyright (C) 2005, 2007 Shaun Jackman |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* |
FUNCTION |
<<diprintf>>, <<vdiprintf>>---print to a file descriptor (integer only) |
INDEX |
diprintf |
INDEX |
_diprintf_r |
INDEX |
vdiprintf |
INDEX |
_vdiprintf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
#include <stdarg.h> |
int diprintf(int <[fd]>, const char *<[format]>, ...); |
int vdiprintf(int <[fd]>, const char *<[format]>, va_list <[ap]>); |
int _diprintf_r(struct _reent *<[ptr]>, int <[fd]>, |
const char *<[format]>, ...); |
int _vdiprintf_r(struct _reent *<[ptr]>, int <[fd]>, |
const char *<[format]>, va_list <[ap]>); |
DESCRIPTION |
<<diprintf>> and <<vdiprintf>> are similar to <<dprintf>> and <<vdprintf>>, |
except that only integer format specifiers are processed. |
The functions <<_diprintf_r>> and <<_vdiprintf_r>> are simply |
reentrant versions of the functions above. |
RETURNS |
Similar to <<dprintf>> and <<vdprintf>>. |
PORTABILITY |
This set of functions is an integer-only extension, and is not portable. |
Supporting OS subroutines required: <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <unistd.h> |
#include <stdarg.h> |
int |
_DEFUN(_diprintf_r, (ptr, fd, format), |
struct _reent *ptr _AND |
int fd _AND |
const char *format _DOTS) |
{ |
va_list ap; |
int n; |
va_start (ap, format); |
n = _vdiprintf_r (ptr, fd, format, ap); |
va_end (ap); |
return n; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(diprintf, (fd, format), |
int fd _AND |
const char *format _DOTS) |
{ |
va_list ap; |
int n; |
va_start (ap, format); |
n = _vdiprintf_r (_REENT, fd, format, ap); |
va_end (ap); |
return n; |
} |
#endif /* ! _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/dprintf.c |
---|
0,0 → 1,87 |
/* Copyright 2005, 2007 Shaun Jackman |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* |
FUNCTION |
<<dprintf>>, <<vdprintf>>---print to a file descriptor |
INDEX |
dprintf |
INDEX |
_dprintf_r |
INDEX |
vdprintf |
INDEX |
_vdprintf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
#include <stdarg.h> |
int dprintf(int <[fd]>, const char *<[format]>, ...); |
int vdprintf(int <[fd]>, const char *<[format]>, va_list <[ap]>); |
int _dprintf_r(struct _reent *<[ptr]>, int <[fd]>, |
const char *<[format]>, ...); |
int _vdprintf_r(struct _reent *<[ptr]>, int <[fd]>, |
const char *<[format]>, va_list <[ap]>); |
DESCRIPTION |
<<dprintf>> and <<vdprintf>> allow printing a format, similarly to |
<<printf>>, but write to a file descriptor instead of to a <<FILE>> |
stream. |
The functions <<_dprintf_r>> and <<_vdprintf_r>> are simply |
reentrant versions of the functions above. |
RETURNS |
The return value and errors are exactly as for <<write>>, except that |
<<errno>> may also be set to <<ENOMEM>> if the heap is exhausted. |
PORTABILITY |
This function is originally a GNU extension in glibc and is not portable. |
Supporting OS subroutines required: <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <unistd.h> |
#include <stdarg.h> |
#include "local.h" |
int |
_DEFUN(_dprintf_r, (ptr, fd, format), |
struct _reent *ptr _AND |
int fd _AND |
const char *format _DOTS) |
{ |
va_list ap; |
int n; |
_REENT_SMALL_CHECK_INIT (ptr); |
va_start (ap, format); |
n = _vdprintf_r (ptr, fd, format, ap); |
va_end (ap); |
return n; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(dprintf, (fd, format), |
int fd _AND |
const char *format _DOTS) |
{ |
va_list ap; |
int n; |
struct _reent *ptr = _REENT; |
_REENT_SMALL_CHECK_INIT (ptr); |
va_start (ap, format); |
n = _vdprintf_r (ptr, fd, format, ap); |
va_end (ap); |
return n; |
} |
#endif /* ! _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fclose.c |
---|
0,0 → 1,119 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fclose>>---close a file |
INDEX |
fclose |
INDEX |
_fclose_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fclose(FILE *<[fp]>); |
int _fclose_r(struct _reent *<[reent]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int fclose(<[fp]>) |
FILE *<[fp]>; |
int fclose(<[fp]>) |
struct _reent *<[reent]> |
FILE *<[fp]>; |
DESCRIPTION |
If the file or stream identified by <[fp]> is open, <<fclose>> closes |
it, after first ensuring that any pending data is written (by calling |
<<fflush(<[fp]>)>>). |
The alternate function <<_fclose_r>> is a reentrant version. |
The extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<fclose>> returns <<0>> if successful (including when <[fp]> is |
<<NULL>> or not an open file); otherwise, it returns <<EOF>>. |
PORTABILITY |
<<fclose>> is required by ANSI C. |
Required OS subroutines: <<close>>, <<fstat>>, <<isatty>>, <<lseek>>, |
<<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <sys/lock.h> |
#include "local.h" |
int |
_DEFUN(_fclose_r, (rptr, fp), |
struct _reent *rptr _AND |
register FILE * fp) |
{ |
int r; |
if (fp == NULL) |
return (0); /* on NULL */ |
CHECK_INIT (rptr, fp); |
_flockfile (fp); |
if (fp->_flags == 0) /* not open! */ |
{ |
_funlockfile (fp); |
return (0); |
} |
/* Unconditionally flush to allow special handling for seekable read |
files to reposition file to last byte processed as opposed to |
last byte read ahead into the buffer. */ |
r = _fflush_r (rptr, fp); |
if (fp->_close != NULL && fp->_close (rptr, fp->_cookie) < 0) |
r = EOF; |
if (fp->_flags & __SMBF) |
_free_r (rptr, (char *) fp->_bf._base); |
if (HASUB (fp)) |
FREEUB (rptr, fp); |
if (HASLB (fp)) |
FREELB (rptr, fp); |
__sfp_lock_acquire (); |
fp->_flags = 0; /* release this FILE for reuse */ |
_funlockfile (fp); |
#ifndef __SINGLE_THREAD__ |
__lock_close_recursive (fp->_lock); |
#endif |
__sfp_lock_release (); |
return (r); |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fclose, (fp), |
register FILE * fp) |
{ |
return _fclose_r(_REENT, fp); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/fdopen.c |
---|
0,0 → 1,144 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fdopen>>---turn open file into a stream |
INDEX |
fdopen |
INDEX |
_fdopen_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
FILE *fdopen(int <[fd]>, const char *<[mode]>); |
FILE *_fdopen_r(struct _reent *<[reent]>, |
int <[fd]>, const char *<[mode]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
FILE *fdopen(<[fd]>, <[mode]>) |
int <[fd]>; |
char *<[mode]>; |
FILE *_fdopen_r(<[reent]>, <[fd]>, <[mode]>) |
struct _reent *<[reent]>; |
int <[fd]>; |
char *<[mode]>); |
DESCRIPTION |
<<fdopen>> produces a file descriptor of type <<FILE *>>, from a |
descriptor for an already-open file (returned, for example, by the |
system subroutine <<open>> rather than by <<fopen>>). |
The <[mode]> argument has the same meanings as in <<fopen>>. |
RETURNS |
File pointer or <<NULL>>, as for <<fopen>>. |
PORTABILITY |
<<fdopen>> is ANSI. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <sys/types.h> |
#include <sys/fcntl.h> |
#include <stdio.h> |
#include <errno.h> |
#include "local.h" |
#include <_syslist.h> |
FILE * |
_DEFUN(_fdopen_r, (ptr, fd, mode), |
struct _reent *ptr _AND |
int fd _AND |
_CONST char *mode) |
{ |
register FILE *fp; |
int flags, oflags; |
#ifdef HAVE_FCNTL |
int fdflags, fdmode; |
#endif |
if ((flags = __sflags (ptr, mode, &oflags)) == 0) |
return 0; |
/* make sure the mode the user wants is a subset of the actual mode */ |
#ifdef HAVE_FCNTL |
if ((fdflags = _fcntl_r (ptr, fd, F_GETFL, 0)) < 0) |
return 0; |
fdmode = fdflags & O_ACCMODE; |
if (fdmode != O_RDWR && (fdmode != (oflags & O_ACCMODE))) |
{ |
ptr->_errno = EBADF; |
return 0; |
} |
#endif |
if ((fp = __sfp (ptr)) == 0) |
return 0; |
_flockfile (fp); |
fp->_flags = flags; |
/* POSIX recommends setting the O_APPEND bit on fd to match append |
streams. Someone may later clear O_APPEND on fileno(fp), but the |
stream must still remain in append mode. Rely on __sflags |
setting __SAPP properly. */ |
#ifdef HAVE_FCNTL |
if ((oflags & O_APPEND) && !(fdflags & O_APPEND)) |
_fcntl_r (ptr, fd, F_SETFL, fdflags | O_APPEND); |
#endif |
fp->_file = fd; |
fp->_cookie = (_PTR) fp; |
#undef _read |
#undef _write |
#undef _seek |
#undef _close |
fp->_read = __sread; |
fp->_write = __swrite; |
fp->_seek = __sseek; |
fp->_close = __sclose; |
#ifdef __SCLE |
/* Explicit given mode results in explicit setting mode on fd */ |
if (oflags & O_BINARY) |
setmode (fp->_file, O_BINARY); |
else if (oflags & O_TEXT) |
setmode (fp->_file, O_TEXT); |
if (__stextmode (fp->_file)) |
fp->_flags |= __SCLE; |
#endif |
_funlockfile (fp); |
return fp; |
} |
#ifndef _REENT_ONLY |
FILE * |
_DEFUN(fdopen, (fd, mode), |
int fd _AND |
_CONST char *mode) |
{ |
return _fdopen_r (_REENT, fd, mode); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/fflush.c |
---|
0,0 → 1,247 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fflush>>---flush buffered file output |
INDEX |
fflush |
INDEX |
_fflush_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fflush(FILE *<[fp]>); |
int _fflush_r(struct _reent *<[reent]>, FILE *<[fp]>); |
DESCRIPTION |
The <<stdio>> output functions can buffer output before delivering it |
to the host system, in order to minimize the overhead of system calls. |
Use <<fflush>> to deliver any such pending output (for the file |
or stream identified by <[fp]>) to the host system. |
If <[fp]> is <<NULL>>, <<fflush>> delivers pending output from all |
open files. |
Additionally, if <[fp]> is a seekable input stream visiting a file |
descriptor, set the position of the file descriptor to match next |
unread byte, useful for obeying POSIX semantics when ending a process |
without consuming all input from the stream. |
The alternate function <<_fflush_r>> is a reentrant version, where the |
extra argument <[reent]> is a pointer to a reentrancy structure, and |
<[fp]> must not be NULL. |
RETURNS |
<<fflush>> returns <<0>> unless it encounters a write error; in that |
situation, it returns <<EOF>>. |
PORTABILITY |
ANSI C requires <<fflush>>. The behavior on input streams is only |
specified by POSIX, and not all implementations follow POSIX rules. |
No supporting OS subroutines are required. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include <errno.h> |
#include "local.h" |
/* Flush a single file, or (if fp is NULL) all files. */ |
/* Core function which does not lock file pointer. This gets called |
directly from __srefill. */ |
int |
_DEFUN(__sflush_r, (ptr, fp), |
struct _reent *ptr _AND |
register FILE * fp) |
{ |
register unsigned char *p; |
register int n, t; |
t = fp->_flags; |
if ((t & __SWR) == 0) |
{ |
/* For a read stream, an fflush causes the next seek to be |
unoptimized (i.e. forces a system-level seek). This conforms |
to the POSIX and SUSv3 standards. */ |
fp->_flags |= __SNPT; |
/* For a seekable stream with buffered read characters, we will attempt |
a seek to the current position now. A subsequent read will then get |
the next byte from the file rather than the buffer. This conforms |
to the POSIX and SUSv3 standards. Note that the standards allow |
this seek to be deferred until necessary, but we choose to do it here |
to make the change simpler, more contained, and less likely |
to miss a code scenario. */ |
if ((fp->_r > 0 || fp->_ur > 0) && fp->_seek != NULL) |
{ |
int tmp_errno; |
#ifdef __LARGE64_FILES |
_fpos64_t curoff; |
#else |
_fpos_t curoff; |
#endif |
/* Save last errno and set errno to 0, so we can check if a device |
returns with a valid position -1. We restore the last errno if |
no other error condition has been encountered. */ |
tmp_errno = ptr->_errno; |
ptr->_errno = 0; |
/* Get the physical position we are at in the file. */ |
if (fp->_flags & __SOFF) |
curoff = fp->_offset; |
else |
{ |
/* We don't know current physical offset, so ask for it. |
Only ESPIPE and EINVAL are ignorable. */ |
#ifdef __LARGE64_FILES |
if (fp->_flags & __SL64) |
curoff = fp->_seek64 (ptr, fp->_cookie, 0, SEEK_CUR); |
else |
#endif |
curoff = fp->_seek (ptr, fp->_cookie, 0, SEEK_CUR); |
if (curoff == -1L && ptr->_errno != 0) |
{ |
int result = EOF; |
if (ptr->_errno == ESPIPE || ptr->_errno == EINVAL) |
{ |
result = 0; |
ptr->_errno = tmp_errno; |
} |
else |
fp->_flags |= __SERR; |
return result; |
} |
} |
if (fp->_flags & __SRD) |
{ |
/* Current offset is at end of buffer. Compensate for |
characters not yet read. */ |
curoff -= fp->_r; |
if (HASUB (fp)) |
curoff -= fp->_ur; |
} |
/* Now physically seek to after byte last read. */ |
#ifdef __LARGE64_FILES |
if (fp->_flags & __SL64) |
curoff = fp->_seek64 (ptr, fp->_cookie, curoff, SEEK_SET); |
else |
#endif |
curoff = fp->_seek (ptr, fp->_cookie, curoff, SEEK_SET); |
if (curoff != -1 || ptr->_errno == 0 |
|| ptr->_errno == ESPIPE || ptr->_errno == EINVAL) |
{ |
/* Seek successful or ignorable error condition. |
We can clear read buffer now. */ |
fp->_flags &= ~__SNPT; |
fp->_r = 0; |
fp->_p = fp->_bf._base; |
if ((fp->_flags & __SOFF) && (curoff != -1 || ptr->_errno == 0)) |
fp->_offset = curoff; |
ptr->_errno = tmp_errno; |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
} |
else |
{ |
fp->_flags |= __SERR; |
return EOF; |
} |
} |
return 0; |
} |
if ((p = fp->_bf._base) == NULL) |
{ |
/* Nothing to flush. */ |
return 0; |
} |
n = fp->_p - p; /* write this much */ |
/* |
* Set these immediately to avoid problems with longjmp |
* and to allow exchange buffering (via setvbuf) in user |
* write function. |
*/ |
fp->_p = p; |
fp->_w = t & (__SLBF | __SNBF) ? 0 : fp->_bf._size; |
while (n > 0) |
{ |
t = fp->_write (ptr, fp->_cookie, (char *) p, n); |
if (t <= 0) |
{ |
fp->_flags |= __SERR; |
return EOF; |
} |
p += t; |
n -= t; |
} |
return 0; |
} |
int |
_DEFUN(_fflush_r, (ptr, fp), |
struct _reent *ptr _AND |
register FILE * fp) |
{ |
int ret; |
#ifdef _REENT_SMALL |
/* For REENT_SMALL platforms, it is possible we are being |
called for the first time on a std stream. This std |
stream can belong to a reentrant struct that is not |
_REENT. If CHECK_INIT gets called below based on _REENT, |
we will end up changing said file pointers to the equivalent |
std stream off of _REENT. This causes unexpected behavior if |
there is any data to flush on the _REENT std stream. There |
are two alternatives to fix this: 1) make a reentrant fflush |
or 2) simply recognize that this file has nothing to flush |
and return immediately before performing a CHECK_INIT. Choice |
2 is implemented here due to its simplicity. */ |
if (fp->_bf._base == NULL) |
return 0; |
#endif /* _REENT_SMALL */ |
CHECK_INIT (ptr, fp); |
if (!fp->_flags) |
return 0; |
_flockfile (fp); |
ret = __sflush_r (ptr, fp); |
_funlockfile (fp); |
return ret; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fflush, (fp), |
register FILE * fp) |
{ |
if (fp == NULL) |
return _fwalk_reent (_GLOBAL_REENT, _fflush_r); |
return _fflush_r (_REENT, fp); |
} |
#endif /* _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fgetc.c |
---|
0,0 → 1,106 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fgetc>>---get a character from a file or stream |
INDEX |
fgetc |
INDEX |
_fgetc_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fgetc(FILE *<[fp]>); |
#include <stdio.h> |
int _fgetc_r(struct _reent *<[ptr]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int fgetc(<[fp]>) |
FILE *<[fp]>; |
#include <stdio.h> |
int _fgetc_r(<[ptr]>, <[fp]>) |
struct _reent *<[ptr]>; |
FILE *<[fp]>; |
DESCRIPTION |
Use <<fgetc>> to get the next single character from the file or stream |
identified by <[fp]>. As a side effect, <<fgetc>> advances the file's |
current position indicator. |
For a macro version of this function, see <<getc>>. |
The function <<_fgetc_r>> is simply a reentrant version of |
<<fgetc>> that is passed the additional reentrant structure |
pointer argument: <[ptr]>. |
RETURNS |
The next character (read as an <<unsigned char>>, and cast to |
<<int>>), unless there is no more data, or the host system reports a |
read error; in either of these situations, <<fgetc>> returns <<EOF>>. |
You can distinguish the two situations that cause an <<EOF>> result by |
using the <<ferror>> and <<feof>> functions. |
PORTABILITY |
ANSI C requires <<fgetc>>. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include "local.h" |
int |
_DEFUN(_fgetc_r, (ptr, fp), |
struct _reent * ptr _AND |
FILE * fp) |
{ |
int result; |
CHECK_INIT(ptr, fp); |
_flockfile (fp); |
result = __sgetc_r (ptr, fp); |
_funlockfile (fp); |
return result; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fgetc, (fp), |
FILE * fp) |
{ |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
int result; |
CHECK_INIT(_REENT, fp); |
_flockfile (fp); |
result = __sgetc_r (_REENT, fp); |
_funlockfile (fp); |
return result; |
#else |
return _fgetc_r (_REENT, fp); |
#endif |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fgets.c |
---|
0,0 → 1,187 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fgets>>---get character string from a file or stream |
INDEX |
fgets |
INDEX |
_fgets_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
char *fgets(char *<[buf]>, int <[n]>, FILE *<[fp]>); |
#include <stdio.h> |
char *_fgets_r(struct _reent *<[ptr]>, char *<[buf]>, int <[n]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
char *fgets(<[buf]>,<[n]>,<[fp]>) |
char *<[buf]>; |
int <[n]>; |
FILE *<[fp]>; |
#include <stdio.h> |
char *_fgets_r(<[ptr]>, <[buf]>,<[n]>,<[fp]>) |
struct _reent *<[ptr]>; |
char *<[buf]>; |
int <[n]>; |
FILE *<[fp]>; |
DESCRIPTION |
Reads at most <[n-1]> characters from <[fp]> until a newline |
is found. The characters including to the newline are stored |
in <[buf]>. The buffer is terminated with a 0. |
The <<_fgets_r>> function is simply the reentrant version of |
<<fgets>> and is passed an additional reentrancy structure |
pointer: <[ptr]>. |
RETURNS |
<<fgets>> returns the buffer passed to it, with the data |
filled in. If end of file occurs with some data already |
accumulated, the data is returned with no other indication. If |
no data are read, NULL is returned instead. |
PORTABILITY |
<<fgets>> should replace all uses of <<gets>>. Note however |
that <<fgets>> returns all of the data, while <<gets>> removes |
the trailing newline (with no indication that it has done so.) |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include <string.h> |
#include "local.h" |
/* |
* Read at most n-1 characters from the given file. |
* Stop when a newline has been read, or the count runs out. |
* Return first argument, or NULL if no characters were read. |
*/ |
char * |
_DEFUN(_fgets_r, (ptr, buf, n, fp), |
struct _reent * ptr _AND |
char *buf _AND |
int n _AND |
FILE * fp) |
{ |
size_t len; |
char *s; |
unsigned char *p, *t; |
if (n < 2) /* sanity check */ |
return 0; |
s = buf; |
CHECK_INIT(ptr, fp); |
_flockfile (fp); |
#ifdef __SCLE |
if (fp->_flags & __SCLE) |
{ |
int c; |
/* Sorry, have to do it the slow way */ |
while (--n > 0 && (c = __sgetc_r (ptr, fp)) != EOF) |
{ |
*s++ = c; |
if (c == '\n') |
break; |
} |
if (c == EOF && s == buf) |
{ |
_funlockfile (fp); |
return NULL; |
} |
*s = 0; |
_funlockfile (fp); |
return buf; |
} |
#endif |
n--; /* leave space for NUL */ |
do |
{ |
/* |
* If the buffer is empty, refill it. |
*/ |
if ((len = fp->_r) <= 0) |
{ |
if (__srefill_r (ptr, fp)) |
{ |
/* EOF: stop with partial or no line */ |
if (s == buf) |
{ |
_funlockfile (fp); |
return 0; |
} |
break; |
} |
len = fp->_r; |
} |
p = fp->_p; |
/* |
* Scan through at most n bytes of the current buffer, |
* looking for '\n'. If found, copy up to and including |
* newline, and stop. Otherwise, copy entire chunk |
* and loop. |
*/ |
if (len > n) |
len = n; |
t = (unsigned char *) memchr ((_PTR) p, '\n', len); |
if (t != 0) |
{ |
len = ++t - p; |
fp->_r -= len; |
fp->_p = t; |
_CAST_VOID memcpy ((_PTR) s, (_PTR) p, len); |
s[len] = 0; |
_funlockfile (fp); |
return (buf); |
} |
fp->_r -= len; |
fp->_p += len; |
_CAST_VOID memcpy ((_PTR) s, (_PTR) p, len); |
s += len; |
} |
while ((n -= len) != 0); |
*s = 0; |
_funlockfile (fp); |
return buf; |
} |
#ifndef _REENT_ONLY |
char * |
_DEFUN(fgets, (buf, n, fp), |
char *buf _AND |
int n _AND |
FILE * fp) |
{ |
return _fgets_r (_REENT, buf, n, fp); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fileno.c |
---|
0,0 → 1,62 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fileno>>---return file descriptor associated with stream |
INDEX |
fileno |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fileno(FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int fileno(<[fp]>) |
FILE *<[fp]>; |
DESCRIPTION |
You can use <<fileno>> to return the file descriptor identified by <[fp]>. |
RETURNS |
<<fileno>> returns a non-negative integer when successful. |
If <[fp]> is not an open stream, <<fileno>> returns -1. |
PORTABILITY |
<<fileno>> is not part of ANSI C. |
POSIX requires <<fileno>>. |
Supporting OS subroutines required: none. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include "local.h" |
int |
_DEFUN(fileno, (f), |
FILE * f) |
{ |
int result; |
CHECK_INIT (_REENT, f); |
_flockfile (f); |
result = __sfileno (f); |
_funlockfile (f); |
return result; |
} |
/contrib/sdk/sources/libc/stdio/findfp.c |
---|
0,0 → 1,294 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <errno.h> |
#include <string.h> |
#include <fcntl.h> |
#include <sys/lock.h> |
#include "local.h" |
#ifdef _REENT_SMALL |
const struct __sFILE_fake __sf_fake_stdin = |
{_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL}; |
const struct __sFILE_fake __sf_fake_stdout = |
{_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL}; |
const struct __sFILE_fake __sf_fake_stderr = |
{_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL}; |
#endif |
static _VOID |
_DEFUN(std, (ptr, flags, file, data), |
FILE *ptr _AND |
int flags _AND |
int file _AND |
struct _reent *data) |
{ |
ptr->_p = 0; |
ptr->_r = 0; |
ptr->_w = 0; |
ptr->_flags = flags; |
ptr->_flags2 = 0; |
ptr->_file = file; |
ptr->_bf._base = 0; |
ptr->_bf._size = 0; |
ptr->_lbfsize = 0; |
memset (&ptr->_mbstate, 0, sizeof (_mbstate_t)); |
ptr->_cookie = ptr; |
ptr->_read = __sread; |
#ifndef __LARGE64_FILES |
ptr->_write = __swrite; |
#else /* __LARGE64_FILES */ |
ptr->_write = __swrite64; |
ptr->_seek64 = __sseek64; |
ptr->_flags |= __SL64; |
#endif /* __LARGE64_FILES */ |
ptr->_seek = __sseek; |
ptr->_close = __sclose; |
#if !defined(__SINGLE_THREAD__) && !defined(_REENT_SMALL) |
__lock_init_recursive (ptr->_lock); |
/* |
* #else |
* lock is already initialized in __sfp |
*/ |
#endif |
#ifdef __SCLE |
if (__stextmode (ptr->_file)) |
ptr->_flags |= __SCLE; |
#endif |
} |
struct _glue * |
_DEFUN(__sfmoreglue, (d, n), |
struct _reent *d _AND |
register int n) |
{ |
struct _glue *g; |
FILE *p; |
g = (struct _glue *) _malloc_r (d, sizeof (*g) + n * sizeof (FILE)); |
if (g == NULL) |
return NULL; |
p = (FILE *) (g + 1); |
g->_next = NULL; |
g->_niobs = n; |
g->_iobs = p; |
memset (p, 0, n * sizeof (FILE)); |
return g; |
} |
/* |
* Find a free FILE for fopen et al. |
*/ |
FILE * |
_DEFUN(__sfp, (d), |
struct _reent *d) |
{ |
FILE *fp; |
int n; |
struct _glue *g; |
__sfp_lock_acquire (); |
if (!_GLOBAL_REENT->__sdidinit) |
__sinit (_GLOBAL_REENT); |
for (g = &_GLOBAL_REENT->__sglue;; g = g->_next) |
{ |
for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++) |
if (fp->_flags == 0) |
goto found; |
if (g->_next == NULL && |
(g->_next = __sfmoreglue (d, NDYNAMIC)) == NULL) |
break; |
} |
__sfp_lock_release (); |
d->_errno = ENOMEM; |
return NULL; |
found: |
fp->_file = -1; /* no file */ |
fp->_flags = 1; /* reserve this slot; caller sets real flags */ |
fp->_flags2 = 0; |
#ifndef __SINGLE_THREAD__ |
__lock_init_recursive (fp->_lock); |
#endif |
__sfp_lock_release (); |
fp->_p = NULL; /* no current pointer */ |
fp->_w = 0; /* nothing to read or write */ |
fp->_r = 0; |
fp->_bf._base = NULL; /* no buffer */ |
fp->_bf._size = 0; |
fp->_lbfsize = 0; /* not line buffered */ |
memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); |
/* fp->_cookie = <any>; */ /* caller sets cookie, _read/_write etc */ |
fp->_ub._base = NULL; /* no ungetc buffer */ |
fp->_ub._size = 0; |
fp->_lb._base = NULL; /* no line buffer */ |
fp->_lb._size = 0; |
return fp; |
} |
/* |
* exit() calls _cleanup() through *__cleanup, set whenever we |
* open or buffer a file. This chicanery is done so that programs |
* that do not use stdio need not link it all in. |
* |
* The name `_cleanup' is, alas, fairly well known outside stdio. |
*/ |
_VOID |
_DEFUN(_cleanup_r, (ptr), |
struct _reent *ptr) |
{ |
_CAST_VOID _fwalk(ptr, fclose); |
/* _CAST_VOID _fwalk (ptr, fflush); */ /* `cheating' */ |
} |
#ifndef _REENT_ONLY |
_VOID |
_DEFUN_VOID(_cleanup) |
{ |
_cleanup_r (_GLOBAL_REENT); |
} |
#endif |
/* |
* __sinit() is called whenever stdio's internal variables must be set up. |
*/ |
_VOID |
_DEFUN(__sinit, (s), |
struct _reent *s) |
{ |
__sinit_lock_acquire (); |
if (s->__sdidinit) |
{ |
__sinit_lock_release (); |
return; |
} |
/* make sure we clean up on exit */ |
s->__cleanup = _cleanup_r; /* conservative */ |
s->__sdidinit = 1; |
s->__sglue._next = NULL; |
#ifndef _REENT_SMALL |
s->__sglue._niobs = 3; |
s->__sglue._iobs = &s->__sf[0]; |
#else |
s->__sglue._niobs = 0; |
s->__sglue._iobs = NULL; |
s->_stdin = __sfp(s); |
s->_stdout = __sfp(s); |
s->_stderr = __sfp(s); |
#endif |
std (s->_stdin, __SRD, 0, s); |
/* On platforms that have true file system I/O, we can verify |
whether stdout is an interactive terminal or not, as part of |
__smakebuf on first use of the stream. For all other platforms, |
we will default to line buffered mode here. Technically, POSIX |
requires both stdin and stdout to be line-buffered, but tradition |
leaves stdin alone on systems without fcntl. */ |
#ifdef HAVE_FCNTL |
std (s->_stdout, __SWR, 1, s); |
#else |
std (s->_stdout, __SWR | __SLBF, 1, s); |
#endif |
/* POSIX requires stderr to be opened for reading and writing, even |
when the underlying fd 2 is write-only. */ |
std (s->_stderr, __SRW | __SNBF, 2, s); |
__sinit_lock_release (); |
} |
#ifndef __SINGLE_THREAD__ |
__LOCK_INIT_RECURSIVE(static, __sfp_lock); |
__LOCK_INIT_RECURSIVE(static, __sinit_lock); |
_VOID |
_DEFUN_VOID(__sfp_lock_acquire) |
{ |
__lock_acquire_recursive (__sfp_lock); |
} |
_VOID |
_DEFUN_VOID(__sfp_lock_release) |
{ |
__lock_release_recursive (__sfp_lock); |
} |
_VOID |
_DEFUN_VOID(__sinit_lock_acquire) |
{ |
__lock_acquire_recursive (__sinit_lock); |
} |
_VOID |
_DEFUN_VOID(__sinit_lock_release) |
{ |
__lock_release_recursive (__sinit_lock); |
} |
/* Walkable file locking routine. */ |
static int |
_DEFUN(__fp_lock, (ptr), |
FILE * ptr) |
{ |
_flockfile (ptr); |
return 0; |
} |
/* Walkable file unlocking routine. */ |
static int |
_DEFUN(__fp_unlock, (ptr), |
FILE * ptr) |
{ |
_funlockfile (ptr); |
return 0; |
} |
_VOID |
_DEFUN_VOID(__fp_lock_all) |
{ |
__sfp_lock_acquire (); |
_CAST_VOID _fwalk (_REENT, __fp_lock); |
} |
_VOID |
_DEFUN_VOID(__fp_unlock_all) |
{ |
_CAST_VOID _fwalk (_REENT, __fp_unlock); |
__sfp_lock_release (); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/fiprintf.c |
---|
0,0 → 1,55 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in siprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdarg.h> |
int |
_DEFUN(_fiprintf_r, (ptr, fp, fmt), |
struct _reent *ptr _AND |
FILE * fp _AND |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
va_start (ap, fmt); |
ret = _vfiprintf_r (ptr, fp, fmt, ap); |
va_end (ap); |
return ret; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fiprintf, (fp, fmt), |
FILE * fp _AND |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
va_start (ap, fmt); |
ret = _vfiprintf_r (_REENT, fp, fmt, ap); |
va_end (ap); |
return ret; |
} |
#endif /* ! _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fiscanf.c |
---|
0,0 → 1,78 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include "local.h" |
#ifndef _REENT_ONLY |
int |
#ifdef _HAVE_STDC |
fiscanf(FILE *fp, _CONST char *fmt, ...) |
#else |
fiscanf(FILE *fp, fmt, va_alist) |
FILE *fp; |
char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = __svfiscanf_r (_REENT, fp, fmt, ap); |
va_end (ap); |
return ret; |
} |
#endif /* !_REENT_ONLY */ |
int |
#ifdef _HAVE_STDC |
_fiscanf_r(struct _reent *ptr, FILE *fp, _CONST char *fmt, ...) |
#else |
_fiscanf_r(ptr, FILE *fp, fmt, va_alist) |
struct _reent *ptr; |
FILE *fp; |
char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = __svfiscanf_r (ptr, fp, fmt, ap); |
va_end (ap); |
return (ret); |
} |
/contrib/sdk/sources/libc/stdio/flags.c |
---|
0,0 → 1,86 |
/* |
* Copyright (c) 1990 Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92 */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <time.h> |
#include <fcntl.h> |
#include <errno.h> |
#include <sys/types.h> |
/* |
* Return the (stdio) flags for a given mode. Store the flags |
* to be passed to an open() syscall through *optr. |
* Return 0 on error. |
*/ |
int |
_DEFUN(__sflags, (ptr, mode, optr), |
struct _reent *ptr _AND |
register char *mode _AND |
int *optr) |
{ |
register int ret, m, o; |
switch (mode[0]) |
{ |
case 'r': /* open for reading */ |
ret = __SRD; |
m = O_RDONLY; |
o = 0; |
break; |
case 'w': /* open for writing */ |
ret = __SWR; |
m = O_WRONLY; |
o = O_CREAT | O_TRUNC; |
break; |
case 'a': /* open for appending */ |
ret = __SWR | __SAPP; |
m = O_WRONLY; |
o = O_CREAT | O_APPEND; |
break; |
default: /* illegal mode */ |
ptr->_errno = EINVAL; |
return (0); |
} |
if (mode[1] && (mode[1] == '+' || mode[2] == '+')) |
{ |
ret = (ret & ~(__SRD | __SWR)) | __SRW; |
m = O_RDWR; |
} |
if (mode[1] && (mode[1] == 'b' || mode[2] == 'b')) |
{ |
#ifdef O_BINARY |
m |= O_BINARY; |
#endif |
} |
#ifdef __CYGWIN__ |
else if (mode[1] && (mode[1] == 't' || mode[2] == 't')) |
#else |
else |
#endif |
{ |
#ifdef O_TEXT |
m |= O_TEXT; |
#endif |
} |
*optr = m | o; |
return ret; |
} |
/contrib/sdk/sources/libc/stdio/floatio.h |
---|
0,0 → 1,32 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
* |
* %W% (Berkeley) %G% |
*/ |
/* |
* Floating point scanf/printf (input/output) definitions. |
*/ |
#ifdef _NO_LONGDBL |
/* 11-bit exponent (VAX G floating point) is 308 decimal digits */ |
#define MAXEXP 308 |
#else /* !_NO_LONGDBL */ |
/* 15-bit exponent (Intel extended floating point) is 4932 decimal digits */ |
#define MAXEXP 4932 |
#endif /* !_NO_LONGDBL */ |
/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */ |
#define MAXFRACT 39 |
/contrib/sdk/sources/libc/stdio/fopen.c |
---|
0,0 → 1,184 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fopen>>---open a file |
INDEX |
fopen |
INDEX |
_fopen_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
FILE *fopen(const char *<[file]>, const char *<[mode]>); |
FILE *_fopen_r(struct _reent *<[reent]>, |
const char *<[file]>, const char *<[mode]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
FILE *fopen(<[file]>, <[mode]>) |
char *<[file]>; |
char *<[mode]>; |
FILE *_fopen_r(<[reent]>, <[file]>, <[mode]>) |
struct _reent *<[reent]>; |
char *<[file]>; |
char *<[mode]>; |
DESCRIPTION |
<<fopen>> initializes the data structures needed to read or write a |
file. Specify the file's name as the string at <[file]>, and the kind |
of access you need to the file with the string at <[mode]>. |
The alternate function <<_fopen_r>> is a reentrant version. |
The extra argument <[reent]> is a pointer to a reentrancy structure. |
Three fundamental kinds of access are available: read, write, and append. |
<<*<[mode]>>> must begin with one of the three characters `<<r>>', |
`<<w>>', or `<<a>>', to select one of these: |
o+ |
o r |
Open the file for reading; the operation will fail if the file does |
not exist, or if the host system does not permit you to read it. |
o w |
Open the file for writing @emph{from the beginning} of the file: |
effectively, this always creates a new file. If the file whose name you |
specified already existed, its old contents are discarded. |
o a |
Open the file for appending data, that is writing from the end of |
file. When you open a file this way, all data always goes to the |
current end of file; you cannot change this using <<fseek>>. |
o- |
Some host systems distinguish between ``binary'' and ``text'' files. |
Such systems may perform data transformations on data written to, or |
read from, files opened as ``text''. |
If your system is one of these, then you can append a `<<b>>' to any |
of the three modes above, to specify that you are opening the file as |
a binary file (the default is to open the file as a text file). |
`<<rb>>', then, means ``read binary''; `<<wb>>', ``write binary''; and |
`<<ab>>', ``append binary''. |
To make C programs more portable, the `<<b>>' is accepted on all |
systems, whether or not it makes a difference. |
Finally, you might need to both read and write from the same file. |
You can also append a `<<+>>' to any of the three modes, to permit |
this. (If you want to append both `<<b>>' and `<<+>>', you can do it |
in either order: for example, <<"rb+">> means the same thing as |
<<"r+b">> when used as a mode string.) |
Use <<"r+">> (or <<"rb+">>) to permit reading and writing anywhere in |
an existing file, without discarding any data; <<"w+">> (or <<"wb+">>) |
to create a new file (or begin by discarding all data from an old one) |
that permits reading and writing anywhere in it; and <<"a+">> (or |
<<"ab+">>) to permit reading anywhere in an existing file, but writing |
only at the end. |
RETURNS |
<<fopen>> returns a file pointer which you can use for other file |
operations, unless the file you requested could not be opened; in that |
situation, the result is <<NULL>>. If the reason for failure was an |
invalid string at <[mode]>, <<errno>> is set to <<EINVAL>>. |
PORTABILITY |
<<fopen>> is required by ANSI C. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<open>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <errno.h> |
#include <sys/lock.h> |
#ifdef __CYGWIN__ |
#include <fcntl.h> |
#endif |
#include "local.h" |
FILE * |
_DEFUN(_fopen_r, (ptr, file, mode), |
struct _reent *ptr _AND |
_CONST char *file _AND |
_CONST char *mode) |
{ |
register FILE *fp; |
register int f; |
int flags, oflags; |
if ((flags = __sflags (ptr, mode, &oflags)) == 0) |
return NULL; |
if ((fp = __sfp (ptr)) == NULL) |
return NULL; |
if ((f = _open_r (ptr, file, oflags, 0666)) < 0) |
{ |
__sfp_lock_acquire (); |
fp->_flags = 0; /* release */ |
#ifndef __SINGLE_THREAD__ |
__lock_close_recursive (fp->_lock); |
#endif |
__sfp_lock_release (); |
return NULL; |
} |
_flockfile (fp); |
fp->_file = f; |
fp->_flags = flags; |
fp->_cookie = (_PTR) fp; |
fp->_read = __sread; |
fp->_write = __swrite; |
fp->_seek = __sseek; |
fp->_close = __sclose; |
if (fp->_flags & __SAPP) |
_fseek_r (ptr, fp, 0, SEEK_END); |
#ifdef __SCLE |
if (__stextmode (fp->_file)) |
fp->_flags |= __SCLE; |
#endif |
_funlockfile (fp); |
return fp; |
} |
#ifndef _REENT_ONLY |
FILE * |
_DEFUN(fopen, (file, mode), |
_CONST char *file _AND |
_CONST char *mode) |
{ |
return _fopen_r (_REENT, file, mode); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/fprintf.c |
---|
0,0 → 1,55 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in sprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdarg.h> |
int |
_DEFUN(_fprintf_r, (ptr, fp, fmt), |
struct _reent *ptr _AND |
FILE *fp _AND |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
va_start (ap, fmt); |
ret = _vfprintf_r (ptr, fp, fmt, ap); |
va_end (ap); |
return ret; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fprintf, (fp, fmt), |
FILE *fp _AND |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
va_start (ap, fmt); |
ret = _vfprintf_r (_REENT, fp, fmt, ap); |
va_end (ap); |
return ret; |
} |
#endif /* ! _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fputc.c |
---|
0,0 → 1,109 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fputc>>---write a character on a stream or file |
INDEX |
fputc |
INDEX |
_fputc_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fputc(int <[ch]>, FILE *<[fp]>); |
#include <stdio.h> |
int _fputc_r(struct _rent *<[ptr]>, int <[ch]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int fputc(<[ch]>, <[fp]>) |
int <[ch]>; |
FILE *<[fp]>; |
#include <stdio.h> |
int _fputc_r(<[ptr]>, <[ch]>, <[fp]>) |
struct _reent *<[ptr]>; |
int <[ch]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<fputc>> converts the argument <[ch]> from an <<int>> to an |
<<unsigned char>>, then writes it to the file or stream identified by |
<[fp]>. |
If the file was opened with append mode (or if the stream cannot |
support positioning), then the new character goes at the end of the |
file or stream. Otherwise, the new character is written at the |
current value of the position indicator, and the position indicator |
oadvances by one. |
For a macro version of this function, see <<putc>>. |
The <<_fputc_r>> function is simply a reentrant version of <<fputc>> |
that takes an additional reentrant structure argument: <[ptr]>. |
RETURNS |
If successful, <<fputc>> returns its argument <[ch]>. If an error |
intervenes, the result is <<EOF>>. You can use `<<ferror(<[fp]>)>>' to |
query for errors. |
PORTABILITY |
<<fputc>> is required by ANSI C. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include "local.h" |
int |
_DEFUN(_fputc_r, (ptr, ch, file), |
struct _reent *ptr _AND |
int ch _AND |
FILE * file) |
{ |
int result; |
CHECK_INIT(ptr, file); |
_flockfile (file); |
result = _putc_r (ptr, ch, file); |
_funlockfile (file); |
return result; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fputc, (ch, file), |
int ch _AND |
FILE * file) |
{ |
#if !defined(__OPTIMIZE_SIZE__) && !defined(PREFER_SIZE_OVER_SPEED) |
int result; |
CHECK_INIT(_REENT, file); |
_flockfile (file); |
result = _putc_r (_REENT, ch, file); |
_funlockfile (file); |
return result; |
#else |
return _fputc_r (_REENT, ch, file); |
#endif |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fputs.c |
---|
0,0 → 1,106 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fputs>>---write a character string in a file or stream |
INDEX |
fputs |
INDEX |
_fputs_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fputs(const char *<[s]>, FILE *<[fp]>); |
#include <stdio.h> |
int _fputs_r(struct _reent *<[ptr]>, const char *<[s]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int fputs(<[s]>, <[fp]>) |
char *<[s]>; |
FILE *<[fp]>; |
#include <stdio.h> |
int _fputs_r(<[ptr]>, <[s]>, <[fp]>) |
struct _reent *<[ptr]>; |
char *<[s]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<fputs>> writes the string at <[s]> (but without the trailing null) |
to the file or stream identified by <[fp]>. |
<<_fputs_r>> is simply the reentrant version of <<fputs>> that takes |
an additional reentrant struct pointer argument: <[ptr]>. |
RETURNS |
If successful, the result is <<0>>; otherwise, the result is <<EOF>>. |
PORTABILITY |
ANSI C requires <<fputs>>, but does not specify that the result on |
success must be <<0>>; any non-negative value is permitted. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include <string.h> |
#include "fvwrite.h" |
#include "local.h" |
/* |
* Write the given string to the given file. |
*/ |
int |
_DEFUN(_fputs_r, (ptr, s, fp), |
struct _reent * ptr _AND |
char _CONST * s _AND |
FILE * fp) |
{ |
int result; |
struct __suio uio; |
struct __siov iov; |
iov.iov_base = s; |
iov.iov_len = uio.uio_resid = strlen (s); |
uio.uio_iov = &iov; |
uio.uio_iovcnt = 1; |
CHECK_INIT(ptr, fp); |
_flockfile (fp); |
ORIENT (fp, -1); |
result = __sfvwrite_r (ptr, fp, &uio); |
_funlockfile (fp); |
return result; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fputs, (s, fp), |
char _CONST * s _AND |
FILE * fp) |
{ |
return _fputs_r (_REENT, s, fp); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fputwc.c |
---|
0,0 → 1,177 |
/*- |
* Copyright (c) 2002-2004 Tim J. Robbins. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<fputwc>>, <<putwc>>---write a wide character on a stream or file |
INDEX |
fputwc |
INDEX |
_fputwc_r |
INDEX |
putwc |
INDEX |
_putwc_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
#include <wchar.h> |
wint_t fputwc(wchar_t <[wc]>, FILE *<[fp]>); |
#include <stdio.h> |
#include <wchar.h> |
wint_t _fputwc_r(struct _reent *<[ptr]>, wchar_t <[wc]>, FILE *<[fp]>); |
#include <stdio.h> |
#include <wchar.h> |
wint_t putwc(wchar_t <[wc]>, FILE *<[fp]>); |
#include <stdio.h> |
#include <wchar.h> |
wint_t _putwc_r(struct _reent *<[ptr]>, wchar_t <[wc]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
#include <wchar.h> |
wint_t fputwc(<[wc]>, <[fp]>) |
wchar_t <[wc]>; |
FILE *<[fp]>; |
#include <stdio.h> |
#include <wchar.h> |
wint_t _fputwc_r(<[ptr]>, <[wc]>, <[fp]>) |
struct _reent *<[ptr]>; |
wchar_t <[wc]>; |
FILE *<[fp]>; |
#include <stdio.h> |
#include <wchar.h> |
wint_t putwc(<[wc]>, <[fp]>) |
wchar_t <[wc]>; |
FILE *<[fp]>; |
#include <stdio.h> |
#include <wchar.h> |
wint_t _putwc_r(<[ptr]>, <[wc]>, <[fp]>) |
struct _reent *<[ptr]>; |
wchar_t <[wc]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<fputwc>> writes the wide character argument <[wc]> to the file or |
stream identified by <[fp]>. |
If the file was opened with append mode (or if the stream cannot |
support positioning), then the new wide character goes at the end of the |
file or stream. Otherwise, the new wide character is written at the |
current value of the position indicator, and the position indicator |
oadvances by one. |
The <<putwc>> function or macro functions identically to <<fputwc>>. It |
may be implemented as a macro, and may evaluate its argument more than |
once. There is no reason ever to use it. |
The <<_fputwc_r>> and <<_putwc_r>> functions are simply reentrant versions |
of <<fputwc>> and <<putwc>> that take an additional reentrant structure |
argument: <[ptr]>. |
RETURNS |
If successful, <<fputwc>> and <<putwc>> return their argument <[wc]>. |
If an error intervenes, the result is <<EOF>>. You can use |
`<<ferror(<[fp]>)>>' to query for errors. |
PORTABILITY |
C99, POSIX.1-2001 |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <errno.h> |
#include <limits.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <wchar.h> |
#include "local.h" |
static wint_t |
_DEFUN(__fputwc, (ptr, wc, fp), |
struct _reent *ptr _AND |
wchar_t wc _AND |
FILE *fp) |
{ |
char buf[MB_LEN_MAX]; |
size_t i, len; |
if (MB_CUR_MAX == 1 && wc > 0 && wc <= UCHAR_MAX) |
{ |
/* |
* Assume single-byte locale with no special encoding. |
* A more careful test would be to check |
* _CurrentRuneLocale->encoding. |
*/ |
*buf = (unsigned char)wc; |
len = 1; |
} |
else |
{ |
if ((len = _wcrtomb_r (ptr, buf, wc, &fp->_mbstate)) == (size_t) -1) |
{ |
fp->_flags |= __SERR; |
return WEOF; |
} |
} |
for (i = 0; i < len; i++) |
if (__sputc_r (ptr, (unsigned char) buf[i], fp) == EOF) |
return WEOF; |
return (wint_t) wc; |
} |
wint_t |
_DEFUN(_fputwc_r, (ptr, wc, fp), |
struct _reent *ptr _AND |
wchar_t wc _AND |
FILE *fp) |
{ |
wint_t r; |
_flockfile (fp); |
ORIENT(fp, 1); |
r = __fputwc(ptr, wc, fp); |
_funlockfile (fp); |
return r; |
} |
wint_t |
_DEFUN(fputwc, (wc, fp), |
wchar_t wc _AND |
FILE *fp) |
{ |
CHECK_INIT(_REENT, fp); |
return _fputwc_r (_REENT, wc, fp); |
} |
/contrib/sdk/sources/libc/stdio/fread.c |
---|
0,0 → 1,258 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fread>>---read array elements from a file |
INDEX |
fread |
INDEX |
_fread_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
size_t fread(void *<[buf]>, size_t <[size]>, size_t <[count]>, |
FILE *<[fp]>); |
#include <stdio.h> |
size_t _fread_r(struct _reent *<[ptr]>, void *<[buf]>, |
size_t <[size]>, size_t <[count]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
size_t fread(<[buf]>, <[size]>, <[count]>, <[fp]>) |
char *<[buf]>; |
size_t <[size]>; |
size_t <[count]>; |
FILE *<[fp]>; |
#include <stdio.h> |
size_t _fread_r(<[ptr]>, <[buf]>, <[size]>, <[count]>, <[fp]>) |
struct _reent *<[ptr]>; |
char *<[buf]>; |
size_t <[size]>; |
size_t <[count]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<fread>> attempts to copy, from the file or stream identified by |
<[fp]>, <[count]> elements (each of size <[size]>) into memory, |
starting at <[buf]>. <<fread>> may copy fewer elements than |
<[count]> if an error, or end of file, intervenes. |
<<fread>> also advances the file position indicator (if any) for |
<[fp]> by the number of @emph{characters} actually read. |
<<_fread_r>> is simply the reentrant version of <<fread>> that |
takes an additional reentrant structure pointer argument: <[ptr]>. |
RETURNS |
The result of <<fread>> is the number of elements it succeeded in |
reading. |
PORTABILITY |
ANSI C requires <<fread>>. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include <string.h> |
#include <malloc.h> |
#include "local.h" |
#ifdef __SCLE |
static size_t |
_DEFUN(crlf_r, (ptr, fp, buf, count, eof), |
struct _reent * ptr _AND |
FILE * fp _AND |
char * buf _AND |
size_t count _AND |
int eof) |
{ |
int r; |
char *s, *d, *e; |
if (count == 0) |
return 0; |
e = buf + count; |
for (s=d=buf; s<e-1; s++) |
{ |
if (*s == '\r' && s[1] == '\n') |
s++; |
*d++ = *s; |
} |
if (s < e) |
{ |
if (*s == '\r') |
{ |
int c = __sgetc_raw_r (ptr, fp); |
if (c == '\n') |
*s = '\n'; |
else |
ungetc (c, fp); |
} |
*d++ = *s++; |
} |
while (d < e) |
{ |
r = _getc_r (ptr, fp); |
if (r == EOF) |
return count - (e-d); |
*d++ = r; |
} |
return count; |
} |
#endif |
size_t |
_DEFUN(_fread_r, (ptr, buf, size, count, fp), |
struct _reent * ptr _AND |
_PTR buf _AND |
size_t size _AND |
size_t count _AND |
FILE * fp) |
{ |
register size_t resid; |
register char *p; |
register int r; |
size_t total; |
if ((resid = count * size) == 0) |
return 0; |
CHECK_INIT(ptr, fp); |
_flockfile (fp); |
ORIENT (fp, -1); |
if (fp->_r < 0) |
fp->_r = 0; |
total = resid; |
p = buf; |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
/* Optimize unbuffered I/O. */ |
if (fp->_flags & __SNBF) |
{ |
/* First copy any available characters from ungetc buffer. */ |
int copy_size = resid > fp->_r ? fp->_r : resid; |
_CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, (size_t) copy_size); |
fp->_p += copy_size; |
fp->_r -= copy_size; |
p += copy_size; |
resid -= copy_size; |
/* If still more data needed, free any allocated ungetc buffer. */ |
if (HASUB (fp) && resid > 0) |
FREEUB (ptr, fp); |
/* Finally read directly into user's buffer if needed. */ |
while (resid > 0) |
{ |
int rc = 0; |
/* save fp buffering state */ |
void *old_base = fp->_bf._base; |
void * old_p = fp->_p; |
int old_size = fp->_bf._size; |
/* allow __refill to use user's buffer */ |
fp->_bf._base = (unsigned char *) p; |
fp->_bf._size = resid; |
fp->_p = (unsigned char *) p; |
rc = __srefill_r (ptr, fp); |
/* restore fp buffering back to original state */ |
fp->_bf._base = old_base; |
fp->_bf._size = old_size; |
fp->_p = old_p; |
resid -= fp->_r; |
p += fp->_r; |
fp->_r = 0; |
if (rc) |
{ |
#ifdef __SCLE |
if (fp->_flags & __SCLE) |
{ |
_funlockfile (fp); |
return crlf_r (ptr, fp, buf, total-resid, 1) / size; |
} |
#endif |
_funlockfile (fp); |
return (total - resid) / size; |
} |
} |
} |
else |
#endif /* !PREFER_SIZE_OVER_SPEED && !__OPTIMIZE_SIZE__ */ |
{ |
while (resid > (r = fp->_r)) |
{ |
_CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, (size_t) r); |
fp->_p += r; |
/* fp->_r = 0 ... done in __srefill */ |
p += r; |
resid -= r; |
if (__srefill_r (ptr, fp)) |
{ |
/* no more input: return partial result */ |
#ifdef __SCLE |
if (fp->_flags & __SCLE) |
{ |
_funlockfile (fp); |
return crlf_r (ptr, fp, buf, total-resid, 1) / size; |
} |
#endif |
_funlockfile (fp); |
return (total - resid) / size; |
} |
} |
_CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, resid); |
fp->_r -= resid; |
fp->_p += resid; |
} |
/* Perform any CR/LF clean-up if necessary. */ |
#ifdef __SCLE |
if (fp->_flags & __SCLE) |
{ |
_funlockfile (fp); |
return crlf_r(ptr, fp, buf, total, 0) / size; |
} |
#endif |
_funlockfile (fp); |
return count; |
} |
#ifndef _REENT_ONLY |
size_t |
_DEFUN(fread, (buf, size, count, fp), |
_PTR buf _AND |
size_t size _AND |
size_t count _AND |
FILE * fp) |
{ |
return _fread_r (_REENT, buf, size, count, fp); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/freopen.c |
---|
0,0 → 1,247 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<freopen>>---open a file using an existing file descriptor |
INDEX |
freopen |
INDEX |
_freopen_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
FILE *freopen(const char *<[file]>, const char *<[mode]>, |
FILE *<[fp]>); |
FILE *_freopen_r(struct _reent *<[ptr]>, const char *<[file]>, |
const char *<[mode]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
FILE *freopen(<[file]>, <[mode]>, <[fp]>) |
char *<[file]>; |
char *<[mode]>; |
FILE *<[fp]>; |
FILE *_freopen_r(<[ptr]>, <[file]>, <[mode]>, <[fp]>) |
struct _reent *<[ptr]>; |
char *<[file]>; |
char *<[mode]>; |
FILE *<[fp]>; |
DESCRIPTION |
Use this variant of <<fopen>> if you wish to specify a particular file |
descriptor <[fp]> (notably <<stdin>>, <<stdout>>, or <<stderr>>) for |
the file. |
If <[fp]> was associated with another file or stream, <<freopen>> |
closes that other file or stream (but ignores any errors while closing |
it). |
<[file]> and <[mode]> are used just as in <<fopen>>. |
If <[file]> is <<NULL>>, the underlying stream is modified rather than |
closed. The file cannot be given a more permissive access mode (for |
example, a <[mode]> of "w" will fail on a read-only file descriptor), |
but can change status such as append or binary mode. If modification |
is not possible, failure occurs. |
RETURNS |
If successful, the result is the same as the argument <[fp]>. If the |
file cannot be opened as specified, the result is <<NULL>>. |
PORTABILITY |
ANSI C requires <<freopen>>. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<open>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <time.h> |
#include <stdio.h> |
#include <string.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <stdlib.h> |
#include <sys/lock.h> |
#include "local.h" |
/* |
* Re-direct an existing, open (probably) file to some other file. |
*/ |
FILE * |
_DEFUN(_freopen_r, (ptr, file, mode, fp), |
struct _reent *ptr _AND |
const char *file _AND |
const char *mode _AND |
register FILE *fp) |
{ |
register int f; |
int flags, oflags; |
int e = 0; |
CHECK_INIT (ptr, fp); |
_flockfile (fp); |
if ((flags = __sflags (ptr, mode, &oflags)) == 0) |
{ |
_funlockfile (fp); |
_fclose_r (ptr, fp); |
return NULL; |
} |
/* |
* Remember whether the stream was open to begin with, and |
* which file descriptor (if any) was associated with it. |
* If it was attached to a descriptor, defer closing it, |
* so that, e.g., freopen("/dev/stdin", "r", stdin) works. |
* This is unnecessary if it was not a Unix file. |
*/ |
if (fp->_flags == 0) |
fp->_flags = __SEOF; /* hold on to it */ |
else |
{ |
if (fp->_flags & __SWR) |
_fflush_r (ptr, fp); |
/* |
* If close is NULL, closing is a no-op, hence pointless. |
* If file is NULL, the file should not be closed. |
*/ |
if (fp->_close != NULL && file != NULL) |
fp->_close (ptr, fp->_cookie); |
} |
/* |
* Now get a new descriptor to refer to the new file, or reuse the |
* existing file descriptor if file is NULL. |
*/ |
if (file != NULL) |
{ |
f = _open_r (ptr, (char *) file, oflags, 0666); |
e = ptr->_errno; |
} |
else |
{ |
#ifdef HAVE_FCNTL |
int oldflags; |
/* |
* Reuse the file descriptor, but only if the new access mode is |
* equal or less permissive than the old. F_SETFL correctly |
* ignores creation flags. |
*/ |
f = fp->_file; |
if ((oldflags = _fcntl_r (ptr, f, F_GETFL, 0)) == -1 |
|| ! ((oldflags & O_ACCMODE) == O_RDWR |
|| ((oldflags ^ oflags) & O_ACCMODE) == 0) |
|| _fcntl_r (ptr, f, F_SETFL, oflags) == -1) |
f = -1; |
#else |
/* We cannot modify without fcntl support. */ |
f = -1; |
#endif |
#ifdef __SCLE |
/* |
* F_SETFL doesn't change textmode. Don't mess with modes of ttys. |
*/ |
if (0 <= f && ! _isatty_r (ptr, f) |
&& setmode (f, oflags & (O_BINARY | O_TEXT)) == -1) |
f = -1; |
#endif |
if (f < 0) |
{ |
e = EBADF; |
if (fp->_close != NULL) |
fp->_close (ptr, fp->_cookie); |
} |
} |
/* |
* Finish closing fp. Even if the open succeeded above, |
* we cannot keep fp->_base: it may be the wrong size. |
* This loses the effect of any setbuffer calls, |
* but stdio has always done this before. |
*/ |
if (fp->_flags & __SMBF) |
_free_r (ptr, (char *) fp->_bf._base); |
fp->_w = 0; |
fp->_r = 0; |
fp->_p = NULL; |
fp->_bf._base = NULL; |
fp->_bf._size = 0; |
fp->_lbfsize = 0; |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
fp->_ub._size = 0; |
if (HASLB (fp)) |
FREELB (ptr, fp); |
fp->_lb._size = 0; |
fp->_flags & ~__SORD; |
fp->_flags2 = 0; |
memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); |
if (f < 0) |
{ /* did not get it after all */ |
__sfp_lock_acquire (); |
fp->_flags = 0; /* set it free */ |
ptr->_errno = e; /* restore in case _close clobbered */ |
_funlockfile (fp); |
#ifndef __SINGLE_THREAD__ |
__lock_close_recursive (fp->_lock); |
#endif |
__sfp_lock_release (); |
return NULL; |
} |
fp->_flags = flags; |
fp->_file = f; |
fp->_cookie = (_PTR) fp; |
fp->_read = __sread; |
fp->_write = __swrite; |
fp->_seek = __sseek; |
fp->_close = __sclose; |
#ifdef __SCLE |
if (__stextmode (fp->_file)) |
fp->_flags |= __SCLE; |
#endif |
_funlockfile (fp); |
return fp; |
} |
#ifndef _REENT_ONLY |
FILE * |
_DEFUN(freopen, (file, mode, fp), |
_CONST char *file _AND |
_CONST char *mode _AND |
register FILE *fp) |
{ |
return _freopen_r (_REENT, file, mode, fp); |
} |
#endif /*!_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fscanf.c |
---|
0,0 → 1,78 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include "local.h" |
#ifndef _REENT_ONLY |
int |
#ifdef _HAVE_STDC |
fscanf(FILE *fp, _CONST char *fmt, ...) |
#else |
fscanf(FILE *fp, fmt, va_alist) |
FILE *fp; |
char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _vfscanf_r (_REENT, fp, fmt, ap); |
va_end (ap); |
return ret; |
} |
#endif /* !_REENT_ONLY */ |
int |
#ifdef _HAVE_STDC |
_fscanf_r(struct _reent *ptr, FILE *fp, _CONST char *fmt, ...) |
#else |
_fscanf_r(ptr, FILE *fp, fmt, va_alist) |
struct _reent *ptr; |
FILE *fp; |
char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _vfscanf_r (ptr, fp, fmt, ap); |
va_end (ap); |
return (ret); |
} |
/contrib/sdk/sources/libc/stdio/fseek.c |
---|
0,0 → 1,397 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fseek>>, <<fseeko>>---set file position |
INDEX |
fseek |
INDEX |
fseeko |
INDEX |
_fseek_r |
INDEX |
_fseeko_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int fseek(FILE *<[fp]>, long <[offset]>, int <[whence]>) |
int fseeko(FILE *<[fp]>, off_t <[offset]>, int <[whence]>) |
int _fseek_r(struct _reent *<[ptr]>, FILE *<[fp]>, |
long <[offset]>, int <[whence]>) |
int _fseeko_r(struct _reent *<[ptr]>, FILE *<[fp]>, |
off_t <[offset]>, int <[whence]>) |
TRAD_SYNOPSIS |
#include <stdio.h> |
int fseek(<[fp]>, <[offset]>, <[whence]>) |
FILE *<[fp]>; |
long <[offset]>; |
int <[whence]>; |
int fseeko(<[fp]>, <[offset]>, <[whence]>) |
FILE *<[fp]>; |
off_t <[offset]>; |
int <[whence]>; |
int _fseek_r(<[ptr]>, <[fp]>, <[offset]>, <[whence]>) |
struct _reent *<[ptr]>; |
FILE *<[fp]>; |
long <[offset]>; |
int <[whence]>; |
int _fseeko_r(<[ptr]>, <[fp]>, <[offset]>, <[whence]>) |
struct _reent *<[ptr]>; |
FILE *<[fp]>; |
off_t <[offset]>; |
int <[whence]>; |
DESCRIPTION |
Objects of type <<FILE>> can have a ``position'' that records how much |
of the file your program has already read. Many of the <<stdio>> functions |
depend on this position, and many change it as a side effect. |
You can use <<fseek>>/<<fseeko>> to set the position for the file identified by |
<[fp]>. The value of <[offset]> determines the new position, in one |
of three ways selected by the value of <[whence]> (defined as macros |
in `<<stdio.h>>'): |
<<SEEK_SET>>---<[offset]> is the absolute file position (an offset |
from the beginning of the file) desired. <[offset]> must be positive. |
<<SEEK_CUR>>---<[offset]> is relative to the current file position. |
<[offset]> can meaningfully be either positive or negative. |
<<SEEK_END>>---<[offset]> is relative to the current end of file. |
<[offset]> can meaningfully be either positive (to increase the size |
of the file) or negative. |
See <<ftell>>/<<ftello>> to determine the current file position. |
RETURNS |
<<fseek>>/<<fseeko>> return <<0>> when successful. On failure, the |
result is <<EOF>>. The reason for failure is indicated in <<errno>>: |
either <<ESPIPE>> (the stream identified by <[fp]> doesn't support |
repositioning) or <<EINVAL>> (invalid file position). |
PORTABILITY |
ANSI C requires <<fseek>>. |
<<fseeko>> is defined by the Single Unix specification. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <string.h> |
#include <time.h> |
#include <fcntl.h> |
#include <stdlib.h> |
#include <errno.h> |
#include <sys/stat.h> |
#include "local.h" |
#define POS_ERR (-(_fpos_t)1) |
/* |
* Seek the given file to the given offset. |
* `Whence' must be one of the three SEEK_* macros. |
*/ |
int |
_DEFUN(_fseek_r, (ptr, fp, offset, whence), |
struct _reent *ptr _AND |
register FILE *fp _AND |
long offset _AND |
int whence) |
{ |
_fpos_t _EXFNPTR(seekfn, (struct _reent *, _PTR, _fpos_t, int)); |
_fpos_t target; |
_fpos_t curoff = 0; |
size_t n; |
#ifdef __USE_INTERNAL_STAT64 |
struct stat64 st; |
#else |
struct stat st; |
#endif |
int havepos; |
/* Make sure stdio is set up. */ |
CHECK_INIT (ptr, fp); |
_flockfile (fp); |
/* If we've been doing some writing, and we're in append mode |
then we don't really know where the filepos is. */ |
if (fp->_flags & __SAPP && fp->_flags & __SWR) |
{ |
/* So flush the buffer and seek to the end. */ |
_fflush_r (ptr, fp); |
} |
/* Have to be able to seek. */ |
if ((seekfn = fp->_seek) == NULL) |
{ |
ptr->_errno = ESPIPE; /* ??? */ |
_funlockfile (fp); |
return EOF; |
} |
/* |
* Change any SEEK_CUR to SEEK_SET, and check `whence' argument. |
* After this, whence is either SEEK_SET or SEEK_END. |
*/ |
switch (whence) |
{ |
case SEEK_CUR: |
/* |
* In order to seek relative to the current stream offset, |
* we have to first find the current stream offset a la |
* ftell (see ftell for details). |
*/ |
_fflush_r (ptr, fp); /* may adjust seek offset on append stream */ |
if (fp->_flags & __SOFF) |
curoff = fp->_offset; |
else |
{ |
curoff = seekfn (ptr, fp->_cookie, (_fpos_t) 0, SEEK_CUR); |
if (curoff == -1L) |
{ |
_funlockfile (fp); |
return EOF; |
} |
} |
if (fp->_flags & __SRD) |
{ |
curoff -= fp->_r; |
if (HASUB (fp)) |
curoff -= fp->_ur; |
} |
else if (fp->_flags & __SWR && fp->_p != NULL) |
curoff += fp->_p - fp->_bf._base; |
offset += curoff; |
whence = SEEK_SET; |
havepos = 1; |
break; |
case SEEK_SET: |
case SEEK_END: |
havepos = 0; |
break; |
default: |
ptr->_errno = EINVAL; |
_funlockfile (fp); |
return (EOF); |
} |
/* |
* Can only optimise if: |
* reading (and not reading-and-writing); |
* not unbuffered; and |
* this is a `regular' Unix file (and hence seekfn==__sseek). |
* We must check __NBF first, because it is possible to have __NBF |
* and __SOPT both set. |
*/ |
if (fp->_bf._base == NULL) |
__smakebuf_r (ptr, fp); |
if (fp->_flags & (__SWR | __SRW | __SNBF | __SNPT)) |
goto dumb; |
if ((fp->_flags & __SOPT) == 0) |
{ |
if (seekfn != __sseek |
|| fp->_file < 0 |
#ifdef __USE_INTERNAL_STAT64 |
|| _fstat64_r (ptr, fp->_file, &st) |
#else |
|| _fstat_r (ptr, fp->_file, &st) |
#endif |
|| (st.st_mode & S_IFMT) != S_IFREG) |
{ |
fp->_flags |= __SNPT; |
goto dumb; |
} |
#ifdef HAVE_BLKSIZE |
fp->_blksize = st.st_blksize; |
#else |
fp->_blksize = 1024; |
#endif |
fp->_flags |= __SOPT; |
} |
/* |
* We are reading; we can try to optimise. |
* Figure out where we are going and where we are now. |
*/ |
if (whence == SEEK_SET) |
target = offset; |
else |
{ |
#ifdef __USE_INTERNAL_STAT64 |
if (_fstat64_r (ptr, fp->_file, &st)) |
#else |
if (_fstat_r (ptr, fp->_file, &st)) |
#endif |
goto dumb; |
target = st.st_size + offset; |
} |
if ((long)target != target) |
{ |
ptr->_errno = EOVERFLOW; |
_funlockfile (fp); |
return EOF; |
} |
if (!havepos) |
{ |
if (fp->_flags & __SOFF) |
curoff = fp->_offset; |
else |
{ |
curoff = seekfn (ptr, fp->_cookie, 0L, SEEK_CUR); |
if (curoff == POS_ERR) |
goto dumb; |
} |
curoff -= fp->_r; |
if (HASUB (fp)) |
curoff -= fp->_ur; |
} |
/* |
* Compute the number of bytes in the input buffer (pretending |
* that any ungetc() input has been discarded). Adjust current |
* offset backwards by this count so that it represents the |
* file offset for the first byte in the current input buffer. |
*/ |
if (HASUB (fp)) |
{ |
curoff += fp->_r; /* kill off ungetc */ |
n = fp->_up - fp->_bf._base; |
curoff -= n; |
n += fp->_ur; |
} |
else |
{ |
n = fp->_p - fp->_bf._base; |
curoff -= n; |
n += fp->_r; |
} |
/* |
* If the target offset is within the current buffer, |
* simply adjust the pointers, clear EOF, undo ungetc(), |
* and return. |
*/ |
if (target >= curoff && target < curoff + n) |
{ |
register int o = target - curoff; |
fp->_p = fp->_bf._base + o; |
fp->_r = n - o; |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
fp->_flags &= ~__SEOF; |
memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); |
_funlockfile (fp); |
return 0; |
} |
/* |
* The place we want to get to is not within the current buffer, |
* but we can still be kind to the kernel copyout mechanism. |
* By aligning the file offset to a block boundary, we can let |
* the kernel use the VM hardware to map pages instead of |
* copying bytes laboriously. Using a block boundary also |
* ensures that we only read one block, rather than two. |
*/ |
curoff = target & ~(fp->_blksize - 1); |
if (seekfn (ptr, fp->_cookie, curoff, SEEK_SET) == POS_ERR) |
goto dumb; |
fp->_r = 0; |
fp->_p = fp->_bf._base; |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
fp->_flags &= ~__SEOF; |
n = target - curoff; |
if (n) |
{ |
if (__srefill_r (ptr, fp) || fp->_r < n) |
goto dumb; |
fp->_p += n; |
fp->_r -= n; |
} |
memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); |
_funlockfile (fp); |
return 0; |
/* |
* We get here if we cannot optimise the seek ... just |
* do it. Allow the seek function to change fp->_bf._base. |
*/ |
dumb: |
if (_fflush_r (ptr, fp) |
|| seekfn (ptr, fp->_cookie, offset, whence) == POS_ERR) |
{ |
_funlockfile (fp); |
return EOF; |
} |
/* success: clear EOF indicator and discard ungetc() data */ |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
fp->_p = fp->_bf._base; |
fp->_r = 0; |
/* fp->_w = 0; *//* unnecessary (I think...) */ |
fp->_flags &= ~__SEOF; |
/* Reset no-optimization flag after successful seek. The |
no-optimization flag may be set in the case of a read |
stream that is flushed which by POSIX/SUSv3 standards, |
means that a corresponding seek must not optimize. The |
optimization is then allowed if no subsequent flush |
is performed. */ |
fp->_flags &= ~__SNPT; |
memset (&fp->_mbstate, 0, sizeof (_mbstate_t)); |
_funlockfile (fp); |
return 0; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fseek, (fp, offset, whence), |
register FILE *fp _AND |
long offset _AND |
int whence) |
{ |
return _fseek_r (_REENT, fp, offset, whence); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fseeko.c |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 2002, Red Hat Inc. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
int |
_DEFUN(_fseeko_r, (ptr, fp, offset, whence), |
struct _reent *ptr _AND |
register FILE *fp _AND |
_off_t offset _AND |
int whence) |
{ |
return _fseek_r (ptr, fp, (long)offset, whence); |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(fseeko, (fp, offset, whence), |
register FILE *fp _AND |
_off_t offset _AND |
int whence) |
{ |
/* for now we simply cast since off_t should be long */ |
return _fseek_r (_REENT, fp, (long)offset, whence); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/ftell.c |
---|
0,0 → 1,177 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<ftell>>, <<ftello>>---return position in a stream or file |
INDEX |
ftell |
INDEX |
ftello |
INDEX |
_ftell_r |
INDEX |
_ftello_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
long ftell(FILE *<[fp]>); |
off_t ftello(FILE *<[fp]>); |
long _ftell_r(struct _reent *<[ptr]>, FILE *<[fp]>); |
off_t _ftello_r(struct _reent *<[ptr]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
long ftell(<[fp]>) |
FILE *<[fp]>; |
off_t ftello(<[fp]>) |
FILE *<[fp]>; |
long _ftell_r(<[ptr]>, <[fp]>) |
struct _reent *<[ptr]>; |
FILE *<[fp]>; |
off_t _ftello_r(<[ptr]>, <[fp]>) |
struct _reent *<[ptr]>; |
FILE *<[fp]>; |
DESCRIPTION |
Objects of type <<FILE>> can have a ``position'' that records how much |
of the file your program has already read. Many of the <<stdio>> functions |
depend on this position, and many change it as a side effect. |
The result of <<ftell>>/<<ftello>> is the current position for a file |
identified by <[fp]>. If you record this result, you can later |
use it with <<fseek>>/<<fseeko>> to return the file to this |
position. The difference between <<ftell>> and <<ftello>> is that |
<<ftell>> returns <<long>> and <<ftello>> returns <<off_t>>. |
In the current implementation, <<ftell>>/<<ftello>> simply uses a character |
count to represent the file position; this is the same number that |
would be recorded by <<fgetpos>>. |
RETURNS |
<<ftell>>/<<ftello>> return the file position, if possible. If they cannot do |
this, they return <<-1L>>. Failure occurs on streams that do not support |
positioning; the global <<errno>> indicates this condition with the |
value <<ESPIPE>>. |
PORTABILITY |
<<ftell>> is required by the ANSI C standard, but the meaning of its |
result (when successful) is not specified beyond requiring that it be |
acceptable as an argument to <<fseek>>. In particular, other |
conforming C implementations may return a different result from |
<<ftell>> than what <<fgetpos>> records. |
<<ftello>> is defined by the Single Unix specification. |
No supporting OS subroutines are required. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
/* |
* ftell: return current offset. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <errno.h> |
#include "local.h" |
long |
_DEFUN(_ftell_r, (ptr, fp), |
struct _reent *ptr _AND |
register FILE * fp) |
{ |
_fpos_t pos; |
/* Ensure stdio is set up. */ |
CHECK_INIT (ptr, fp); |
_flockfile (fp); |
if (fp->_seek == NULL) |
{ |
ptr->_errno = ESPIPE; |
_funlockfile (fp); |
return -1L; |
} |
/* Find offset of underlying I/O object, then adjust for buffered |
bytes. Flush a write stream, since the offset may be altered if |
the stream is appending. Do not flush a read stream, since we |
must not lose the ungetc buffer. */ |
if (fp->_flags & __SWR) |
_fflush_r (ptr, fp); |
if (fp->_flags & __SOFF) |
pos = fp->_offset; |
else |
{ |
pos = fp->_seek (ptr, fp->_cookie, (_fpos_t) 0, SEEK_CUR); |
if (pos == -1L) |
{ |
_funlockfile (fp); |
return pos; |
} |
} |
if (fp->_flags & __SRD) |
{ |
/* |
* Reading. Any unread characters (including |
* those from ungetc) cause the position to be |
* smaller than that in the underlying object. |
*/ |
pos -= fp->_r; |
if (HASUB (fp)) |
pos -= fp->_ur; |
} |
else if ((fp->_flags & __SWR) && fp->_p != NULL) |
{ |
/* |
* Writing. Any buffered characters cause the |
* position to be greater than that in the |
* underlying object. |
*/ |
pos += fp->_p - fp->_bf._base; |
} |
_funlockfile (fp); |
if ((long)pos != pos) |
{ |
pos = -1; |
ptr->_errno = EOVERFLOW; |
} |
return pos; |
} |
#ifndef _REENT_ONLY |
long |
_DEFUN(ftell, (fp), |
register FILE * fp) |
{ |
return _ftell_r (_REENT, fp); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/ftello.c |
---|
0,0 → 1,40 |
/* |
* Copyright (c) 2002, Red Hat Inc. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
_off_t |
_DEFUN(_ftello_r, (ptr, fp), |
struct _reent * ptr _AND |
register FILE * fp) |
{ |
/* for now we simply cast since off_t should be long */ |
return (_off_t)_ftell_r (ptr, fp); |
} |
#ifndef _REENT_ONLY |
_off_t |
_DEFUN(ftello, (fp), |
register FILE * fp) |
{ |
return (_off_t)_ftell_r (_REENT, fp); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/fvwrite.c |
---|
0,0 → 1,267 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <string.h> |
#include <stdlib.h> |
#include <errno.h> |
#include "local.h" |
#include "fvwrite.h" |
#define MIN(a, b) ((a) < (b) ? (a) : (b)) |
#define COPY(n) _CAST_VOID memmove ((_PTR) fp->_p, (_PTR) p, (size_t) (n)) |
#define GETIOV(extra_work) \ |
while (len == 0) \ |
{ \ |
extra_work; \ |
p = iov->iov_base; \ |
len = iov->iov_len; \ |
iov++; \ |
} |
/* |
* Write some memory regions. Return zero on success, EOF on error. |
* |
* This routine is large and unsightly, but most of the ugliness due |
* to the three different kinds of output buffering is handled here. |
*/ |
int |
_DEFUN(__sfvwrite_r, (ptr, fp, uio), |
struct _reent *ptr _AND |
register FILE *fp _AND |
register struct __suio *uio) |
{ |
register size_t len; |
register _CONST char *p = NULL; |
register struct __siov *iov; |
register int w, s; |
char *nl; |
int nlknown, nldist; |
if ((len = uio->uio_resid) == 0) |
return 0; |
/* make sure we can write */ |
if (cantwrite (ptr, fp)) |
return EOF; |
iov = uio->uio_iov; |
len = 0; |
#ifdef __SCLE |
if (fp->_flags & __SCLE) /* text mode */ |
{ |
do |
{ |
GETIOV (;); |
while (len > 0) |
{ |
if (putc (*p, fp) == EOF) |
return EOF; |
p++; |
len--; |
uio->uio_resid--; |
} |
} |
while (uio->uio_resid > 0); |
return 0; |
} |
#endif |
if (fp->_flags & __SNBF) |
{ |
/* |
* Unbuffered: write up to BUFSIZ bytes at a time. |
*/ |
do |
{ |
GETIOV (;); |
w = fp->_write (ptr, fp->_cookie, p, MIN (len, BUFSIZ)); |
if (w <= 0) |
goto err; |
p += w; |
len -= w; |
} |
while ((uio->uio_resid -= w) != 0); |
} |
else if ((fp->_flags & __SLBF) == 0) |
{ |
/* |
* Fully buffered: fill partially full buffer, if any, |
* and then flush. If there is no partial buffer, write |
* one _bf._size byte chunk directly (without copying). |
* |
* String output is a special case: write as many bytes |
* as fit, but pretend we wrote everything. This makes |
* snprintf() return the number of bytes needed, rather |
* than the number used, and avoids its write function |
* (so that the write function can be invalid). If |
* we are dealing with the asprintf routines, we will |
* dynamically increase the buffer size as needed. |
*/ |
do |
{ |
GETIOV (;); |
w = fp->_w; |
if (fp->_flags & __SSTR) |
{ |
if (len >= w && fp->_flags & (__SMBF | __SOPT)) |
{ /* must be asprintf family */ |
unsigned char *str; |
int curpos = (fp->_p - fp->_bf._base); |
/* Choose a geometric growth factor to avoid |
quadratic realloc behavior, but use a rate less |
than (1+sqrt(5))/2 to accomodate malloc |
overhead. asprintf EXPECTS us to overallocate, so |
that it can add a trailing \0 without |
reallocating. The new allocation should thus be |
max(prev_size*1.5, curpos+len+1). */ |
int newsize = fp->_bf._size * 3 / 2; |
if (newsize < curpos + len + 1) |
newsize = curpos + len + 1; |
if (fp->_flags & __SOPT) |
{ |
/* asnprintf leaves original buffer alone. */ |
str = (unsigned char *)_malloc_r (ptr, newsize); |
if (!str) |
{ |
ptr->_errno = ENOMEM; |
goto err; |
} |
memcpy (str, fp->_bf._base, curpos); |
fp->_flags = (fp->_flags & ~__SOPT) | __SMBF; |
} |
else |
{ |
str = (unsigned char *)_realloc_r (ptr, fp->_bf._base, |
newsize); |
if (!str) |
{ |
/* Free buffer which is no longer used. */ |
_free_r (ptr, fp->_bf._base); |
/* Ensure correct errno, even if free changed it. */ |
ptr->_errno = ENOMEM; |
goto err; |
} |
} |
fp->_bf._base = str; |
fp->_p = str + curpos; |
fp->_bf._size = newsize; |
w = len; |
fp->_w = newsize - curpos; |
} |
if (len < w) |
w = len; |
COPY (w); /* copy MIN(fp->_w,len), */ |
fp->_w -= w; |
fp->_p += w; |
w = len; /* but pretend copied all */ |
} |
else if (fp->_p > fp->_bf._base && len > w) |
{ |
/* fill and flush */ |
COPY (w); |
/* fp->_w -= w; *//* unneeded */ |
fp->_p += w; |
if (_fflush_r (ptr, fp)) |
goto err; |
} |
else if (len >= (w = fp->_bf._size)) |
{ |
/* write directly */ |
w = fp->_write (ptr, fp->_cookie, p, w); |
if (w <= 0) |
goto err; |
} |
else |
{ |
/* fill and done */ |
w = len; |
COPY (w); |
fp->_w -= w; |
fp->_p += w; |
} |
p += w; |
len -= w; |
} |
while ((uio->uio_resid -= w) != 0); |
} |
else |
{ |
/* |
* Line buffered: like fully buffered, but we |
* must check for newlines. Compute the distance |
* to the first newline (including the newline), |
* or `infinity' if there is none, then pretend |
* that the amount to write is MIN(len,nldist). |
*/ |
nlknown = 0; |
nldist = 0; |
do |
{ |
GETIOV (nlknown = 0); |
if (!nlknown) |
{ |
nl = memchr ((_PTR) p, '\n', len); |
nldist = nl ? nl + 1 - p : len + 1; |
nlknown = 1; |
} |
s = MIN (len, nldist); |
w = fp->_w + fp->_bf._size; |
if (fp->_p > fp->_bf._base && s > w) |
{ |
COPY (w); |
/* fp->_w -= w; */ |
fp->_p += w; |
if (_fflush_r (ptr, fp)) |
goto err; |
} |
else if (s >= (w = fp->_bf._size)) |
{ |
w = fp->_write (ptr, fp->_cookie, p, w); |
if (w <= 0) |
goto err; |
} |
else |
{ |
w = s; |
COPY (w); |
fp->_w -= w; |
fp->_p += w; |
} |
if ((nldist -= w) == 0) |
{ |
/* copied the newline: flush and forget */ |
if (_fflush_r (ptr, fp)) |
goto err; |
nlknown = 0; |
} |
p += w; |
len -= w; |
} |
while ((uio->uio_resid -= w) != 0); |
} |
return 0; |
err: |
fp->_flags |= __SERR; |
return EOF; |
} |
/contrib/sdk/sources/libc/stdio/fvwrite.h |
---|
0,0 → 1,36 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* %W% (Berkeley) %G% */ |
#include <_ansi.h> |
/* |
* I/O descriptors for __sfvwrite_r(). |
*/ |
struct __siov { |
_CONST _PTR iov_base; |
size_t iov_len; |
}; |
struct __suio { |
struct __siov *uio_iov; |
int uio_iovcnt; |
int uio_resid; |
}; |
extern int _EXFUN(__sfvwrite_r,(struct _reent *, FILE *, struct __suio *)); |
extern int _EXFUN(__swsetup_r,(struct _reent *, FILE *)); |
/contrib/sdk/sources/libc/stdio/fwalk.c |
---|
0,0 → 1,86 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <errno.h> |
#include "local.h" |
int |
_DEFUN(_fwalk, (ptr, function), |
struct _reent *ptr _AND |
register int (*function) (FILE *)) |
{ |
register FILE *fp; |
register int n, ret = 0; |
register struct _glue *g; |
/* |
* It should be safe to walk the list without locking it; |
* new nodes are only added to the end and none are ever |
* removed. |
* |
* Avoid locking this list while walking it or else you will |
* introduce a potential deadlock in [at least] refill.c. |
*/ |
for (g = &ptr->__sglue; g != NULL; g = g->_next) |
for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++) |
if (fp->_flags != 0) |
{ |
if (fp->_flags != 0 && fp->_flags != 1 && fp->_file != -1) |
ret |= (*function) (fp); |
} |
return ret; |
} |
/* Special version of __fwalk where the function pointer is a reentrant |
I/O function (e.g. _fclose_r). */ |
int |
_DEFUN(_fwalk_reent, (ptr, reent_function), |
struct _reent *ptr _AND |
register int (*reent_function) (struct _reent *, FILE *)) |
{ |
register FILE *fp; |
register int n, ret = 0; |
register struct _glue *g; |
/* |
* It should be safe to walk the list without locking it; |
* new nodes are only added to the end and none are ever |
* removed. |
* |
* Avoid locking this list while walking it or else you will |
* introduce a potential deadlock in [at least] refill.c. |
*/ |
for (g = &ptr->__sglue; g != NULL; g = g->_next) |
for (fp = g->_iobs, n = g->_niobs; --n >= 0; fp++) |
if (fp->_flags != 0) |
{ |
if (fp->_flags != 0 && fp->_flags != 1 && fp->_file != -1) |
ret |= (*reent_function) (ptr, fp); |
} |
return ret; |
} |
/contrib/sdk/sources/libc/stdio/fwrite.c |
---|
0,0 → 1,143 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<fwrite>>---write array elements |
INDEX |
fwrite |
INDEX |
_fwrite_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
size_t fwrite(const void *<[buf]>, size_t <[size]>, |
size_t <[count]>, FILE *<[fp]>); |
#include <stdio.h> |
size_t _fwrite_r(struct _reent *<[ptr]>, const void *<[buf]>, size_t <[size]>, |
size_t <[count]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
size_t fwrite(<[buf]>, <[size]>, <[count]>, <[fp]>) |
char *<[buf]>; |
size_t <[size]>; |
size_t <[count]>; |
FILE *<[fp]>; |
#include <stdio.h> |
size_t _fwrite_r(<[ptr]>, <[buf]>, <[size]>, <[count]>, <[fp]>) |
struct _reent *<[ptr]>; |
char *<[buf]>; |
size_t <[size]>; |
size_t <[count]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<fwrite>> attempts to copy, starting from the memory location |
<[buf]>, <[count]> elements (each of size <[size]>) into the file or |
stream identified by <[fp]>. <<fwrite>> may copy fewer elements than |
<[count]> if an error intervenes. |
<<fwrite>> also advances the file position indicator (if any) for |
<[fp]> by the number of @emph{characters} actually written. |
<<_fwrite_r>> is simply the reentrant version of <<fwrite>> that |
takes an additional reentrant structure argument: <[ptr]>. |
RETURNS |
If <<fwrite>> succeeds in writing all the elements you specify, the |
result is the same as the argument <[count]>. In any event, the |
result is the number of complete elements that <<fwrite>> copied to |
the file. |
PORTABILITY |
ANSI C requires <<fwrite>>. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <string.h> |
#if 0 |
#include <sys/stdc.h> |
#endif |
#include "local.h" |
#if 1 |
#include "fvwrite.h" |
#endif |
/* |
* Write `count' objects (each size `size') from memory to the given file. |
* Return the number of whole objects written. |
*/ |
size_t |
_DEFUN(_fwrite_r, (ptr, buf, size, count, fp), |
struct _reent * ptr _AND |
_CONST _PTR buf _AND |
size_t size _AND |
size_t count _AND |
FILE * fp) |
{ |
size_t n; |
struct __suio uio; |
struct __siov iov; |
iov.iov_base = buf; |
uio.uio_resid = iov.iov_len = n = count * size; |
uio.uio_iov = &iov; |
uio.uio_iovcnt = 1; |
/* |
* The usual case is success (__sfvwrite_r returns 0); |
* skip the divide if this happens, since divides are |
* generally slow and since this occurs whenever size==0. |
*/ |
CHECK_INIT(ptr, fp); |
_flockfile (fp); |
ORIENT (fp, -1); |
if (__sfvwrite_r (ptr, fp, &uio) == 0) |
{ |
_funlockfile (fp); |
return count; |
} |
_funlockfile (fp); |
return (n - uio.uio_resid) / size; |
} |
#ifndef _REENT_ONLY |
size_t |
_DEFUN(fwrite, (buf, size, count, fp), |
_CONST _PTR buf _AND |
size_t size _AND |
size_t count _AND |
FILE * fp) |
{ |
return _fwrite_r (_REENT, buf, size, count, fp); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/local.h |
---|
0,0 → 1,229 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
* |
* %W% (UofMD/Berkeley) %G% |
*/ |
/* |
* Information local to this implementation of stdio, |
* in particular, macros and private variables. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdarg.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <stdio.h> |
#ifdef __SCLE |
# include <io.h> |
#endif |
extern u_char *_EXFUN(__sccl, (char *, u_char *fmt)); |
extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
extern int _EXFUN(__ssvfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
extern int _EXFUN(__svfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
extern int _EXFUN(__ssvfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list)); |
extern int _EXFUN(__svfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
extern int _EXFUN(__ssvfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
extern int _EXFUN(__svfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
extern int _EXFUN(__ssvfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list)); |
int _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *, |
va_list) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *, |
va_list) |
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); |
int _EXFUN(_svfwprintf_r,(struct _reent *, FILE *, const wchar_t *, |
va_list)); |
int _EXFUN(_svfiwprintf_r,(struct _reent *, FILE *, const wchar_t *, |
va_list)); |
extern FILE *_EXFUN(__sfp,(struct _reent *)); |
extern int _EXFUN(__sflags,(struct _reent *,_CONST char*, int*)); |
extern int _EXFUN(__sflush_r,(struct _reent *,FILE *)); |
extern int _EXFUN(__srefill_r,(struct _reent *,FILE *)); |
extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(struct _reent *, void *, char *, |
int)); |
extern _READ_WRITE_RETURN_TYPE _EXFUN(__seofread,(struct _reent *, void *, |
char *, int)); |
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(struct _reent *, void *, |
const char *, int)); |
extern _fpos_t _EXFUN(__sseek,(struct _reent *, void *, _fpos_t, int)); |
extern int _EXFUN(__sclose,(struct _reent *, void *)); |
extern int _EXFUN(__stextmode,(int)); |
extern _VOID _EXFUN(__sinit,(struct _reent *)); |
extern _VOID _EXFUN(_cleanup_r,(struct _reent *)); |
extern _VOID _EXFUN(__smakebuf_r,(struct _reent *, FILE *)); |
extern int _EXFUN(_fwalk,(struct _reent *, int (*)(FILE *))); |
extern int _EXFUN(_fwalk_reent,(struct _reent *, int (*)(struct _reent *, FILE *))); |
struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n)); |
extern int _EXFUN(__submore, (struct _reent *, FILE *)); |
#ifdef __LARGE64_FILES |
extern _fpos64_t _EXFUN(__sseek64,(struct _reent *, void *, _fpos64_t, int)); |
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *, |
const char *, int)); |
#endif |
/* Called by the main entry point fns to ensure stdio has been initialized. */ |
#ifdef _REENT_SMALL |
#define CHECK_INIT(ptr, fp) \ |
do \ |
{ \ |
if ((ptr) && !(ptr)->__sdidinit) \ |
__sinit (ptr); \ |
if ((fp) == (FILE *)&__sf_fake_stdin) \ |
(fp) = _stdin_r(ptr); \ |
else if ((fp) == (FILE *)&__sf_fake_stdout) \ |
(fp) = _stdout_r(ptr); \ |
else if ((fp) == (FILE *)&__sf_fake_stderr) \ |
(fp) = _stderr_r(ptr); \ |
} \ |
while (0) |
#else /* !_REENT_SMALL */ |
#define CHECK_INIT(ptr, fp) \ |
do \ |
{ \ |
if ((ptr) && !(ptr)->__sdidinit) \ |
__sinit (ptr); \ |
} \ |
while (0) |
#endif /* !_REENT_SMALL */ |
#define CHECK_STD_INIT(ptr) \ |
do \ |
{ \ |
if ((ptr) && !(ptr)->__sdidinit) \ |
__sinit (ptr); \ |
} \ |
while (0) |
/* Return true and set errno and stream error flag iff the given FILE |
cannot be written now. */ |
#define cantwrite(ptr, fp) \ |
((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \ |
__swsetup_r(ptr, fp)) |
/* Test whether the given stdio file has an active ungetc buffer; |
release such a buffer, without restoring ordinary unread data. */ |
#define HASUB(fp) ((fp)->_ub._base != NULL) |
#define FREEUB(ptr, fp) { \ |
if ((fp)->_ub._base != (fp)->_ubuf) \ |
_free_r(ptr, (char *)(fp)->_ub._base); \ |
(fp)->_ub._base = NULL; \ |
} |
/* Test for an fgetline() buffer. */ |
#define HASLB(fp) ((fp)->_lb._base != NULL) |
#define FREELB(ptr, fp) { _free_r(ptr,(char *)(fp)->_lb._base); \ |
(fp)->_lb._base = NULL; } |
/* |
* Set the orientation for a stream. If o > 0, the stream has wide- |
* orientation. If o < 0, the stream has byte-orientation. |
*/ |
#define ORIENT(fp,ori) \ |
do \ |
{ \ |
if (!((fp)->_flags & __SORD)) \ |
{ \ |
(fp)->_flags |= __SORD; \ |
if (ori > 0) \ |
(fp)->_flags2 |= __SWID; \ |
else \ |
(fp)->_flags2 &= ~__SWID; \ |
} \ |
} \ |
while (0) |
/* WARNING: _dcvt is defined in the stdlib directory, not here! */ |
char *_EXFUN(_dcvt,(struct _reent *, char *, double, int, int, char, int)); |
char *_EXFUN(_sicvt,(char *, short, char)); |
char *_EXFUN(_icvt,(char *, int, char)); |
char *_EXFUN(_licvt,(char *, long, char)); |
#ifdef __GNUC__ |
char *_EXFUN(_llicvt,(char *, long long, char)); |
#endif |
#define CVT_BUF_SIZE 128 |
#define NDYNAMIC 4 /* add four more whenever necessary */ |
#ifdef __SINGLE_THREAD__ |
#define __sfp_lock_acquire() |
#define __sfp_lock_release() |
#define __sinit_lock_acquire() |
#define __sinit_lock_release() |
#else |
_VOID _EXFUN(__sfp_lock_acquire,(_VOID)); |
_VOID _EXFUN(__sfp_lock_release,(_VOID)); |
_VOID _EXFUN(__sinit_lock_acquire,(_VOID)); |
_VOID _EXFUN(__sinit_lock_release,(_VOID)); |
#endif |
/* Types used in positional argument support in vfprinf/vfwprintf. |
The implementation is char/wchar_t dependent but the class and state |
tables are only defined once in vfprintf.c. */ |
typedef enum { |
ZERO, /* '0' */ |
DIGIT, /* '1-9' */ |
DOLLAR, /* '$' */ |
MODFR, /* spec modifier */ |
SPEC, /* format specifier */ |
DOT, /* '.' */ |
STAR, /* '*' */ |
FLAG, /* format flag */ |
OTHER, /* all other chars */ |
MAX_CH_CLASS /* place-holder */ |
} __CH_CLASS; |
typedef enum { |
START, /* start */ |
SFLAG, /* seen a flag */ |
WDIG, /* seen digits in width area */ |
WIDTH, /* processed width */ |
SMOD, /* seen spec modifier */ |
SDOT, /* seen dot */ |
VARW, /* have variable width specifier */ |
VARP, /* have variable precision specifier */ |
PREC, /* processed precision */ |
VWDIG, /* have digits in variable width specification */ |
VPDIG, /* have digits in variable precision specification */ |
DONE, /* done */ |
MAX_STATE, /* place-holder */ |
} __STATE; |
typedef enum { |
NOOP, /* do nothing */ |
NUMBER, /* build a number from digits */ |
SKIPNUM, /* skip over digits */ |
GETMOD, /* get and process format modifier */ |
GETARG, /* get and process argument */ |
GETPW, /* get variable precision or width */ |
GETPWB, /* get variable precision or width and pushback fmt char */ |
GETPOS, /* get positional parameter value */ |
PWPOS, /* get positional parameter value for variable width or precision */ |
} __ACTION; |
extern _CONST __CH_CLASS __chclass[256]; |
extern _CONST __STATE __state_table[MAX_STATE][MAX_CH_CLASS]; |
extern _CONST __ACTION __action_table[MAX_STATE][MAX_CH_CLASS]; |
/contrib/sdk/sources/libc/stdio/makebuf.c |
---|
0,0 → 1,113 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <sys/stat.h> |
#include <sys/types.h> |
#include <sys/unistd.h> |
#include "local.h" |
#define _DEFAULT_ASPRINTF_BUFSIZE 64 |
/* |
* Allocate a file buffer, or switch to unbuffered I/O. |
* Per the ANSI C standard, ALL tty devices default to line buffered. |
* |
* As a side effect, we set __SOPT or __SNPT (en/dis-able fseek |
* optimization) right after the _fstat() that finds the buffer size. |
*/ |
_VOID |
_DEFUN(__smakebuf_r, (ptr, fp), |
struct _reent *ptr _AND |
register FILE *fp) |
{ |
register size_t size, couldbetty; |
register _PTR p; |
#ifdef __USE_INTERNAL_STAT64 |
struct stat64 st; |
#else |
struct stat st; |
#endif |
if (fp->_flags & __SNBF) |
{ |
fp->_bf._base = fp->_p = fp->_nbuf; |
fp->_bf._size = 1; |
return; |
} |
#ifdef __USE_INTERNAL_STAT64 |
if (fp->_file < 0 || _fstat64_r (ptr, fp->_file, &st) < 0) |
#else |
if (fp->_file < 0 || _fstat_r (ptr, fp->_file, &st) < 0) |
#endif |
{ |
couldbetty = 0; |
/* Check if we are be called by asprintf family for initial buffer. */ |
if (fp->_flags & __SMBF) |
size = _DEFAULT_ASPRINTF_BUFSIZE; |
else |
size = BUFSIZ; |
/* do not try to optimise fseek() */ |
fp->_flags |= __SNPT; |
} |
else |
{ |
couldbetty = (st.st_mode & S_IFMT) == S_IFCHR; |
#ifdef HAVE_BLKSIZE |
size = st.st_blksize <= 0 ? BUFSIZ : st.st_blksize; |
#else |
size = BUFSIZ; |
#endif |
/* |
* Optimize fseek() only if it is a regular file. |
* (The test for __sseek is mainly paranoia.) |
*/ |
if ((st.st_mode & S_IFMT) == S_IFREG && fp->_seek == __sseek) |
{ |
fp->_flags |= __SOPT; |
#ifdef HAVE_BLKSIZE |
fp->_blksize = st.st_blksize; |
#else |
fp->_blksize = 1024; |
#endif |
} |
else |
fp->_flags |= __SNPT; |
} |
if ((p = _malloc_r (ptr, size)) == NULL) |
{ |
if (!(fp->_flags & __SSTR)) |
{ |
fp->_flags |= __SNBF; |
fp->_bf._base = fp->_p = fp->_nbuf; |
fp->_bf._size = 1; |
} |
} |
else |
{ |
ptr->__cleanup = _cleanup_r; |
fp->_flags |= __SMBF; |
fp->_bf._base = fp->_p = (unsigned char *) p; |
fp->_bf._size = size; |
if (couldbetty && _isatty_r (ptr, fp->_file)) |
fp->_flags |= __SLBF; |
} |
} |
/contrib/sdk/sources/libc/stdio/printf.c |
---|
0,0 → 1,57 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in sprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdarg.h> |
#include "local.h" |
int |
_DEFUN(_printf_r, (ptr, fmt), |
struct _reent *ptr _AND |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
_REENT_SMALL_CHECK_INIT (ptr); |
va_start (ap, fmt); |
ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap); |
va_end (ap); |
return ret; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(printf, (fmt), |
const char *fmt _DOTS) |
{ |
int ret; |
va_list ap; |
struct _reent *ptr = _REENT; |
_REENT_SMALL_CHECK_INIT (ptr); |
va_start (ap, fmt); |
ret = _vfprintf_r (ptr, _stdout_r (ptr), fmt, ap); |
va_end (ap); |
return ret; |
} |
#endif /* ! _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/putc.c |
---|
0,0 → 1,124 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<putc>>---write a character (macro) |
INDEX |
putc |
INDEX |
_putc_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int putc(int <[ch]>, FILE *<[fp]>); |
#include <stdio.h> |
int _putc_r(struct _reent *<[ptr]>, int <[ch]>, FILE *<[fp]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int putc(<[ch]>, <[fp]>) |
int <[ch]>; |
FILE *<[fp]>; |
#include <stdio.h> |
int _putc_r(<[ptr]>, <[ch]>, <[fp]>) |
struct _reent *<[ptr]>; |
int <[ch]>; |
FILE *<[fp]>; |
DESCRIPTION |
<<putc>> is a macro, defined in <<stdio.h>>. <<putc>> |
writes the argument <[ch]> to the file or stream identified by |
<[fp]>, after converting it from an <<int>> to an <<unsigned char>>. |
If the file was opened with append mode (or if the stream cannot |
support positioning), then the new character goes at the end of the |
file or stream. Otherwise, the new character is written at the |
current value of the position indicator, and the position indicator |
advances by one. |
For a subroutine version of this macro, see <<fputc>>. |
The <<_putc_r>> function is simply the reentrant version of |
<<putc>> that takes an additional reentrant structure argument: <[ptr]>. |
RETURNS |
If successful, <<putc>> returns its argument <[ch]>. If an error |
intervenes, the result is <<EOF>>. You can use `<<ferror(<[fp]>)>>' to |
query for errors. |
PORTABILITY |
ANSI C requires <<putc>>; it suggests, but does not require, that |
<<putc>> be implemented as a macro. The standard explicitly permits |
macro implementations of <<putc>> to use the <[fp]> argument more than once; |
therefore, in a portable program, you should not use an expression |
with side effects as this argument. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <stdio.h> |
#include "local.h" |
/* |
* A subroutine version of the macro putc. |
*/ |
#undef putc |
int |
_DEFUN(_putc_r, (ptr, c, fp), |
struct _reent *ptr _AND |
int c _AND |
register FILE *fp) |
{ |
int result; |
CHECK_INIT (ptr, fp); |
_flockfile (fp); |
result = __sputc_r (ptr, c, fp); |
_funlockfile (fp); |
return result; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(putc, (c, fp), |
int c _AND |
register FILE *fp) |
{ |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
int result; |
CHECK_INIT (_REENT, fp); |
_flockfile (fp); |
result = __sputc_r (_REENT, c, fp); |
_funlockfile (fp); |
return result; |
#else |
return _putc_r (_REENT, c, fp); |
#endif |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/putchar.c |
---|
0,0 → 1,97 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<putchar>>---write a character (macro) |
INDEX |
putchar |
INDEX |
_putchar_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int putchar(int <[ch]>); |
int _putchar_r(struct _reent *<[reent]>, int <[ch]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int putchar(<[ch]>) |
int <[ch]>; |
int _putchar_r(<[reent]>, <[ch]>) |
struct _reent *<[reent]>; |
int <[ch]>; |
DESCRIPTION |
<<putchar>> is a macro, defined in <<stdio.h>>. <<putchar>> |
writes its argument to the standard output stream, |
after converting it from an <<int>> to an <<unsigned char>>. |
The alternate function <<_putchar_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
If successful, <<putchar>> returns its argument <[ch]>. If an error |
intervenes, the result is <<EOF>>. You can use `<<ferror(stdin)>>' to |
query for errors. |
PORTABILITY |
ANSI C requires <<putchar>>; it suggests, but does not require, that |
<<putchar>> be implemented as a macro. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
/* |
* A subroutine version of the macro putchar. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include "local.h" |
#undef putchar |
int |
_DEFUN(_putchar_r, (ptr, c), |
struct _reent *ptr _AND |
int c) |
{ |
_REENT_SMALL_CHECK_INIT (ptr); |
return _putc_r (ptr, c, _stdout_r (ptr)); |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(putchar, (c), |
int c) |
{ |
_REENT_SMALL_CHECK_INIT (_REENT); |
return _putc_r (_REENT, c, _stdout_r (_REENT)); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/puts.c |
---|
0,0 → 1,106 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<puts>>---write a character string |
INDEX |
puts |
INDEX |
_puts_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int puts(const char *<[s]>); |
int _puts_r(struct _reent *<[reent]>, const char *<[s]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int puts(<[s]>) |
char *<[s]>; |
int _puts_r(<[reent]>, <[s]>) |
struct _reent *<[reent]>; |
char *<[s]>; |
DESCRIPTION |
<<puts>> writes the string at <[s]> (followed by a newline, instead of |
the trailing null) to the standard output stream. |
The alternate function <<_puts_r>> is a reentrant version. The extra |
argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
If successful, the result is a nonnegative integer; otherwise, the |
result is <<EOF>>. |
PORTABILITY |
ANSI C requires <<puts>>, but does not specify that the result on |
success must be <<0>>; any non-negative value is permitted. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <string.h> |
#include "fvwrite.h" |
#include "local.h" |
/* |
* Write the given string to stdout, appending a newline. |
*/ |
int |
_DEFUN(_puts_r, (ptr, s), |
struct _reent *ptr _AND |
_CONST char * s) |
{ |
size_t c = strlen (s); |
struct __suio uio; |
struct __siov iov[2]; |
iov[0].iov_base = s; |
iov[0].iov_len = c; |
iov[1].iov_base = "\n"; |
iov[1].iov_len = 1; |
uio.uio_resid = c + 1; |
uio.uio_iov = &iov[0]; |
uio.uio_iovcnt = 2; |
_REENT_SMALL_CHECK_INIT (ptr); |
ORIENT (stdout, -1); |
return (__sfvwrite_r (ptr, _stdout_r (ptr), &uio) ? EOF : '\n'); |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(puts, (s), |
char _CONST * s) |
{ |
return _puts_r (_REENT, s); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/refill.c |
---|
0,0 → 1,138 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <errno.h> |
#include "local.h" |
static int |
_DEFUN(lflush, (fp), |
FILE *fp) |
{ |
if ((fp->_flags & (__SLBF | __SWR)) == (__SLBF | __SWR)) |
return fflush (fp); |
return 0; |
} |
/* |
* Refill a stdio buffer. |
* Return EOF on eof or error, 0 otherwise. |
*/ |
int |
_DEFUN(__srefill_r, (ptr, fp), |
struct _reent * ptr _AND |
register FILE * fp) |
{ |
/* make sure stdio is set up */ |
CHECK_INIT (ptr, fp); |
ORIENT (fp, -1); |
fp->_r = 0; /* largely a convenience for callers */ |
#ifndef __CYGWIN__ |
/* SysV does not make this test; take it out for compatibility */ |
if (fp->_flags & __SEOF) |
return EOF; |
#endif |
/* if not already reading, have to be reading and writing */ |
if ((fp->_flags & __SRD) == 0) |
{ |
if ((fp->_flags & __SRW) == 0) |
{ |
ptr->_errno = EBADF; |
fp->_flags |= __SERR; |
return EOF; |
} |
/* switch to reading */ |
if (fp->_flags & __SWR) |
{ |
if (_fflush_r (ptr, fp)) |
return EOF; |
fp->_flags &= ~__SWR; |
fp->_w = 0; |
fp->_lbfsize = 0; |
} |
fp->_flags |= __SRD; |
} |
else |
{ |
/* |
* We were reading. If there is an ungetc buffer, |
* we must have been reading from that. Drop it, |
* restoring the previous buffer (if any). If there |
* is anything in that buffer, return. |
*/ |
if (HASUB (fp)) |
{ |
FREEUB (ptr, fp); |
if ((fp->_r = fp->_ur) != 0) |
{ |
fp->_p = fp->_up; |
return 0; |
} |
} |
} |
if (fp->_bf._base == NULL) |
__smakebuf_r (ptr, fp); |
/* |
* Before reading from a line buffered or unbuffered file, |
* flush all line buffered output files, per the ANSI C |
* standard. |
*/ |
if (fp->_flags & (__SLBF | __SNBF)) |
{ |
/* Ignore this file in _fwalk to avoid potential deadlock. */ |
short orig_flags = fp->_flags; |
fp->_flags = 1; |
_CAST_VOID _fwalk (_GLOBAL_REENT, lflush); |
fp->_flags = orig_flags; |
/* Now flush this file without locking it. */ |
if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR)) |
__sflush_r (ptr, fp); |
} |
fp->_p = fp->_bf._base; |
fp->_r = fp->_read (ptr, fp->_cookie, (char *) fp->_p, fp->_bf._size); |
#ifndef __CYGWIN__ |
if (fp->_r <= 0) |
#else |
if (fp->_r > 0) |
fp->_flags &= ~__SEOF; |
else |
#endif |
{ |
if (fp->_r == 0) |
fp->_flags |= __SEOF; |
else |
{ |
fp->_r = 0; |
fp->_flags |= __SERR; |
} |
return EOF; |
} |
return 0; |
} |
/contrib/sdk/sources/libc/stdio/remove.c |
---|
0,0 → 1,91 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<remove>>---delete a file's name |
INDEX |
remove |
INDEX |
_remove_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int remove(char *<[filename]>); |
int _remove_r(struct _reent *<[reent]>, char *<[filename]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int remove(<[filename]>) |
char *<[filename]>; |
int _remove_r(<[reent]>, <[filename]>) |
struct _reent *<[reent]>; |
char *<[filename]>; |
DESCRIPTION |
Use <<remove>> to dissolve the association between a particular |
filename (the string at <[filename]>) and the file it represents. |
After calling <<remove>> with a particular filename, you will no |
longer be able to open the file by that name. |
In this implementation, you may use <<remove>> on an open file without |
error; existing file descriptors for the file will continue to access |
the file's data until the program using them closes the file. |
The alternate function <<_remove_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<remove>> returns <<0>> if it succeeds, <<-1>> if it fails. |
PORTABILITY |
ANSI C requires <<remove>>, but only specifies that the result on |
failure be nonzero. The behavior of <<remove>> when you call it on an |
open file may vary among implementations. |
Supporting OS subroutine required: <<unlink>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <sys/kos_io.h> |
int |
_DEFUN(_remove_r, (ptr, filename), |
struct _reent *ptr _AND |
_CONST char *filename) |
{ |
return delete_file(filename)==0 ? 0: -1; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(remove, (filename), |
_CONST char *filename) |
{ |
return delete_file(filename)==0 ? 0: -1; |
} |
#endif |
/contrib/sdk/sources/libc/stdio/rename.c |
---|
0,0 → 1,80 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<rename>>---rename a file |
INDEX |
rename |
ANSI_SYNOPSIS |
#include <stdio.h> |
int rename(const char *<[old]>, const char *<[new]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int rename(<[old]>, <[new]>) |
char *<[old]>; |
char *<[new]>; |
DESCRIPTION |
Use <<rename>> to establish a new name (the string at <[new]>) for a |
file now known by the string at <[old]>. After a successful |
<<rename>>, the file is no longer accessible by the string at <[old]>. |
If <<rename>> fails, the file named <<*<[old]>>> is unaffected. The |
conditions for failure depend on the host operating system. |
RETURNS |
The result is either <<0>> (when successful) or <<-1>> (when the file |
could not be renamed). |
PORTABILITY |
ANSI C requires <<rename>>, but only specifies that the result on |
failure be nonzero. The effects of using the name of an existing file |
as <<*<[new]>>> may vary from one implementation to another. |
Supporting OS subroutines required: <<link>>, <<unlink>>, or <<rename>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <sys/unistd.h> |
int |
_DEFUN (_rename_r, (ptr, old, new), |
struct _reent *ptr _AND |
_CONST char *old _AND |
_CONST char *new) |
{ |
return -1; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(rename, (old, new), |
_CONST char *old _AND |
_CONST char *new) |
{ |
return -1; |
} |
#endif |
/contrib/sdk/sources/libc/stdio/rget.c |
---|
0,0 → 1,59 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <errno.h> |
#include "local.h" |
/* |
* Handle getc() when the buffer ran out: |
* Refill, then return the first character |
* in the newly-filled buffer. |
*/ |
int |
_DEFUN(__srget_r, (ptr, fp), |
struct _reent *ptr _AND |
register FILE *fp) |
{ |
/* Ensure that any fake std stream is resolved before |
we call __srefill_r so we may access the true read buffer. */ |
CHECK_INIT(ptr, fp); |
if (__srefill_r (ptr, fp) == 0) |
{ |
fp->_r--; |
return *fp->_p++; |
} |
return EOF; |
} |
/* This function isn't any longer declared in stdio.h, but it's |
required for backward compatibility with applications built against |
earlier dynamically built newlib libraries. */ |
int |
_DEFUN(__srget, (fp), |
register FILE *fp) |
{ |
return __srget_r (_REENT, fp); |
} |
/contrib/sdk/sources/libc/stdio/sccl.c |
---|
0,0 → 1,127 |
/*- |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* Split from vfscanf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <newlib.h> |
#include <stdio.h> |
#include "local.h" |
/* |
* Fill in the given table from the scanset at the given format |
* (just after `['). Return a pointer to the character past the |
* closing `]'. The table has a 1 wherever characters should be |
* considered part of the scanset. |
*/ |
u_char * |
_DEFUN(__sccl, (tab, fmt), |
register char *tab _AND |
register u_char *fmt) |
{ |
register int c, n, v; |
/* first `clear' the whole table */ |
c = *fmt++; /* first char hat => negated scanset */ |
if (c == '^') |
{ |
v = 1; /* default => accept */ |
c = *fmt++; /* get new first char */ |
} |
else |
v = 0; /* default => reject */ |
/* should probably use memset here */ |
for (n = 0; n < 256; n++) |
tab[n] = v; |
if (c == 0) |
return fmt - 1; /* format ended before closing ] */ |
/* |
* Now set the entries corresponding to the actual scanset to the |
* opposite of the above. |
* |
* The first character may be ']' (or '-') without being special; the |
* last character may be '-'. |
*/ |
v = 1 - v; |
for (;;) |
{ |
tab[c] = v; /* take character c */ |
doswitch: |
n = *fmt++; /* and examine the next */ |
switch (n) |
{ |
case 0: /* format ended too soon */ |
return fmt - 1; |
case '-': |
/* |
* A scanset of the form [01+-] is defined as `the digit 0, the |
* digit 1, the character +, the character -', but the effect of a |
* scanset such as [a-zA-Z0-9] is implementation defined. The V7 |
* Unix scanf treats `a-z' as `the letters a through z', but treats |
* `a-a' as `the letter a, the character -, and the letter a'. |
* |
* For compatibility, the `-' is not considerd to define a range if |
* the character following it is either a close bracket (required by |
* ANSI) or is not numerically greater than the character we just |
* stored in the table (c). |
*/ |
n = *fmt; |
if (n == ']' || n < c) |
{ |
c = '-'; |
break; /* resume the for(;;) */ |
} |
fmt++; |
do |
{ /* fill in the range */ |
tab[++c] = v; |
} |
while (c < n); |
#if 1 /* XXX another disgusting compatibility hack */ |
/* |
* Alas, the V7 Unix scanf also treats formats such |
* as [a-c-e] as `the letters a through e'. This too |
* is permitted by the standard.... |
*/ |
goto doswitch; |
#else |
c = *fmt++; |
if (c == 0) |
return fmt - 1; |
if (c == ']') |
return fmt; |
#endif |
break; |
case ']': /* end of scanset */ |
return fmt; |
default: /* just another character */ |
c = n; |
break; |
} |
} |
/* NOTREACHED */ |
} |
/contrib/sdk/sources/libc/stdio/setvbuf.c |
---|
0,0 → 1,198 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<setvbuf>>---specify file or stream buffering |
INDEX |
setvbuf |
ANSI_SYNOPSIS |
#include <stdio.h> |
int setvbuf(FILE *<[fp]>, char *<[buf]>, |
int <[mode]>, size_t <[size]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int setvbuf(<[fp]>, <[buf]>, <[mode]>, <[size]>) |
FILE *<[fp]>; |
char *<[buf]>; |
int <[mode]>; |
size_t <[size]>; |
DESCRIPTION |
Use <<setvbuf>> to specify what kind of buffering you want for the |
file or stream identified by <[fp]>, by using one of the following |
values (from <<stdio.h>>) as the <[mode]> argument: |
o+ |
o _IONBF |
Do not use a buffer: send output directly to the host system for the |
file or stream identified by <[fp]>. |
o _IOFBF |
Use full output buffering: output will be passed on to the host system |
only when the buffer is full, or when an input operation intervenes. |
o _IOLBF |
Use line buffering: pass on output to the host system at every |
newline, as well as when the buffer is full, or when an input |
operation intervenes. |
o- |
Use the <[size]> argument to specify how large a buffer you wish. You |
can supply the buffer itself, if you wish, by passing a pointer to a |
suitable area of memory as <[buf]>. Otherwise, you may pass <<NULL>> |
as the <[buf]> argument, and <<setvbuf>> will allocate the buffer. |
WARNINGS |
You may only use <<setvbuf>> before performing any file operation other |
than opening the file. |
If you supply a non-null <[buf]>, you must ensure that the associated |
storage continues to be available until you close the stream |
identified by <[fp]>. |
RETURNS |
A <<0>> result indicates success, <<EOF>> failure (invalid <[mode]> or |
<[size]> can cause failure). |
PORTABILITY |
Both ANSI C and the System V Interface Definition (Issue 2) require |
<<setvbuf>>. However, they differ on the meaning of a <<NULL>> buffer |
pointer: the SVID issue 2 specification says that a <<NULL>> buffer |
pointer requests unbuffered output. For maximum portability, avoid |
<<NULL>> buffer pointers. |
Both specifications describe the result on failure only as a |
nonzero value. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include "local.h" |
/* |
* Set one of the three kinds of buffering, optionally including a buffer. |
*/ |
int |
_DEFUN(setvbuf, (fp, buf, mode, size), |
register FILE * fp _AND |
char *buf _AND |
register int mode _AND |
register size_t size) |
{ |
int ret = 0; |
CHECK_INIT (_REENT, fp); |
_flockfile (fp); |
/* |
* Verify arguments. The `int' limit on `size' is due to this |
* particular implementation. |
*/ |
if ((mode != _IOFBF && mode != _IOLBF && mode != _IONBF) || (int)(_POINTER_INT) size < 0) |
{ |
_funlockfile (fp); |
return (EOF); |
} |
/* |
* Write current buffer, if any; drop read count, if any. |
* Make sure putc() will not think fp is line buffered. |
* Free old buffer if it was from malloc(). Clear line and |
* non buffer flags, and clear malloc flag. |
*/ |
_fflush_r (_REENT, fp); |
fp->_r = 0; |
fp->_lbfsize = 0; |
if (fp->_flags & __SMBF) |
_free_r (_REENT, (_PTR) fp->_bf._base); |
fp->_flags &= ~(__SLBF | __SNBF | __SMBF); |
if (mode == _IONBF) |
goto nbf; |
/* |
* Allocate buffer if needed. */ |
if (buf == NULL) |
{ |
/* we need this here because malloc() may return a pointer |
even if size == 0 */ |
if (!size) size = BUFSIZ; |
if ((buf = malloc (size)) == NULL) |
{ |
ret = EOF; |
/* Try another size... */ |
buf = malloc (BUFSIZ); |
size = BUFSIZ; |
} |
if (buf == NULL) |
{ |
/* Can't allocate it, let's try another approach */ |
nbf: |
fp->_flags |= __SNBF; |
fp->_w = 0; |
fp->_bf._base = fp->_p = fp->_nbuf; |
fp->_bf._size = 1; |
_funlockfile (fp); |
return (ret); |
} |
fp->_flags |= __SMBF; |
} |
/* |
* Now put back whichever flag is needed, and fix _lbfsize |
* if line buffered. Ensure output flush on exit if the |
* stream will be buffered at all. |
* If buf is NULL then make _lbfsize 0 to force the buffer |
* to be flushed and hence malloced on first use |
*/ |
switch (mode) |
{ |
case _IOLBF: |
fp->_flags |= __SLBF; |
fp->_lbfsize = buf ? -size : 0; |
/* FALLTHROUGH */ |
case _IOFBF: |
/* no flag */ |
_REENT->__cleanup = _cleanup_r; |
fp->_bf._base = fp->_p = (unsigned char *) buf; |
fp->_bf._size = size; |
break; |
} |
/* |
* Patch up write count if necessary. |
*/ |
if (fp->_flags & __SWR) |
fp->_w = fp->_flags & (__SLBF | __SNBF) ? 0 : size; |
_funlockfile (fp); |
return 0; |
} |
/contrib/sdk/sources/libc/stdio/siprintf.c |
---|
0,0 → 1,171 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<siprintf>>, <<fiprintf>>, <<iprintf>>, <<sniprintf>>, <<asiprintf>>, <<asniprintf>>---format output (integer only) |
INDEX |
fiprintf |
INDEX |
_fiprintf_r |
INDEX |
iprintf |
INDEX |
_iprintf_r |
INDEX |
siprintf |
INDEX |
_siprintf_r |
INDEX |
sniprintf |
INDEX |
_sniprintf_r |
INDEX |
asiprintf |
INDEX |
_asiprintf_r |
INDEX |
asniprintf |
INDEX |
_asniprintf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int iprintf(const char *<[format]>, ...); |
int fiprintf(FILE *<[fd]>, const char *<[format]> , ...); |
int siprintf(char *<[str]>, const char *<[format]>, ...); |
int sniprintf(char *<[str]>, size_t <[size]>, const char *<[format]>, |
...); |
int asiprintf(char **<[strp]>, const char *<[format]>, ...); |
char *asniprintf(char *<[str]>, size_t *<[size]>, |
const char *<[format]>, ...); |
int _iprintf_r(struct _reent *<[ptr]>, const char *<[format]>, ...); |
int _fiprintf_r(struct _reent *<[ptr]>, FILE *<[fd]>, |
const char *<[format]>, ...); |
int _siprintf_r(struct _reent *<[ptr]>, char *<[str]>, |
const char *<[format]>, ...); |
int _sniprintf_r(struct _reent *<[ptr]>, char *<[str]>, size_t <[size]>, |
const char *<[format]>, ...); |
int _asiprintf_r(struct _reent *<[ptr]>, char **<[strp]>, |
const char *<[format]>, ...); |
char *_asniprintf_r(struct _reent *<[ptr]>, char *<[str]>, |
size_t *<[size]>, const char *<[format]>, ...); |
DESCRIPTION |
<<iprintf>>, <<fiprintf>>, <<siprintf>>, <<sniprintf>>, |
<<asiprintf>>, and <<asniprintf>> are the same as <<printf>>, |
<<fprintf>>, <<sprintf>>, <<snprintf>>, <<asprintf>>, and |
<<asnprintf>>, respectively, except that they restrict usage |
to non-floating-point format specifiers. |
<<_iprintf_r>>, <<_fiprintf_r>>, <<_asiprintf_r>>, |
<<_siprintf_r>>, <<_sniprintf_r>>, <<_asniprintf_r>> are |
simply reentrant versions of the functions above. |
RETURNS |
Similar to <<printf>>, <<fprintf>>, <<sprintf>>, <<snprintf>>, <<asprintf>>, |
and <<asnprintf>>. |
PORTABILITY |
<<iprintf>>, <<fiprintf>>, <<siprintf>>, <<sniprintf>>, <<asiprintf>>, |
and <<asniprintf>> are newlib extensions. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include <limits.h> |
#include "local.h" |
int |
#ifdef _HAVE_STDC |
_DEFUN(_siprintf_r, (ptr, str, fmt), |
struct _reent *ptr _AND |
char *str _AND |
_CONST char *fmt _DOTS) |
#else |
_siprintf_r(ptr, str, fmt, va_alist) |
struct _reent *ptr; |
char *str; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = INT_MAX; |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfiprintf_r (ptr, &f, fmt, ap); |
va_end (ap); |
*f._p = 0; |
return (ret); |
} |
#ifndef _REENT_ONLY |
int |
#ifdef _HAVE_STDC |
_DEFUN(siprintf, (str, fmt), |
char *str _AND |
_CONST char *fmt _DOTS) |
#else |
siprintf(str, fmt, va_alist) |
char *str; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = INT_MAX; |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfiprintf_r (_REENT, &f, fmt, ap); |
va_end (ap); |
*f._p = 0; |
return (ret); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/sniprintf.c |
---|
0,0 → 1,120 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* This code created by modifying snprintf.c so copyright inherited. */ |
/* doc in siprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include <limits.h> |
#include <errno.h> |
#include "local.h" |
int |
#ifdef _HAVE_STDC |
_DEFUN (_sniprintf_r, (ptr, str, size, fmt), |
struct _reent *ptr _AND |
char *str _AND |
size_t size _AND |
_CONST char *fmt _DOTS) |
#else |
_sniprintf_r (ptr, str, size, fmt, va_alist) |
struct _reent *ptr; |
char *str; |
size_t size; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
if (size > INT_MAX) |
{ |
ptr->_errno = EOVERFLOW; |
return EOF; |
} |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = (size > 0 ? size - 1 : 0); |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfiprintf_r (ptr, &f, fmt, ap); |
va_end (ap); |
if (ret < EOF) |
ptr->_errno = EOVERFLOW; |
if (size > 0) |
*f._p = 0; |
return (ret); |
} |
#ifndef _REENT_ONLY |
int |
#ifdef _HAVE_STDC |
_DEFUN (sniprintf, (str, size, fmt), |
char *str _AND |
size_t size _AND |
_CONST char *fmt _DOTS) |
#else |
sniprintf (str, size, fmt, va_alist) |
char *str; |
size_t size; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
struct _reent *ptr = _REENT; |
if (size > INT_MAX) |
{ |
ptr->_errno = EOVERFLOW; |
return EOF; |
} |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = (size > 0 ? size - 1 : 0); |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfiprintf_r (ptr, &f, fmt, ap); |
va_end (ap); |
if (ret < EOF) |
ptr->_errno = EOVERFLOW; |
if (size > 0) |
*f._p = 0; |
return (ret); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/snprintf.c |
---|
0,0 → 1,119 |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in sprintf.c */ |
/* This code created by modifying sprintf.c so copyright inherited. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include <limits.h> |
#include <errno.h> |
#include "local.h" |
int |
#ifdef _HAVE_STDC |
_DEFUN(_snprintf_r, (ptr, str, size, fmt), |
struct _reent *ptr _AND |
char *str _AND |
size_t size _AND |
_CONST char *fmt _DOTS) |
#else |
_snprintf_r(ptr, str, size, fmt, va_alist) |
struct _reent *ptr; |
char *str; |
size_t size; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
if (size > INT_MAX) |
{ |
ptr->_errno = EOVERFLOW; |
return EOF; |
} |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = (size > 0 ? size - 1 : 0); |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
va_end (ap); |
if (ret < EOF) |
ptr->_errno = EOVERFLOW; |
if (size > 0) |
*f._p = 0; |
return (ret); |
} |
#ifndef _REENT_ONLY |
int |
#ifdef _HAVE_STDC |
_DEFUN(snprintf, (str, size, fmt), |
char *str _AND |
size_t size _AND |
_CONST char *fmt _DOTS) |
#else |
snprintf(str, size, fmt, va_alist) |
char *str; |
size_t size; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
struct _reent *ptr = _REENT; |
if (size > INT_MAX) |
{ |
ptr->_errno = EOVERFLOW; |
return EOF; |
} |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = (size > 0 ? size - 1 : 0); |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
va_end (ap); |
if (ret < EOF) |
ptr->_errno = EOVERFLOW; |
if (size > 0) |
*f._p = 0; |
return (ret); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/sprintf.c |
---|
0,0 → 1,640 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<sprintf>>, <<fprintf>>, <<printf>>, <<snprintf>>, <<asprintf>>, <<asnprintf>>---format output |
INDEX |
fprintf |
INDEX |
_fprintf_r |
INDEX |
printf |
INDEX |
_printf_r |
INDEX |
asprintf |
INDEX |
_asprintf_r |
INDEX |
sprintf |
INDEX |
_sprintf_r |
INDEX |
snprintf |
INDEX |
_snprintf_r |
INDEX |
asnprintf |
INDEX |
_asnprintf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int printf(const char *<[format]>, ...); |
int fprintf(FILE *<[fd]>, const char *<[format]>, ...); |
int sprintf(char *<[str]>, const char *<[format]>, ...); |
int snprintf(char *<[str]>, size_t <[size]>, const char *<[format]>, |
...); |
int asprintf(char **<[strp]>, const char *<[format]>, ...); |
char *asnprintf(char *<[str]>, size_t *<[size]>, const char *<[format]>, |
...); |
int _printf_r(struct _reent *<[ptr]>, const char *<[format]>, ...); |
int _fprintf_r(struct _reent *<[ptr]>, FILE *<[fd]>, |
const char *<[format]>, ...); |
int _sprintf_r(struct _reent *<[ptr]>, char *<[str]>, |
const char *<[format]>, ...); |
int _snprintf_r(struct _reent *<[ptr]>, char *<[str]>, size_t <[size]>, |
const char *<[format]>, ...); |
int _asprintf_r(struct _reent *<[ptr]>, char **<[strp]>, |
const char *<[format]>, ...); |
char *_asnprintf_r(struct _reent *<[ptr]>, char *<[str]>, |
size_t *<[size]>, const char *<[format]>, ...); |
DESCRIPTION |
<<printf>> accepts a series of arguments, applies to each a |
format specifier from <<*<[format]>>>, and writes the |
formatted data to <<stdout>>, without a terminating NUL |
character. The behavior of <<printf>> is undefined if there |
are not enough arguments for the format. <<printf>> returns |
when it reaches the end of the format string. If there are |
more arguments than the format requires, excess arguments are |
ignored. |
<<fprintf>> is like <<printf>>, except that output is directed |
to the stream <[fd]> rather than <<stdout>>. |
<<sprintf>> is like <<printf>>, except that output is directed |
to the buffer <[str]>, and a terminating NUL is output. |
Behavior is undefined if more output is generated than the |
buffer can hold. |
<<snprintf>> is like <<sprintf>>, except that output is |
limited to at most <[size]> bytes, including the terminating |
<<NUL>>. As a special case, if <[size]> is 0, <[str]> can be |
NULL, and <<snprintf>> merely calculates how many bytes would |
be printed. |
<<asprintf>> is like <<sprintf>>, except that the output is |
stored in a dynamically allocated buffer, <[pstr]>, which |
should be freed later with <<free>>. |
<<asnprintf>> is like <<sprintf>>, except that the return type |
is either the original <[str]> if it was large enough, or a |
dynamically allocated string if the output exceeds *<[size]>; |
the length of the result is returned in *<[size]>. When |
dynamic allocation occurs, the contents of the original |
<[str]> may have been modified. |
For <<sprintf>>, <<snprintf>>, and <<asnprintf>>, the behavior |
is undefined if the output <<*<[str]>>> overlaps with one of |
the arguments. Behavior is also undefined if the argument for |
<<%n>> within <<*<[format]>>> overlaps another argument. |
<[format]> is a pointer to a character string containing two |
types of objects: ordinary characters (other than <<%>>), |
which are copied unchanged to the output, and conversion |
specifications, each of which is introduced by <<%>>. (To |
include <<%>> in the output, use <<%%>> in the format string.) |
A conversion specification has the following form: |
. %[<[pos]>][<[flags]>][<[width]>][.<[prec]>][<[size]>]<[type]> |
The fields of the conversion specification have the following |
meanings: |
O+ |
o <[pos]> |
Conversions normally consume arguments in the order that they |
are presented. However, it is possible to consume arguments |
out of order, and reuse an argument for more than one |
conversion specification (although the behavior is undefined |
if the same argument is requested with different types), by |
specifying <[pos]>, which is a decimal integer followed by |
'$'. The integer must be between 1 and <NL_ARGMAX> from |
limits.h, and if argument <<%n$>> is requested, all earlier |
arguments must be requested somewhere within <[format]>. If |
positional parameters are used, then all conversion |
specifications except for <<%%>> must specify a position. |
This positional parameters method is a POSIX extension to the C |
standard definition for the functions. |
o <[flags]> |
<[flags]> is an optional sequence of characters which control |
output justification, numeric signs, decimal points, trailing |
zeros, and octal and hex prefixes. The flag characters are |
minus (<<->>), plus (<<+>>), space ( ), zero (<<0>>), sharp |
(<<#>>), and quote (<<'>>). They can appear in any |
combination, although not all flags can be used for all |
conversion specification types. |
o+ |
o ' |
A POSIX extension to the C standard. However, this |
implementation presently treats it as a no-op, which |
is the default behavior for the C locale, anyway. (If |
it did what it is supposed to, when <[type]> were <<i>>, |
<<d>>, <<u>>, <<f>>, <<F>>, <<g>>, or <<G>>, the |
integer portion of the conversion would be formatted |
with thousands' grouping wide characters.) |
o - |
The result of the conversion is left |
justified, and the right is padded with |
blanks. If you do not use this flag, the |
result is right justified, and padded on the |
left. |
o + |
The result of a signed conversion (as |
determined by <[type]> of <<d>>, <<i>>, <<a>>, |
<<A>>, <<e>>, <<E>>, <<f>>, <<F>>, <<g>>, or |
<<G>>) will always begin with a plus or minus |
sign. (If you do not use this flag, positive |
values do not begin with a plus sign.) |
o " " (space) |
If the first character of a signed conversion |
specification is not a sign, or if a signed |
conversion results in no characters, the |
result will begin with a space. If the space |
( ) flag and the plus (<<+>>) flag both |
appear, the space flag is ignored. |
o 0 |
If the <[type]> character is <<d>>, <<i>>, |
<<o>>, <<u>>, <<x>>, <<X>>, <<a>>, <<A>>, |
<<e>>, <<E>>, <<f>>, <<F>>, <<g>>, or <<G>>: leading |
zeros are used to pad the field width |
(following any indication of sign or base); no |
spaces are used for padding. If the zero |
(<<0>>) and minus (<<->>) flags both appear, |
the zero (<<0>>) flag will be ignored. For |
<<d>>, <<i>>, <<o>>, <<u>>, <<x>>, and <<X>> |
conversions, if a precision <[prec]> is |
specified, the zero (<<0>>) flag is ignored. |
Note that <<0>> is interpreted as a flag, not |
as the beginning of a field width. |
o # |
The result is to be converted to an |
alternative form, according to the <[type]> |
character: |
o+ |
o o |
Increases precision to force the first |
digit of the result to be a zero. |
o x |
A non-zero result will have a <<0x>> |
prefix. |
o X |
A non-zero result will have a <<0X>> |
prefix. |
o a, A, e, E, f, or F |
The result will always contain a |
decimal point even if no digits follow |
the point. (Normally, a decimal point |
appears only if a digit follows it.) |
Trailing zeros are removed. |
o g or G |
The result will always contain a |
decimal point even if no digits follow |
the point. Trailing zeros are not |
removed. |
o all others |
Undefined. |
o- |
o- |
o <[width]> |
<[width]> is an optional minimum field width. You can |
either specify it directly as a decimal integer, or |
indirectly by using instead an asterisk (<<*>>), in |
which case an <<int>> argument is used as the field |
width. If positional arguments are used, then the |
width must also be specified positionally as <<*m$>>, |
with m as a decimal integer. Negative field widths |
are treated as specifying the minus (<<->>) flag for |
left justfication, along with a positive field width. |
The resulting format may be wider than the specified |
width. |
o <[prec]> |
<[prec]> is an optional field; if present, it is |
introduced with `<<.>>' (a period). You can specify |
the precision either directly as a decimal integer or |
indirectly by using an asterisk (<<*>>), in which case |
an <<int>> argument is used as the precision. If |
positional arguments are used, then the precision must |
also be specified positionally as <<*m$>>, with m as a |
decimal integer. Supplying a negative precision is |
equivalent to omitting the precision. If only a |
period is specified the precision is zero. The effect |
depends on the conversion <[type]>. |
o+ |
o d, i, o, u, x, or X |
Minimum number of digits to appear. If no |
precision is given, defaults to 1. |
o a or A |
Number of digits to appear after the decimal |
point. If no precision is given, the |
precision defaults to the minimum needed for |
an exact representation. |
o e, E, f or F |
Number of digits to appear after the decimal |
point. If no precision is given, the |
precision defaults to 6. |
o g or G |
Maximum number of significant digits. A |
precision of 0 is treated the same as a |
precision of 1. If no precision is given, the |
precision defaults to 6. |
o s or S |
Maximum number of characters to print from the |
string. If no precision is given, the entire |
string is printed. |
o all others |
undefined. |
o- |
o <[size]> |
<[size]> is an optional modifier that changes the data |
type that the corresponding argument has. Behavior is |
unspecified if a size is given that does not match the |
<[type]>. |
o+ |
o hh |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument should be |
converted to a <<signed char>> or <<unsigned |
char>> before printing. |
With <<n>>, specifies that the argument is a |
pointer to a <<signed char>>. |
o h |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument should be |
converted to a <<short>> or <<unsigned short>> |
before printing. |
With <<n>>, specifies that the argument is a |
pointer to a <<short>>. |
o l |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument is a |
<<long>> or <<unsigned long>>. |
With <<c>>, specifies that the argument has |
type <<wint_t>>. |
With <<s>>, specifies that the argument is a |
pointer to <<wchar_t>>. |
With <<n>>, specifies that the argument is a |
pointer to a <<long>>. |
With <<a>>, <<A>>, <<e>>, <<E>>, <<f>>, <<F>>, |
<<g>>, or <<G>>, has no effect (because of |
vararg promotion rules, there is no need to |
distinguish between <<float>> and <<double>>). |
o ll |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument is a |
<<long long>> or <<unsigned long long>>. |
With <<n>>, specifies that the argument is a |
pointer to a <<long long>>. |
o j |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument is an |
<<intmax_t>> or <<uintmax_t>>. |
With <<n>>, specifies that the argument is a |
pointer to an <<intmax_t>>. |
o z |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument is a <<size_t>>. |
With <<n>>, specifies that the argument is a |
pointer to a <<size_t>>. |
o t |
With <<d>>, <<i>>, <<o>>, <<u>>, <<x>>, or |
<<X>>, specifies that the argument is a |
<<ptrdiff_t>>. |
With <<n>>, specifies that the argument is a |
pointer to a <<ptrdiff_t>>. |
o L |
With <<a>>, <<A>>, <<e>>, <<E>>, <<f>>, <<F>>, |
<<g>>, or <<G>>, specifies that the argument |
is a <<long double>>. |
o- |
o <[type]> |
<[type]> specifies what kind of conversion <<printf>> |
performs. Here is a table of these: |
o+ |
o % |
Prints the percent character (<<%>>). |
o c |
Prints <[arg]> as single character. If the |
<<l>> size specifier is in effect, a multibyte |
character is printed. |
o C |
Short for <<%lc>>. A POSIX extension to the C standard. |
o s |
Prints the elements of a pointer to <<char>> |
until the precision or a null character is |
reached. If the <<l>> size specifier is in |
effect, the pointer is to an array of |
<<wchar_t>>, and the string is converted to |
multibyte characters before printing. |
o S |
Short for <<%ls>>. A POSIX extension to the C standard. |
o d or i |
Prints a signed decimal integer; takes an |
<<int>>. Leading zeros are inserted as |
necessary to reach the precision. A value of 0 with |
a precision of 0 produces an empty string. |
o D |
Newlib extension, short for <<%ld>>. |
o o |
Prints an unsigned octal integer; takes an |
<<unsigned>>. Leading zeros are inserted as |
necessary to reach the precision. A value of 0 with |
a precision of 0 produces an empty string. |
o O |
Newlib extension, short for <<%lo>>. |
o u |
Prints an unsigned decimal integer; takes an |
<<unsigned>>. Leading zeros are inserted as |
necessary to reach the precision. A value of 0 with |
a precision of 0 produces an empty string. |
o U |
Newlib extension, short for <<%lu>>. |
o x |
Prints an unsigned hexadecimal integer (using |
<<abcdef>> as digits beyond <<9>>); takes an |
<<unsigned>>. Leading zeros are inserted as |
necessary to reach the precision. A value of 0 with |
a precision of 0 produces an empty string. |
o X |
Like <<x>>, but uses <<ABCDEF>> as digits |
beyond <<9>>. |
o f |
Prints a signed value of the form |
<<[-]9999.9999>>, with the precision |
determining how many digits follow the decimal |
point; takes a <<double>> (remember that |
<<float>> promotes to <<double>> as a vararg). |
The low order digit is rounded to even. If |
the precision results in at most DECIMAL_DIG |
digits, the result is rounded correctly; if |
more than DECIMAL_DIG digits are printed, the |
result is only guaranteed to round back to the |
original value. |
If the value is infinite, the result is |
<<inf>>, and no zero padding is performed. If |
the value is not a number, the result is |
<<nan>>, and no zero padding is performed. |
o F |
Like <<f>>, but uses <<INF>> and <<NAN>> for |
non-finite numbers. |
o e |
Prints a signed value of the form |
<<[-]9.9999e[+|-]999>>; takes a <<double>>. |
The digit before the decimal point is non-zero |
if the value is non-zero. The precision |
determines how many digits appear between |
<<.>> and <<e>>, and the exponent always |
contains at least two digits. The value zero |
has an exponent of zero. If the value is not |
finite, it is printed like <<f>>. |
o E |
Like <<e>>, but using <<E>> to introduce the |
exponent, and like <<F>> for non-finite |
values. |
o g |
Prints a signed value in either <<f>> or <<e>> |
form, based on the given value and |
precision---an exponent less than -4 or |
greater than the precision selects the <<e>> |
form. Trailing zeros and the decimal point |
are printed only if necessary; takes a |
<<double>>. |
o G |
Like <<g>>, except use <<F>> or <<E>> form. |
o a |
Prints a signed value of the form |
<<[-]0x1.ffffp[+|-]9>>; takes a <<double>>. |
The letters <<abcdef>> are used for digits |
beyond <<9>>. The precision determines how |
many digits appear after the decimal point. |
The exponent contains at least one digit, and |
is a decimal value representing the power of |
2; a value of 0 has an exponent of 0. |
Non-finite values are printed like <<f>>. |
o A |
Like <<a>>, except uses <<X>>, <<P>>, and |
<<ABCDEF>> instead of lower case. |
o n |
Takes a pointer to <<int>>, and stores a count |
of the number of bytes written so far. No |
output is created. |
o p |
Takes a pointer to <<void>>, and prints it in |
an implementation-defined format. This |
implementation is similar to <<%#tx>>), except |
that <<0x>> appears even for the NULL pointer. |
o- |
O- |
<<_printf_r>>, <<_fprintf_r>>, <<_asprintf_r>>, |
<<_sprintf_r>>, <<_snprintf_r>>, <<_asnprintf_r>> are simply |
reentrant versions of the functions above. |
RETURNS |
On success, <<sprintf>> and <<asprintf>> return the number of bytes in |
the output string, except the concluding <<NUL>> is not counted. |
<<snprintf>> returns the number of bytes that would be in the output |
string, except the concluding <<NUL>> is not counted. <<printf>> and |
<<fprintf>> return the number of characters transmitted. |
<<asnprintf>> returns the original <[str]> if there was enough room, |
otherwise it returns an allocated string. |
If an error occurs, the result of <<printf>>, <<fprintf>>, |
<<snprintf>>, and <<asprintf>> is a negative value, and the result of |
<<asnprintf>> is NULL. No error returns occur for <<sprintf>>. For |
<<printf>> and <<fprintf>>, <<errno>> may be set according to |
<<fputc>>. For <<asprintf>> and <<asnprintf>>, <<errno>> may be set |
to ENOMEM if allocation fails, and for <<snprintf>>, <<errno>> may be |
set to EOVERFLOW if <[size]> or the output length exceeds INT_MAX. |
BUGS |
The ``''' (quote) flag does not work when locale's thousands_sep is not empty. |
PORTABILITY |
ANSI C requires <<printf>>, <<fprintf>>, <<sprintf>>, and |
<<snprintf>>. <<asprintf>> and <<asnprintf>> are newlib extensions. |
The ANSI C standard specifies that implementations must support at |
least formatted output of up to 509 characters. This implementation |
has no inherent limit. |
Depending on how newlib was configured, not all format specifiers are |
supported. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include <limits.h> |
#include "local.h" |
int |
#ifdef _HAVE_STDC |
_DEFUN(_sprintf_r, (ptr, str, fmt), |
struct _reent *ptr _AND |
char *str _AND |
_CONST char *fmt _DOTS) |
#else |
_sprintf_r(ptr, str, fmt, va_alist) |
struct _reent *ptr; |
char *str; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = INT_MAX; |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
va_end (ap); |
*f._p = '\0'; /* terminate the string */ |
return (ret); |
} |
#ifndef _REENT_ONLY |
int |
#ifdef _HAVE_STDC |
_DEFUN(sprintf, (str, fmt), |
char *str _AND |
_CONST char *fmt _DOTS) |
#else |
sprintf(str, fmt, va_alist) |
char *str; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = INT_MAX; |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = _svfprintf_r (_REENT, &f, fmt, ap); |
va_end (ap); |
*f._p = '\0'; /* terminate the string */ |
return (ret); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/sscanf.c |
---|
0,0 → 1,469 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<sscanf>>, <<fscanf>>, <<scanf>>---scan and format input |
INDEX |
scanf |
INDEX |
_scanf_r |
INDEX |
fscanf |
INDEX |
_fscanf_r |
INDEX |
sscanf |
INDEX |
_sscanf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int scanf(const char *<[format]>, ...); |
int fscanf(FILE *<[fd]>, const char *<[format]>, ...); |
int sscanf(const char *<[str]>, const char *<[format]>, ...); |
int _scanf_r(struct _reent *<[ptr]>, const char *<[format]>, ...); |
int _fscanf_r(struct _reent *<[ptr]>, FILE *<[fd]>, |
const char *<[format]>, ...); |
int _sscanf_r(struct _reent *<[ptr]>, const char *<[str]>, |
const char *<[format]>, ...); |
TRAD_SYNOPSIS |
#include <stdio.h> |
int scanf(<[format]> [, <[arg]>, ...]) |
char *<[format]>; |
int fscanf(<[fd]>, <[format]> [, <[arg]>, ...]); |
FILE *<[fd]>; |
char *<[format]>; |
int sscanf(<[str]>, <[format]> [, <[arg]>, ...]); |
char *<[str]>; |
char *<[format]>; |
int _scanf_r(<[ptr]>, <[format]> [, <[arg]>, ...]) |
struct _reent *<[ptr]>; |
char *<[format]>; |
int _fscanf_r(<[ptr]>, <[fd]>, <[format]> [, <[arg]>, ...]); |
struct _reent *<[ptr]>; |
FILE *<[fd]>; |
char *<[format]>; |
int _sscanf_r(<[ptr]>, <[str]>, <[format]> [, <[arg]>, ...]); |
struct _reent *<[ptr]>; |
char *<[str]>; |
char *<[format]>; |
DESCRIPTION |
<<scanf>> scans a series of input fields from standard input, |
one character at a time. Each field is interpreted according to |
a format specifier passed to <<scanf>> in the format string at |
<<*<[format]>>>. <<scanf>> stores the interpreted input from |
each field at the address passed to it as the corresponding argument |
following <[format]>. You must supply the same number of |
format specifiers and address arguments as there are input fields. |
There must be sufficient address arguments for the given format |
specifiers; if not the results are unpredictable and likely |
disasterous. Excess address arguments are merely ignored. |
<<scanf>> often produces unexpected results if the input diverges from |
an expected pattern. Since the combination of <<gets>> or <<fgets>> |
followed by <<sscanf>> is safe and easy, that is the preferred way |
to be certain that a program is synchronized with input at the end |
of a line. |
<<fscanf>> and <<sscanf>> are identical to <<scanf>>, other than the |
source of input: <<fscanf>> reads from a file, and <<sscanf>> |
from a string. |
The routines <<_scanf_r>>, <<_fscanf_r>>, and <<_sscanf_r>> are reentrant |
versions of <<scanf>>, <<fscanf>>, and <<sscanf>> that take an additional |
first argument pointing to a reentrancy structure. |
The string at <<*<[format]>>> is a character sequence composed |
of zero or more directives. Directives are composed of |
one or more whitespace characters, non-whitespace characters, |
and format specifications. |
Whitespace characters are blank (<< >>), tab (<<\t>>), or |
newline (<<\n>>). |
When <<scanf>> encounters a whitespace character in the format string |
it will read (but not store) all consecutive whitespace characters |
up to the next non-whitespace character in the input. |
Non-whitespace characters are all other ASCII characters except the |
percent sign (<<%>>). When <<scanf>> encounters a non-whitespace |
character in the format string it will read, but not store |
a matching non-whitespace character. |
Format specifications tell <<scanf>> to read and convert characters |
from the input field into specific types of values, and store then |
in the locations specified by the address arguments. |
Trailing whitespace is left unread unless explicitly |
matched in the format string. |
The format specifiers must begin with a percent sign (<<%>>) |
and have the following form: |
. %[*][<[width]>][<[size]>]<[type]> |
Each format specification begins with the percent character (<<%>>). |
The other fields are: |
o+ |
o * |
an optional marker; if present, it suppresses interpretation and |
assignment of this input field. |
o <[width]> |
an optional maximum field width: a decimal integer, |
which controls the maximum number of characters that |
will be read before converting the current input field. If the |
input field has fewer than <[width]> characters, <<scanf>> |
reads all the characters in the field, and then |
proceeds with the next field and its format specification. |
If a whitespace or a non-convertable character occurs |
before <[width]> character are read, the characters up |
to that character are read, converted, and stored. |
Then <<scanf>> proceeds to the next format specification. |
o size |
<<h>>, <<j>>, <<l>>, <<L>>, <<t>>, and <<z>> are optional size |
characters which override the default way that <<scanf>> |
interprets the data type of the corresponding argument. |
.Modifier Type(s) |
. hh d, i, o, u, x, n convert input to char, |
. store in char object |
. |
. h d, i, o, u, x, n convert input to short, |
. store in short object |
. |
. h D, I, O, U, X no effect |
. e, f, c, s, p |
. |
. j d, i, o, u, x, n convert input to intmax_t, |
. store in intmax_t object |
. |
. j all others no effect |
. |
. l d, i, o, u, x, n convert input to long, |
. store in long object |
. |
. l e, f, g convert input to double |
. store in a double object |
. |
. l D, I, O, U, X no effect |
. c, s, p |
. |
. ll d, i, o, u, x, n convert to long long, |
. store in long long |
. |
. L d, i, o, u, x, n convert to long long, |
. store in long long |
. |
. L e, f, g, E, G convert to long double, |
. store in long double |
. |
. L all others no effect |
. |
. t d, i, o, u, x, n convert input to ptrdiff_t, |
. store in ptrdiff_t object |
. |
. t all others no effect |
. |
. z d, i, o, u, x, n convert input to size_t, |
. store in size_t object |
. |
. z all others no effect |
. |
o <[type]> |
A character to specify what kind of conversion |
<<scanf>> performs. Here is a table of the conversion |
characters: |
o+ |
o % |
No conversion is done; the percent character (<<%>>) is stored. |
o c |
Scans one character. Corresponding <[arg]>: <<(char *arg)>>. |
o s |
Reads a character string into the array supplied. |
Corresponding <[arg]>: <<(char arg[])>>. |
o [<[pattern]>] |
Reads a non-empty character string into memory |
starting at <[arg]>. This area must be large |
enough to accept the sequence and a |
terminating null character which will be added |
automatically. (<[pattern]> is discussed in the paragraph following |
this table). Corresponding <[arg]>: <<(char *arg)>>. |
o d |
Reads a decimal integer into the corresponding <[arg]>: <<(int *arg)>>. |
o D |
Reads a decimal integer into the corresponding |
<[arg]>: <<(long *arg)>>. |
o o |
Reads an octal integer into the corresponding <[arg]>: <<(int *arg)>>. |
o O |
Reads an octal integer into the corresponding <[arg]>: <<(long *arg)>>. |
o u |
Reads an unsigned decimal integer into the corresponding |
<[arg]>: <<(unsigned int *arg)>>. |
o U |
Reads an unsigned decimal integer into the corresponding <[arg]>: |
<<(unsigned long *arg)>>. |
o x,X |
Read a hexadecimal integer into the corresponding <[arg]>: |
<<(int *arg)>>. |
o e, f, g |
Read a floating-point number into the corresponding <[arg]>: |
<<(float *arg)>>. |
o E, F, G |
Read a floating-point number into the corresponding <[arg]>: |
<<(double *arg)>>. |
o i |
Reads a decimal, octal or hexadecimal integer into the |
corresponding <[arg]>: <<(int *arg)>>. |
o I |
Reads a decimal, octal or hexadecimal integer into the |
corresponding <[arg]>: <<(long *arg)>>. |
o n |
Stores the number of characters read in the corresponding |
<[arg]>: <<(int *arg)>>. |
o p |
Stores a scanned pointer. ANSI C leaves the details |
to each implementation; this implementation treats |
<<%p>> exactly the same as <<%U>>. Corresponding |
<[arg]>: <<(void **arg)>>. |
o- |
A <[pattern]> of characters surrounded by square brackets can be used |
instead of the <<s>> type character. <[pattern]> is a set of |
characters which define a search set of possible characters making up |
the <<scanf>> input field. If the first character in the brackets is a |
caret (<<^>>), the search set is inverted to include all ASCII characters |
except those between the brackets. There is also a range facility |
which you can use as a shortcut. <<%[0-9] >> matches all decimal digits. |
The hyphen must not be the first or last character in the set. |
The character prior to the hyphen must be lexically less than the |
character after it. |
Here are some <[pattern]> examples: |
o+ |
o %[abcd] |
matches strings containing only <<a>>, <<b>>, <<c>>, and <<d>>. |
o %[^abcd] |
matches strings containing any characters except <<a>>, <<b>>, |
<<c>>, or <<d>> |
o %[A-DW-Z] |
matches strings containing <<A>>, <<B>>, <<C>>, <<D>>, <<W>>, |
<<X>>, <<Y>>, <<Z>> |
o %[z-a] |
matches the characters <<z>>, <<->>, and <<a>> |
o- |
Floating point numbers (for field types <<e>>, <<f>>, <<g>>, <<E>>, |
<<F>>, <<G>>) must correspond to the following general form: |
. [+/-] ddddd[.]ddd [E|e[+|-]ddd] |
where objects inclosed in square brackets are optional, and <<ddd>> |
represents decimal, octal, or hexadecimal digits. |
o- |
RETURNS |
<<scanf>> returns the number of input fields successfully |
scanned, converted and stored; the return value does |
not include scanned fields which were not stored. |
If <<scanf>> attempts to read at end-of-file, the return |
value is <<EOF>>. |
If no fields were stored, the return value is <<0>>. |
<<scanf>> might stop scanning a particular field before |
reaching the normal field end character, or may |
terminate entirely. |
<<scanf>> stops scanning and storing the current field |
and moves to the next input field (if any) |
in any of the following situations: |
O+ |
o The assignment suppressing character (<<*>>) appears |
after the <<%>> in the format specification; the current |
input field is scanned but not stored. |
o <[width]> characters have been read (<[width]> is a |
width specification, a positive decimal integer). |
o The next character read cannot be converted |
under the the current format (for example, |
if a <<Z>> is read when the format is decimal). |
o The next character in the input field does not appear |
in the search set (or does appear in the inverted search set). |
O- |
When <<scanf>> stops scanning the current input field for one of |
these reasons, the next character is considered unread and |
used as the first character of the following input field, or the |
first character in a subsequent read operation on the input. |
<<scanf>> will terminate under the following circumstances: |
O+ |
o The next character in the input field conflicts |
with a corresponding non-whitespace character in the |
format string. |
o The next character in the input field is <<EOF>>. |
o The format string has been exhausted. |
O- |
When the format string contains a character sequence that is |
not part of a format specification, the same character |
sequence must appear in the input; <<scanf>> will |
scan but not store the matched characters. If a |
conflict occurs, the first conflicting character remains in the input |
as if it had never been read. |
PORTABILITY |
<<scanf>> is ANSI C. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <string.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include "local.h" |
#ifndef _REENT_ONLY |
#ifdef _HAVE_STDC |
int |
_DEFUN(sscanf, (str, fmt), |
_CONST char *str _AND |
_CONST char *fmt _DOTS) |
#else |
int |
sscanf(str, fmt, va_alist) |
_CONST char *str; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
f._flags = __SRD | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._r = strlen (str); |
f._read = __seofread; |
f._ub._base = NULL; |
f._lb._base = NULL; |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = __ssvfscanf_r (_REENT, &f, fmt, ap); |
va_end (ap); |
return ret; |
} |
#endif /* !_REENT_ONLY */ |
#ifdef _HAVE_STDC |
int |
_DEFUN(_sscanf_r, (ptr, str, fmt), |
struct _reent *ptr _AND |
_CONST char *str _AND |
_CONST char *fmt _DOTS) |
#else |
int |
_sscanf_r(ptr, str, fmt, va_alist) |
struct _reent *ptr; |
_CONST char *str; |
_CONST char *fmt; |
va_dcl |
#endif |
{ |
int ret; |
va_list ap; |
FILE f; |
f._flags = __SRD | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._r = strlen (str); |
f._read = __seofread; |
f._ub._base = NULL; |
f._lb._base = NULL; |
f._file = -1; /* No file. */ |
#ifdef _HAVE_STDC |
va_start (ap, fmt); |
#else |
va_start (ap); |
#endif |
ret = __ssvfscanf_r (ptr, &f, fmt, ap); |
va_end (ap); |
return ret; |
} |
/contrib/sdk/sources/libc/stdio/stdio.c |
---|
0,0 → 1,150 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <sys/types.h> |
#include <fcntl.h> |
#include <sys/unistd.h> |
#include "local.h" |
/* |
* Small standard I/O/seek/close functions. |
* These maintain the `known seek offset' for seek optimisation. |
*/ |
_READ_WRITE_RETURN_TYPE |
_DEFUN(__sread, (ptr, cookie, buf, n), |
struct _reent *ptr _AND |
void *cookie _AND |
char *buf _AND |
int n) |
{ |
register FILE *fp = (FILE *) cookie; |
register int ret; |
#ifdef __SCLE |
int oldmode = 0; |
if (fp->_flags & __SCLE) |
oldmode = setmode (fp->_file, O_BINARY); |
#endif |
ret = _read_r (ptr, fp->_file, buf, n); |
#ifdef __SCLE |
if (oldmode) |
setmode (fp->_file, oldmode); |
#endif |
/* If the read succeeded, update the current offset. */ |
if (ret >= 0) |
fp->_offset += ret; |
else |
fp->_flags &= ~__SOFF; /* paranoia */ |
return ret; |
} |
/* Dummy function used in sscanf/swscanf. */ |
_READ_WRITE_RETURN_TYPE |
_DEFUN(__seofread, (ptr, cookie, buf, len), |
struct _reent *_ptr _AND |
_PTR cookie _AND |
char *buf _AND |
int len) |
{ |
return 0; |
} |
_READ_WRITE_RETURN_TYPE |
_DEFUN(__swrite, (ptr, cookie, buf, n), |
struct _reent *ptr _AND |
void *cookie _AND |
char const *buf _AND |
int n) |
{ |
register FILE *fp = (FILE *) cookie; |
int w; |
#ifdef __SCLE |
int oldmode=0; |
#endif |
if (fp->_flags & __SAPP) |
_lseek_r (ptr, fp->_file, (_off_t) 0, SEEK_END); |
fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */ |
#ifdef __SCLE |
if (fp->_flags & __SCLE) |
oldmode = setmode (fp->_file, O_BINARY); |
#endif |
w = _write_r (ptr, fp->_file, buf, n); |
#ifdef __SCLE |
if (oldmode) |
setmode (fp->_file, oldmode); |
#endif |
return w; |
} |
_fpos_t |
_DEFUN(__sseek, (ptr, cookie, offset, whence), |
struct _reent *ptr _AND |
void *cookie _AND |
_fpos_t offset _AND |
int whence) |
{ |
register FILE *fp = (FILE *) cookie; |
register _off_t ret; |
ret = _lseek_r (ptr, fp->_file, (_off_t) offset, whence); |
if (ret == -1L) |
fp->_flags &= ~__SOFF; |
else |
{ |
fp->_flags |= __SOFF; |
fp->_offset = ret; |
} |
return ret; |
} |
int |
_DEFUN(__sclose, (ptr, cookie), |
struct _reent *ptr _AND |
void *cookie) |
{ |
FILE *fp = (FILE *) cookie; |
return _close_r (ptr, fp->_file); |
} |
#ifdef __SCLE |
int |
_DEFUN(__stextmode, (fd), |
int fd) |
{ |
#ifdef __CYGWIN__ |
extern int _cygwin_istext_for_stdio (int); |
return _cygwin_istext_for_stdio (fd); |
#else |
return 0; |
#endif |
} |
#endif |
/contrib/sdk/sources/libc/stdio/tmpfile.c |
---|
0,0 → 1,96 |
/* |
FUNCTION |
<<tmpfile>>---create a temporary file |
INDEX |
tmpfile |
INDEX |
_tmpfile_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
FILE *tmpfile(void); |
FILE *_tmpfile_r(struct _reent *<[reent]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
FILE *tmpfile(); |
FILE *_tmpfile_r(<[reent]>) |
struct _reent *<[reent]>; |
DESCRIPTION |
Create a temporary file (a file which will be deleted automatically), |
using a name generated by <<tmpnam>>. The temporary file is opened with |
the mode <<"wb+">>, permitting you to read and write anywhere in it |
as a binary file (without any data transformations the host system may |
perform for text files). |
The alternate function <<_tmpfile_r>> is a reentrant version. The |
argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
<<tmpfile>> normally returns a pointer to the temporary file. If no |
temporary file could be created, the result is NULL, and <<errno>> |
records the reason for failure. |
PORTABILITY |
Both ANSI C and the System V Interface Definition (Issue 2) require |
<<tmpfile>>. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<getpid>>, |
<<isatty>>, <<lseek>>, <<open>>, <<read>>, <<sbrk>>, <<write>>. |
<<tmpfile>> also requires the global pointer <<environ>>. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <sys/stat.h> |
#ifndef O_BINARY |
# define O_BINARY 0 |
#endif |
FILE * |
_DEFUN(_tmpfile_r, (ptr), |
struct _reent *ptr) |
{ |
FILE *fp; |
int e; |
char *f; |
char buf[L_tmpnam]; |
int fd; |
do |
{ |
if ((f = _tmpnam_r (ptr, buf)) == NULL) |
return NULL; |
fd = _open_r (ptr, f, O_RDWR | O_CREAT | O_EXCL | O_BINARY, |
S_IRUSR | S_IWUSR); |
} |
while (fd < 0 && ptr->_errno == EEXIST); |
if (fd < 0) |
return NULL; |
fp = _fdopen_r (ptr, fd, "wb+"); |
e = ptr->_errno; |
if (!fp) |
_close_r (ptr, fd); |
_CAST_VOID _remove_r (ptr, f); |
ptr->_errno = e; |
return fp; |
} |
#ifndef _REENT_ONLY |
FILE * |
_DEFUN_VOID(tmpfile) |
{ |
return _tmpfile_r (_REENT); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/tmpnam.c |
---|
0,0 → 1,209 |
/* |
* tmpname.c |
* Original Author: G. Haley |
*/ |
/* |
FUNCTION |
<<tmpnam>>, <<tempnam>>---name for a temporary file |
INDEX |
tmpnam |
INDEX |
tempnam |
INDEX |
_tmpnam_r |
INDEX |
_tempnam_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
char *tmpnam(char *<[s]>); |
char *tempnam(char *<[dir]>, char *<[pfx]>); |
char *_tmpnam_r(struct _reent *<[reent]>, char *<[s]>); |
char *_tempnam_r(struct _reent *<[reent]>, char *<[dir]>, char *<[pfx]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
char *tmpnam(<[s]>) |
char *<[s]>; |
char *tempnam(<[dir]>, <[pfx]>) |
char *<[dir]>; |
char *<[pfx]>; |
char *_tmpnam_r(<[reent]>, <[s]>) |
struct _reent *<[reent]>; |
char *<[s]>; |
char *_tempnam_r(<[reent]>, <[dir]>, <[pfx]>) |
struct *<[reent]>; |
char *<[dir]>; |
char *<[pfx]>; |
DESCRIPTION |
Use either of these functions to generate a name for a temporary file. |
The generated name is guaranteed to avoid collision with other files |
(for up to <<TMP_MAX>> calls of either function). |
<<tmpnam>> generates file names with the value of <<P_tmpdir>> |
(defined in `<<stdio.h>>') as the leading directory component of the path. |
You can use the <<tmpnam>> argument <[s]> to specify a suitable area |
of memory for the generated filename; otherwise, you can call |
<<tmpnam(NULL)>> to use an internal static buffer. |
<<tempnam>> allows you more control over the generated filename: you |
can use the argument <[dir]> to specify the path to a directory for |
temporary files, and you can use the argument <[pfx]> to specify a |
prefix for the base filename. |
If <[dir]> is <<NULL>>, <<tempnam>> will attempt to use the value of |
environment variable <<TMPDIR>> instead; if there is no such value, |
<<tempnam>> uses the value of <<P_tmpdir>> (defined in `<<stdio.h>>'). |
If you don't need any particular prefix to the basename of temporary |
files, you can pass <<NULL>> as the <[pfx]> argument to <<tempnam>>. |
<<_tmpnam_r>> and <<_tempnam_r>> are reentrant versions of <<tmpnam>> |
and <<tempnam>> respectively. The extra argument <[reent]> is a |
pointer to a reentrancy structure. |
WARNINGS |
The generated filenames are suitable for temporary files, but do not |
in themselves make files temporary. Files with these names must still |
be explicitly removed when you no longer want them. |
If you supply your own data area <[s]> for <<tmpnam>>, you must ensure |
that it has room for at least <<L_tmpnam>> elements of type <<char>>. |
RETURNS |
Both <<tmpnam>> and <<tempnam>> return a pointer to the newly |
generated filename. |
PORTABILITY |
ANSI C requires <<tmpnam>>, but does not specify the use of |
<<P_tmpdir>>. The System V Interface Definition (Issue 2) requires |
both <<tmpnam>> and <<tempnam>>. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<getpid>>, |
<<isatty>>, <<lseek>>, <<open>>, <<read>>, <<sbrk>>, <<write>>. |
The global pointer <<environ>> is also required. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <fcntl.h> |
#include <reent.h> |
#include <errno.h> |
/* Try to open the file specified, if it can't be opened then try |
another one. Return nonzero if successful, otherwise zero. */ |
static int |
_DEFUN(worker, (ptr, result, part1, part2, part3, part4), |
struct _reent *ptr _AND |
char *result _AND |
_CONST char *part1 _AND |
_CONST char *part2 _AND |
int part3 _AND |
int *part4) |
{ |
/* Generate the filename and make sure that there isn't one called |
it already. */ |
while (1) |
{ |
int t; |
_sprintf_r (ptr, result, "%s/%s%x.%x", part1, part2, part3, *part4); |
(*part4)++; |
t = _open_r (ptr, result, O_RDONLY, 0); |
if (t == -1) |
{ |
if (ptr->_errno == ENOSYS) |
{ |
result[0] = '\0'; |
return 0; |
} |
break; |
} |
_close_r (ptr, t); |
} |
return 1; |
} |
char * |
_DEFUN(_tmpnam_r, (p, s), |
struct _reent *p _AND |
char *s) |
{ |
char *result; |
int pid; |
if (s == NULL) |
{ |
/* ANSI states we must use an internal static buffer if s is NULL */ |
_REENT_CHECK_EMERGENCY(p); |
result = _REENT_EMERGENCY(p); |
} |
else |
{ |
result = s; |
} |
pid = _getpid_r (p); |
if (worker (p, result, P_tmpdir, "t", pid, &p->_inc)) |
{ |
p->_inc++; |
return result; |
} |
return NULL; |
} |
char * |
_DEFUN(_tempnam_r, (p, dir, pfx), |
struct _reent *p _AND |
_CONST char *dir _AND |
_CONST char *pfx) |
{ |
char *filename; |
int length; |
_CONST char *prefix = (pfx) ? pfx : ""; |
if (dir == NULL && (dir = getenv ("TMPDIR")) == NULL) |
dir = P_tmpdir; |
/* two 8 digit numbers + . / */ |
length = strlen (dir) + strlen (prefix) + (4 * sizeof (int)) + 2 + 1; |
filename = _malloc_r (p, length); |
if (filename) |
{ |
if (! worker (p, filename, dir, prefix, |
_getpid_r (p) ^ (int) (_POINTER_INT) p, &p->_inc)) |
return NULL; |
} |
return filename; |
} |
#ifndef _REENT_ONLY |
char * |
_DEFUN(tempnam, (dir, pfx), |
_CONST char *dir _AND |
_CONST char *pfx) |
{ |
return _tempnam_r (_REENT, dir, pfx); |
} |
char * |
_DEFUN(tmpnam, (s), |
char *s) |
{ |
return _tmpnam_r (_REENT, s); |
} |
#endif |
/contrib/sdk/sources/libc/stdio/ungetc.c |
---|
0,0 → 1,217 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<ungetc>>---push data back into a stream |
INDEX |
ungetc |
INDEX |
_ungetc_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
int ungetc(int <[c]>, FILE *<[stream]>); |
int _ungetc_r(struct _reent *<[reent]>, int <[c]>, FILE *<[stream]>); |
DESCRIPTION |
<<ungetc>> is used to return bytes back to <[stream]> to be read again. |
If <[c]> is EOF, the stream is unchanged. Otherwise, the unsigned |
char <[c]> is put back on the stream, and subsequent reads will see |
the bytes pushed back in reverse order. Pushed byes are lost if the |
stream is repositioned, such as by <<fseek>>, <<fsetpos>>, or |
<<rewind>>. |
The underlying file is not changed, but it is possible to push back |
something different than what was originally read. Ungetting a |
character will clear the end-of-stream marker, and decrement the file |
position indicator. Pushing back beyond the beginning of a file gives |
unspecified behavior. |
The alternate function <<_ungetc_r>> is a reentrant version. The |
extra argument <[reent]> is a pointer to a reentrancy structure. |
RETURNS |
The character pushed back, or <<EOF>> on error. |
PORTABILITY |
ANSI C requires <<ungetc>>, but only requires a pushback buffer of one |
byte; although this implementation can handle multiple bytes, not all |
can. Pushing back a signed char is a common application bug. |
Supporting OS subroutines required: <<sbrk>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include "local.h" |
/* |
* Expand the ungetc buffer `in place'. That is, adjust fp->_p when |
* the buffer moves, so that it points the same distance from the end, |
* and move the bytes in the buffer around as necessary so that they |
* are all at the end (stack-style). |
*/ |
/*static*/ |
int |
_DEFUN(__submore, (rptr, fp), |
struct _reent *rptr _AND |
register FILE *fp) |
{ |
register int i; |
register unsigned char *p; |
if (fp->_ub._base == fp->_ubuf) |
{ |
/* |
* Get a new buffer (rather than expanding the old one). |
*/ |
if ((p = (unsigned char *) _malloc_r (rptr, (size_t) BUFSIZ)) == NULL) |
return EOF; |
fp->_ub._base = p; |
fp->_ub._size = BUFSIZ; |
p += BUFSIZ - sizeof (fp->_ubuf); |
for (i = sizeof (fp->_ubuf); --i >= 0;) |
p[i] = fp->_ubuf[i]; |
fp->_p = p; |
return 0; |
} |
i = fp->_ub._size; |
p = (unsigned char *) _realloc_r (rptr, (_PTR) (fp->_ub._base), i << 1); |
if (p == NULL) |
return EOF; |
_CAST_VOID memcpy ((_PTR) (p + i), (_PTR) p, (size_t) i); |
fp->_p = p + i; |
fp->_ub._base = p; |
fp->_ub._size = i << 1; |
return 0; |
} |
int |
_DEFUN(_ungetc_r, (rptr, c, fp), |
struct _reent *rptr _AND |
int c _AND |
register FILE *fp) |
{ |
if (c == EOF) |
return (EOF); |
/* Ensure stdio has been initialized. |
??? Might be able to remove this as some other stdio routine should |
have already been called to get the char we are un-getting. */ |
CHECK_INIT (rptr, fp); |
_flockfile (fp); |
ORIENT (fp, -1); |
/* After ungetc, we won't be at eof anymore */ |
fp->_flags &= ~__SEOF; |
if ((fp->_flags & __SRD) == 0) |
{ |
/* |
* Not already reading: no good unless reading-and-writing. |
* Otherwise, flush any current write stuff. |
*/ |
if ((fp->_flags & __SRW) == 0) |
{ |
_funlockfile (fp); |
return EOF; |
} |
if (fp->_flags & __SWR) |
{ |
if (_fflush_r (rptr, fp)) |
{ |
_funlockfile (fp); |
return EOF; |
} |
fp->_flags &= ~__SWR; |
fp->_w = 0; |
fp->_lbfsize = 0; |
} |
fp->_flags |= __SRD; |
} |
c = (unsigned char) c; |
/* |
* If we are in the middle of ungetc'ing, just continue. |
* This may require expanding the current ungetc buffer. |
*/ |
if (HASUB (fp)) |
{ |
if (fp->_r >= fp->_ub._size && __submore (rptr, fp)) |
{ |
_funlockfile (fp); |
return EOF; |
} |
*--fp->_p = c; |
fp->_r++; |
_funlockfile (fp); |
return c; |
} |
/* |
* If we can handle this by simply backing up, do so, |
* but never replace the original character. |
* (This makes sscanf() work when scanning `const' data.) |
*/ |
if (fp->_bf._base != NULL && fp->_p > fp->_bf._base && fp->_p[-1] == c) |
{ |
fp->_p--; |
fp->_r++; |
_funlockfile (fp); |
return c; |
} |
/* |
* Create an ungetc buffer. |
* Initially, we will use the `reserve' buffer. |
*/ |
fp->_ur = fp->_r; |
fp->_up = fp->_p; |
fp->_ub._base = fp->_ubuf; |
fp->_ub._size = sizeof (fp->_ubuf); |
fp->_ubuf[sizeof (fp->_ubuf) - 1] = c; |
fp->_p = &fp->_ubuf[sizeof (fp->_ubuf) - 1]; |
fp->_r = 1; |
_funlockfile (fp); |
return c; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(ungetc, (c, fp), |
int c _AND |
register FILE *fp) |
{ |
return _ungetc_r (_REENT, c, fp); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/vasniprintf.c |
---|
0,0 → 1,71 |
/* Copyright (C) 2007, 2008 Eric Blake |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* This code was derived from asprintf.c */ |
/* doc in viprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdarg.h> |
#include <limits.h> |
#include <errno.h> |
#include "local.h" |
char * |
_DEFUN(_vasniprintf_r, (ptr, buf, lenp, fmt, ap), |
struct _reent *ptr _AND |
char *buf _AND |
size_t *lenp _AND |
const char *fmt _AND |
va_list ap) |
{ |
int ret; |
FILE f; |
size_t len = *lenp; |
if (buf && len) |
{ |
/* mark an existing buffer, but allow allocation of larger string */ |
f._flags = __SWR | __SSTR | __SOPT; |
} |
else |
{ |
/* mark a zero-length reallocatable buffer */ |
f._flags = __SWR | __SSTR | __SMBF; |
len = 0; |
buf = NULL; |
} |
f._bf._base = f._p = (unsigned char *) buf; |
/* For now, inherit the 32-bit signed limit of FILE._bf._size. |
FIXME - it would be nice to rewrite sys/reent.h to support size_t |
for _size. */ |
if (len > INT_MAX) |
{ |
ptr->_errno = EOVERFLOW; |
return NULL; |
} |
f._bf._size = f._w = len; |
f._file = -1; /* No file. */ |
ret = _svfiprintf_r (ptr, &f, fmt, ap); |
if (ret < 0) |
return NULL; |
*lenp = ret; |
*f._p = '\0'; |
return (char *) f._bf._base; |
} |
#ifndef _REENT_ONLY |
char * |
_DEFUN(vasniprintf, (buf, lenp, fmt, ap), |
char *buf _AND |
size_t *lenp _AND |
const char *fmt _AND |
va_list ap) |
{ |
return _vasniprintf_r (_REENT, buf, lenp, fmt, ap); |
} |
#endif /* ! _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/vasnprintf.c |
---|
0,0 → 1,71 |
/* Copyright (C) 2007 Eric Blake |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* This code was derived from asprintf.c */ |
/* doc in vfprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdarg.h> |
#include <limits.h> |
#include <errno.h> |
#include "local.h" |
char * |
_DEFUN(_vasnprintf_r, (ptr, buf, lenp, fmt, ap), |
struct _reent *ptr _AND |
char *buf _AND |
size_t *lenp _AND |
const char *fmt _AND |
va_list ap) |
{ |
int ret; |
FILE f; |
size_t len = *lenp; |
if (buf && len) |
{ |
/* mark an existing buffer, but allow allocation of larger string */ |
f._flags = __SWR | __SSTR | __SOPT; |
} |
else |
{ |
/* mark a zero-length reallocatable buffer */ |
f._flags = __SWR | __SSTR | __SMBF; |
len = 0; |
buf = NULL; |
} |
f._bf._base = f._p = (unsigned char *) buf; |
/* For now, inherit the 32-bit signed limit of FILE._bf._size. |
FIXME - it would be nice to rewrite sys/reent.h to support size_t |
for _size. */ |
if (len > INT_MAX) |
{ |
ptr->_errno = EOVERFLOW; |
return NULL; |
} |
f._bf._size = f._w = len; |
f._file = -1; /* No file. */ |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
if (ret < 0) |
return NULL; |
*lenp = ret; |
*f._p = '\0'; |
return (char *) f._bf._base; |
} |
#ifndef _REENT_ONLY |
char * |
_DEFUN(vasnprintf, (buf, lenp, fmt, ap), |
char *buf _AND |
size_t *lenp _AND |
const char *fmt _AND |
va_list ap) |
{ |
return _vasnprintf_r (_REENT, buf, lenp, fmt, ap); |
} |
#endif /* ! _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/vdiprintf.c |
---|
0,0 → 1,47 |
/* Copyright 2005, 2007 Shaun Jackman |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* doc in diprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <stdarg.h> |
#include "local.h" |
int |
_DEFUN(_vdiprintf_r, (ptr, fd, format, ap), |
struct _reent *ptr _AND |
int fd _AND |
const char *format _AND |
va_list ap) |
{ |
char *p; |
char buf[512]; |
size_t n = sizeof buf; |
_REENT_SMALL_CHECK_INIT (ptr); |
p = _vasniprintf_r (ptr, buf, &n, format, ap); |
if (!p) |
return -1; |
n = _write_r (ptr, fd, p, n); |
if (p != buf) |
_free_r (ptr, p); |
return n; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(vdiprintf, (fd, format, ap), |
int fd _AND |
const char *format _AND |
va_list ap) |
{ |
return _vdiprintf_r (_REENT, fd, format, ap); |
} |
#endif /* ! _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/vdprintf.c |
---|
0,0 → 1,47 |
/* Copyright 2005, 2007 Shaun Jackman |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* doc in dprintf.c */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <unistd.h> |
#include <stdarg.h> |
#include "local.h" |
int |
_DEFUN(_vdprintf_r, (ptr, fd, format, ap), |
struct _reent *ptr _AND |
int fd _AND |
const char *format _AND |
va_list ap) |
{ |
char *p; |
char buf[512]; |
size_t n = sizeof buf; |
_REENT_SMALL_CHECK_INIT (ptr); |
p = _vasnprintf_r (ptr, buf, &n, format, ap); |
if (!p) |
return -1; |
n = _write_r (ptr, fd, p, n); |
if (p != buf) |
_free_r (ptr, p); |
return n; |
} |
#ifndef _REENT_ONLY |
int |
_DEFUN(vdprintf, (fd, format, ap), |
int fd _AND |
const char *format _AND |
va_list ap) |
{ |
return _vdprintf_r (_REENT, fd, format, ap); |
} |
#endif /* ! _REENT_ONLY */ |
/contrib/sdk/sources/libc/stdio/vfieeefp.h |
---|
0,0 → 1,283 |
/**************************************************************** |
* |
* The author of this software is David M. Gay. |
* |
* Copyright (c) 1991 by AT&T. |
* |
* Permission to use, copy, modify, and distribute this software for any |
* purpose without fee is hereby granted, provided that this entire notice |
* is included in all copies of any software which is or includes a copy |
* or modification of this software and in all copies of the supporting |
* documentation for such software. |
* |
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED |
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY |
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY |
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. |
* |
***************************************************************/ |
/* Please send bug reports to |
David M. Gay |
AT&T Bell Laboratories, Room 2C-463 |
600 Mountain Avenue |
Murray Hill, NJ 07974-2070 |
U.S.A. |
dmg@research.att.com or research!dmg |
*/ |
/* This header file is a modification of mprec.h that only contains floating |
point union code. */ |
#include <newlib.h> |
#include <ieeefp.h> |
#include <math.h> |
#include <float.h> |
#include <errno.h> |
#include <sys/config.h> |
#ifdef __IEEE_LITTLE_ENDIAN |
#define IEEE_8087 |
#endif |
#ifdef __IEEE_BIG_ENDIAN |
#define IEEE_MC68k |
#endif |
#ifdef __Z8000__ |
#define Just_16 |
#endif |
#ifdef Unsigned_Shifts |
#define Sign_Extend(a,b) if (b < 0) a |= (__uint32_t)0xffff0000; |
#else |
#define Sign_Extend(a,b) /*no-op*/ |
#endif |
#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 |
Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. |
#endif |
#ifdef _WANT_IO_LONG_DOUBLE |
/* If we are going to examine or modify specific bits in a long double using |
the lword0 or lwordx macros, then we must wrap the long double inside |
a union. This is necessary to avoid undefined behavior according to |
the ANSI C spec. */ |
#ifdef IEEE_8087 |
#if LDBL_MANT_DIG == 24 |
struct ldieee |
{ |
unsigned manh:23; |
unsigned exp:8; |
unsigned sign:1; |
}; |
#elif LDBL_MANT_DIG == 53 |
struct ldieee |
{ |
unsigned manl:20; |
unsigned manh:32; |
unsigned exp:11; |
unsigned sign:1; |
}; |
#elif LDBL_MANT_DIG == 64 |
struct ldieee |
{ |
unsigned manl:32; |
unsigned manh:32; |
unsigned exp:15; |
unsigned sign:1; |
}; |
#elif LDBL_MANT_DIG > 64 |
struct ldieee |
{ |
unsigned manl3:16; |
unsigned manl2:32; |
unsigned manl:32; |
unsigned manh:32; |
unsigned exp:15; |
unsigned sign:1; |
}; |
#endif /* LDBL_MANT_DIG */ |
#else /* !IEEE_8087 */ |
#if LDBL_MANT_DIG == 24 |
struct ldieee |
{ |
unsigned sign:1; |
unsigned exp:8; |
unsigned manh:23; |
}; |
#elif LDBL_MANT_DIG == 53 |
struct ldieee |
{ |
unsigned sign:1; |
unsigned exp:11; |
unsigned manh:32; |
unsigned manl:20; |
}; |
#elif LDBL_MANT_DIG == 64 |
struct ldieee |
{ |
unsigned sign:1; |
unsigned exp:15; |
unsigned manh:32; |
unsigned manl:32; |
}; |
#elif LDBL_MANT_DIG > 64 |
struct ldieee |
{ |
unsigned sign:1; |
unsigned exp:15; |
unsigned manh:32; |
unsigned manl:32; |
unsigned manl2:32; |
unsigned manl3;16; |
}; |
#endif /* LDBL_MANT_DIG */ |
#endif /* !IEEE_8087 */ |
#endif /* _WANT_IO_LONG_DOUBLE */ |
/* If we are going to examine or modify specific bits in a double using |
the word0 and/or word1 macros, then we must wrap the double inside |
a union. This is necessary to avoid undefined behavior according to |
the ANSI C spec. */ |
union double_union |
{ |
double d; |
__uint32_t i[2]; |
}; |
#ifdef IEEE_8087 |
#define word0(x) (x.i[1]) |
#define word1(x) (x.i[0]) |
#else |
#define word0(x) (x.i[0]) |
#define word1(x) (x.i[1]) |
#endif |
/* #define P DBL_MANT_DIG */ |
/* Ten_pmax = floor(P*log(2)/log(5)) */ |
/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ |
/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ |
/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ |
#if defined(IEEE_8087) + defined(IEEE_MC68k) |
#if defined (_DOUBLE_IS_32BITS) |
#define Exp_shift 23 |
#define Exp_shift1 23 |
#define Exp_msk1 ((__uint32_t)0x00800000L) |
#define Exp_msk11 ((__uint32_t)0x00800000L) |
#define Exp_mask ((__uint32_t)0x7f800000L) |
#define P 24 |
#define Bias 127 |
#define IEEE_Arith |
#define Emin (-126) |
#define Exp_1 ((__uint32_t)0x3f800000L) |
#define Exp_11 ((__uint32_t)0x3f800000L) |
#define Ebits 8 |
#define Frac_mask ((__uint32_t)0x007fffffL) |
#define Frac_mask1 ((__uint32_t)0x007fffffL) |
#define Ten_pmax 10 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Ten_pmax 10 |
#define Bletch 2 |
#define Bndry_mask ((__uint32_t)0x007fffffL) |
#define Bndry_mask1 ((__uint32_t)0x007fffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 1 |
#define Tiny0 0 |
#define Tiny1 1 |
#define Quick_max 5 |
#define Int_max 6 |
#define Infinite(x) (word0(x) == ((__uint32_t)0x7f800000L)) |
#undef word0 |
#undef word1 |
#define word0(x) (x.i[0]) |
#define word1(x) 0 |
#else |
#define Exp_shift 20 |
#define Exp_shift1 20 |
#define Exp_msk1 ((__uint32_t)0x100000L) |
#define Exp_msk11 ((__uint32_t)0x100000L) |
#define Exp_mask ((__uint32_t)0x7ff00000L) |
#define P 53 |
#define Bias 1023 |
#define IEEE_Arith |
#define Emin (-1022) |
#define Exp_1 ((__uint32_t)0x3ff00000L) |
#define Exp_11 ((__uint32_t)0x3ff00000L) |
#define Ebits 11 |
#define Frac_mask ((__uint32_t)0xfffffL) |
#define Frac_mask1 ((__uint32_t)0xfffffL) |
#define Ten_pmax 22 |
#define Bletch 0x10 |
#define Bndry_mask ((__uint32_t)0xfffffL) |
#define Bndry_mask1 ((__uint32_t)0xfffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 1 |
#define Tiny0 0 |
#define Tiny1 1 |
#define Quick_max 14 |
#define Int_max 14 |
#define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L)) /* sufficient test for here */ |
#endif |
#else |
#undef Sudden_Underflow |
#define Sudden_Underflow |
#ifdef IBM |
#define Exp_shift 24 |
#define Exp_shift1 24 |
#define Exp_msk1 ((__uint32_t)0x1000000L) |
#define Exp_msk11 ((__uint32_t)0x1000000L) |
#define Exp_mask ((__uint32_t)0x7f000000L) |
#define P 14 |
#define Bias 65 |
#define Exp_1 ((__uint32_t)0x41000000L) |
#define Exp_11 ((__uint32_t)0x41000000L) |
#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ |
#define Frac_mask ((__uint32_t)0xffffffL) |
#define Frac_mask1 ((__uint32_t)0xffffffL) |
#define Bletch 4 |
#define Ten_pmax 22 |
#define Bndry_mask ((__uint32_t)0xefffffL) |
#define Bndry_mask1 ((__uint32_t)0xffffffL) |
#define LSB 1 |
#define Sign_bit ((__uint32_t)0x80000000L) |
#define Log2P 4 |
#define Tiny0 ((__uint32_t)0x100000L) |
#define Tiny1 0 |
#define Quick_max 14 |
#define Int_max 15 |
#else /* VAX */ |
#define Exp_shift 23 |
#define Exp_shift1 7 |
#define Exp_msk1 0x80 |
#define Exp_msk11 ((__uint32_t)0x800000L) |
#define Exp_mask ((__uint32_t)0x7f80L) |
#define P 56 |
#define Bias 129 |
#define Exp_1 ((__uint32_t)0x40800000L) |
#define Exp_11 ((__uint32_t)0x4080L) |
#define Ebits 8 |
#define Frac_mask ((__uint32_t)0x7fffffL) |
#define Frac_mask1 ((__uint32_t)0xffff007fL) |
#define Ten_pmax 24 |
#define Bletch 2 |
#define Bndry_mask ((__uint32_t)0xffff007fL) |
#define Bndry_mask1 ((__uint32_t)0xffff007fL) |
#define LSB ((__uint32_t)0x10000L) |
#define Sign_bit ((__uint32_t)0x8000L) |
#define Log2P 1 |
#define Tiny0 0x80 |
#define Tiny1 0 |
#define Quick_max 15 |
#define Int_max 15 |
#endif |
#endif |
/contrib/sdk/sources/libc/stdio/vfprintf.c |
---|
0,0 → 1,2190 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* Chris Torek. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* must display the following acknowledgement: |
* This product includes software developed by the University of |
* California, Berkeley and its contributors. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
/* |
FUNCTION |
<<vfprintf>>, <<vprintf>>, <<vsprintf>>, <<vsnprintf>>, <<vasprintf>>, <<vasnprintf>>---format argument list |
INDEX |
vfprintf |
INDEX |
_vfprintf_r |
INDEX |
vprintf |
INDEX |
_vprintf_r |
INDEX |
vsprintf |
INDEX |
_vsprintf_r |
INDEX |
vsnprintf |
INDEX |
_vsnprintf_r |
INDEX |
vasprintf |
INDEX |
_vasprintf_r |
INDEX |
vasnprintf |
INDEX |
_vasnprintf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
#include <stdarg.h> |
int vprintf(const char *<[fmt]>, va_list <[list]>); |
int vfprintf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); |
int vsprintf(char *<[str]>, const char *<[fmt]>, va_list <[list]>); |
int vsnprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>, |
va_list <[list]>); |
int vasprintf(char **<[strp]>, const char *<[fmt]>, va_list <[list]>); |
char *vasnprintf(char *<[str]>, size_t *<[size]>, const char *<[fmt]>, |
va_list <[list]>); |
int _vprintf_r(struct _reent *<[reent]>, const char *<[fmt]>, |
va_list <[list]>); |
int _vfprintf_r(struct _reent *<[reent]>, FILE *<[fp]>, |
const char *<[fmt]>, va_list <[list]>); |
int _vsprintf_r(struct _reent *<[reent]>, char *<[str]>, |
const char *<[fmt]>, va_list <[list]>); |
int _vasprintf_r(struct _reent *<[reent]>, char **<[str]>, |
const char *<[fmt]>, va_list <[list]>); |
int _vsnprintf_r(struct _reent *<[reent]>, char *<[str]>, |
size_t <[size]>, const char *<[fmt]>, va_list <[list]>); |
char *_vasnprintf_r(struct _reent *<[reent]>, char *<[str]>, |
size_t *<[size]>, const char *<[fmt]>, va_list <[list]>); |
DESCRIPTION |
<<vprintf>>, <<vfprintf>>, <<vasprintf>>, <<vsprintf>>, <<vsnprintf>>, |
and <<vasnprintf>> are (respectively) variants of <<printf>>, |
<<fprintf>>, <<asprintf>>, <<sprintf>>, <<snprintf>>, and |
<<asnprintf>>. They differ only in allowing their caller to pass the |
variable argument list as a <<va_list>> object (initialized by |
<<va_start>>) rather than directly accepting a variable number of |
arguments. The caller is responsible for calling <<va_end>>. |
<<_vprintf_r>>, <<_vfprintf_r>>, <<_vasprintf_r>>, <<_vsprintf_r>>, |
<<_vsnprintf_r>>, and <<_vasnprintf_r>> are reentrant versions of the |
above. |
RETURNS |
The return values are consistent with the corresponding functions. |
PORTABILITY |
ANSI C requires <<vprintf>>, <<vfprintf>>, <<vsprintf>>, and |
<<vsnprintf>>. The remaining functions are newlib extensions. |
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, |
<<lseek>>, <<read>>, <<sbrk>>, <<write>>. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
/*static char *sccsid = "from: @(#)vfprintf.c 5.50 (Berkeley) 12/16/92";*/ |
static char *rcsid = "$Id: vfprintf.c,v 1.43 2002/08/13 02:40:06 fitzsim Exp $"; |
#endif /* LIBC_SCCS and not lint */ |
/* |
* Actual printf innards. |
* |
* This code is large and complicated... |
*/ |
#include <newlib.h> |
#ifdef INTEGER_ONLY |
# define VFPRINTF vfiprintf |
# ifdef STRING_ONLY |
# define _VFPRINTF_R _svfiprintf_r |
# else |
# define _VFPRINTF_R _vfiprintf_r |
# endif |
#else |
# define VFPRINTF vfprintf |
# ifdef STRING_ONLY |
# define _VFPRINTF_R _svfprintf_r |
# else |
# define _VFPRINTF_R _vfprintf_r |
# endif |
# ifndef NO_FLOATING_POINT |
# define FLOATING_POINT |
# endif |
#endif |
#define _NO_POS_ARGS |
#ifdef _WANT_IO_POS_ARGS |
# undef _NO_POS_ARGS |
#endif |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <limits.h> |
#include <stdint.h> |
#include <wchar.h> |
#include <sys/lock.h> |
#include <stdarg.h> |
#include "local.h" |
#include "../stdlib/local.h" |
#include "fvwrite.h" |
#include "vfieeefp.h" |
/* Currently a test is made to see if long double processing is warranted. |
This could be changed in the future should the _ldtoa_r code be |
preferred over _dtoa_r. */ |
#define _NO_LONGDBL |
#if defined _WANT_IO_LONG_DOUBLE && (LDBL_MANT_DIG > DBL_MANT_DIG) |
#undef _NO_LONGDBL |
#endif |
#define _NO_LONGLONG |
#if defined _WANT_IO_LONG_LONG \ |
&& (defined __GNUC__ || __STDC_VERSION__ >= 199901L) |
# undef _NO_LONGLONG |
#endif |
#ifdef STRING_ONLY |
#define __SPRINT __ssprint_r |
#else |
#define __SPRINT __sprint_r |
#endif |
/* The __sprint_r/__ssprint_r functions are shared between all versions of |
vfprintf and vfwprintf. They must only be defined once, which we do in |
the INTEGER_ONLY versions here. */ |
#ifdef STRING_ONLY |
#ifdef INTEGER_ONLY |
int |
_DEFUN(__ssprint_r, (ptr, fp, uio), |
struct _reent *ptr _AND |
FILE *fp _AND |
register struct __suio *uio) |
{ |
register size_t len; |
register int w; |
register struct __siov *iov; |
register _CONST char *p = NULL; |
iov = uio->uio_iov; |
len = 0; |
if (uio->uio_resid == 0) { |
uio->uio_iovcnt = 0; |
return (0); |
} |
do { |
while (len == 0) { |
p = iov->iov_base; |
len = iov->iov_len; |
iov++; |
} |
w = fp->_w; |
if (len >= w && fp->_flags & (__SMBF | __SOPT)) { |
/* must be asprintf family */ |
unsigned char *str; |
int curpos = (fp->_p - fp->_bf._base); |
/* Choose a geometric growth factor to avoid |
* quadratic realloc behavior, but use a rate less |
* than (1+sqrt(5))/2 to accomodate malloc |
* overhead. asprintf EXPECTS us to overallocate, so |
* that it can add a trailing \0 without |
* reallocating. The new allocation should thus be |
* max(prev_size*1.5, curpos+len+1). */ |
int newsize = fp->_bf._size * 3 / 2; |
if (newsize < curpos + len + 1) |
newsize = curpos + len + 1; |
if (fp->_flags & __SOPT) |
{ |
/* asnprintf leaves original buffer alone. */ |
str = (unsigned char *)_malloc_r (ptr, newsize); |
if (!str) |
{ |
ptr->_errno = ENOMEM; |
goto err; |
} |
memcpy (str, fp->_bf._base, curpos); |
fp->_flags = (fp->_flags & ~__SOPT) | __SMBF; |
} |
else |
{ |
str = (unsigned char *)_realloc_r (ptr, fp->_bf._base, |
newsize); |
if (!str) { |
/* Free unneeded buffer. */ |
_free_r (ptr, fp->_bf._base); |
/* Ensure correct errno, even if free |
* changed it. */ |
ptr->_errno = ENOMEM; |
goto err; |
} |
} |
fp->_bf._base = str; |
fp->_p = str + curpos; |
fp->_bf._size = newsize; |
w = len; |
fp->_w = newsize - curpos; |
} |
if (len < w) |
w = len; |
(void)memmove ((_PTR) fp->_p, (_PTR) p, (size_t) (w)); |
fp->_w -= w; |
fp->_p += w; |
w = len; /* pretend we copied all */ |
p += w; |
len -= w; |
} while ((uio->uio_resid -= w) != 0); |
uio->uio_resid = 0; |
uio->uio_iovcnt = 0; |
return 0; |
err: |
fp->_flags |= __SERR; |
uio->uio_resid = 0; |
uio->uio_iovcnt = 0; |
return EOF; |
} |
#else /* !INTEGER_ONLY */ |
int __ssprint_r (struct _reent *, FILE *, register struct __suio *); |
#endif /* !INTEGER_ONLY */ |
#else /* !STRING_ONLY */ |
#ifdef INTEGER_ONLY |
/* |
* Flush out all the vectors defined by the given uio, |
* then reset it so that it can be reused. |
*/ |
int |
_DEFUN(__sprint_r, (ptr, fp, uio), |
struct _reent *ptr _AND |
FILE *fp _AND |
register struct __suio *uio) |
{ |
register int err = 0; |
if (uio->uio_resid == 0) { |
uio->uio_iovcnt = 0; |
return (0); |
} |
if (fp->_flags2 & __SWID) { |
struct __siov *iov; |
wchar_t *p; |
int i, len; |
iov = uio->uio_iov; |
for (; uio->uio_resid != 0; |
uio->uio_resid -= len * sizeof (wchar_t), iov++) { |
p = (wchar_t *) iov->iov_base; |
len = iov->iov_len / sizeof (wchar_t); |
for (i = 0; i < len; i++) { |
if (_fputwc_r (ptr, p[i], fp) == WEOF) { |
err = -1; |
goto out; |
} |
} |
} |
} else |
err = __sfvwrite_r(ptr, fp, uio); |
out: |
uio->uio_resid = 0; |
uio->uio_iovcnt = 0; |
return (err); |
} |
#else /* !INTEGER_ONLY */ |
int __sprint_r (struct _reent *, FILE *, register struct __suio *); |
#endif /* !INTEGER_ONLY */ |
/* |
* Helper function for `fprintf to unbuffered unix file': creates a |
* temporary buffer. We only work on write-only files; this avoids |
* worries about ungetc buffers and so forth. |
*/ |
static int |
_DEFUN(__sbprintf, (rptr, fp, fmt, ap), |
struct _reent *rptr _AND |
register FILE *fp _AND |
_CONST char *fmt _AND |
va_list ap) |
{ |
int ret; |
FILE fake; |
unsigned char buf[BUFSIZ]; |
/* copy the important variables */ |
fake._flags = fp->_flags & ~__SNBF; |
fake._flags2 = fp->_flags2; |
fake._file = fp->_file; |
fake._cookie = fp->_cookie; |
fake._write = fp->_write; |
/* set up the buffer */ |
fake._bf._base = fake._p = buf; |
fake._bf._size = fake._w = sizeof (buf); |
fake._lbfsize = 0; /* not actually used, but Just In Case */ |
#ifndef __SINGLE_THREAD__ |
__lock_init_recursive (fake._lock); |
#endif |
/* do the work, then copy any error status */ |
ret = _VFPRINTF_R (rptr, &fake, fmt, ap); |
if (ret >= 0 && _fflush_r (rptr, &fake)) |
ret = EOF; |
if (fake._flags & __SERR) |
fp->_flags |= __SERR; |
#ifndef __SINGLE_THREAD__ |
__lock_close_recursive (fake._lock); |
#endif |
return (ret); |
} |
#endif /* !STRING_ONLY */ |
#if defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS) |
# include <locale.h> |
#endif |
#ifdef FLOATING_POINT |
# include <math.h> |
/* For %La, an exponent of 15 bits occupies the exponent character, a |
sign, and up to 5 digits. */ |
# define MAXEXPLEN 7 |
# define DEFPREC 6 |
# ifdef _NO_LONGDBL |
extern char *_dtoa_r _PARAMS((struct _reent *, double, int, |
int, int *, int *, char **)); |
# define _PRINTF_FLOAT_TYPE double |
# define _DTOA_R _dtoa_r |
# define FREXP frexp |
# else /* !_NO_LONGDBL */ |
extern char *_ldtoa_r _PARAMS((struct _reent *, _LONG_DOUBLE, int, |
int, int *, int *, char **)); |
extern int _EXFUN(_ldcheck,(_LONG_DOUBLE *)); |
# define _PRINTF_FLOAT_TYPE _LONG_DOUBLE |
# define _DTOA_R _ldtoa_r |
/* FIXME - frexpl is not yet supported; and cvt infloops if (double)f |
converts a finite value into infinity. */ |
/* # define FREXP frexpl */ |
# define FREXP(f,e) ((_LONG_DOUBLE) frexp ((double)f, e)) |
# endif /* !_NO_LONGDBL */ |
static char *cvt(struct _reent *, _PRINTF_FLOAT_TYPE, int, int, char *, int *, |
int, int *, char *); |
static int exponent(char *, int, int); |
#endif /* FLOATING_POINT */ |
/* BUF must be big enough for the maximum %#llo (assuming long long is |
at most 64 bits, this would be 23 characters), the maximum |
multibyte character %C, and the maximum default precision of %La |
(assuming long double is at most 128 bits with 113 bits of |
mantissa, this would be 29 characters). %e, %f, and %g use |
reentrant storage shared with mprec. All other formats that use |
buf get by with fewer characters. Making BUF slightly bigger |
reduces the need for malloc in %.*a and %S, when large precision or |
long strings are processed. |
The bigger size of 100 bytes is used on systems which allow number |
strings using the locale's grouping character. Since that's a multibyte |
value, we should use a conservative value. |
*/ |
#ifdef _WANT_IO_C99_FORMATS |
#define BUF 100 |
#else |
#define BUF 40 |
#endif |
#if defined _MB_CAPABLE && MB_LEN_MAX > BUF |
# undef BUF |
# define BUF MB_LEN_MAX |
#endif |
#ifndef _NO_LONGLONG |
# define quad_t long long |
# define u_quad_t unsigned long long |
#else |
# define quad_t long |
# define u_quad_t unsigned long |
#endif |
typedef quad_t * quad_ptr_t; |
typedef _PTR void_ptr_t; |
typedef char * char_ptr_t; |
typedef long * long_ptr_t; |
typedef int * int_ptr_t; |
typedef short * short_ptr_t; |
#ifndef _NO_POS_ARGS |
# ifdef NL_ARGMAX |
# define MAX_POS_ARGS NL_ARGMAX |
# else |
# define MAX_POS_ARGS 32 |
# endif |
union arg_val |
{ |
int val_int; |
u_int val_u_int; |
long val_long; |
u_long val_u_long; |
float val_float; |
double val_double; |
_LONG_DOUBLE val__LONG_DOUBLE; |
int_ptr_t val_int_ptr_t; |
short_ptr_t val_short_ptr_t; |
long_ptr_t val_long_ptr_t; |
char_ptr_t val_char_ptr_t; |
quad_ptr_t val_quad_ptr_t; |
void_ptr_t val_void_ptr_t; |
quad_t val_quad_t; |
u_quad_t val_u_quad_t; |
wint_t val_wint_t; |
}; |
static union arg_val * |
_EXFUN(get_arg, (struct _reent *data, int n, char *fmt, |
va_list *ap, int *numargs, union arg_val *args, |
int *arg_type, char **last_fmt)); |
#endif /* !_NO_POS_ARGS */ |
/* |
* Macros for converting digits to letters and vice versa |
*/ |
#define to_digit(c) ((c) - '0') |
#define is_digit(c) ((unsigned)to_digit (c) <= 9) |
#define to_char(n) ((n) + '0') |
/* |
* Flags used during conversion. |
*/ |
#define ALT 0x001 /* alternate form */ |
#define HEXPREFIX 0x002 /* add 0x or 0X prefix */ |
#define LADJUST 0x004 /* left adjustment */ |
#define LONGDBL 0x008 /* long double */ |
#define LONGINT 0x010 /* long integer */ |
#ifndef _NO_LONGLONG |
# define QUADINT 0x020 /* quad integer */ |
#else /* ifdef _NO_LONGLONG, make QUADINT equivalent to LONGINT, so |
that %lld behaves the same as %ld, not as %d, as expected if: |
sizeof (long long) = sizeof long > sizeof int */ |
# define QUADINT LONGINT |
#endif |
#define SHORTINT 0x040 /* short integer */ |
#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */ |
#define FPT 0x100 /* Floating point number */ |
#ifdef _WANT_IO_C99_FORMATS |
# define CHARINT 0x200 /* char as integer */ |
#else /* define as 0, to make SARG and UARG occupy fewer instructions */ |
# define CHARINT 0 |
#endif |
#ifdef _WANT_IO_C99_FORMATS |
# define GROUPING 0x400 /* use grouping ("'" flag) */ |
#endif |
int _EXFUN(_VFPRINTF_R, (struct _reent *, FILE *, _CONST char *, va_list)); |
#ifndef STRING_ONLY |
int |
_DEFUN(VFPRINTF, (fp, fmt0, ap), |
FILE * fp _AND |
_CONST char *fmt0 _AND |
va_list ap) |
{ |
int result; |
result = _VFPRINTF_R (_REENT, fp, fmt0, ap); |
return result; |
} |
#endif /* STRING_ONLY */ |
int |
_DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap), |
struct _reent *data _AND |
FILE * fp _AND |
_CONST char *fmt0 _AND |
va_list ap) |
{ |
register char *fmt; /* format string */ |
register int ch; /* character from fmt */ |
register int n, m; /* handy integers (short term usage) */ |
register char *cp; /* handy char pointer (short term usage) */ |
register struct __siov *iovp;/* for PRINT macro */ |
register int flags; /* flags as above */ |
char *fmt_anchor; /* current format spec being processed */ |
#ifndef _NO_POS_ARGS |
int N; /* arg number */ |
int arg_index; /* index into args processed directly */ |
int numargs; /* number of varargs read */ |
char *saved_fmt; /* saved fmt pointer */ |
union arg_val args[MAX_POS_ARGS]; |
int arg_type[MAX_POS_ARGS]; |
int is_pos_arg; /* is current format positional? */ |
int old_is_pos_arg; /* is current format positional? */ |
#endif |
int ret; /* return value accumulator */ |
int width; /* width from format (%8d), or 0 */ |
int prec; /* precision from format (%.3d), or -1 */ |
char sign; /* sign prefix (' ', '+', '-', or \0) */ |
#ifdef _WANT_IO_C99_FORMATS |
/* locale specific numeric grouping */ |
char *thousands_sep; |
size_t thsnd_len; |
const char *grouping; |
#endif |
#ifdef FLOATING_POINT |
char *decimal_point = _localeconv_r (data)->decimal_point; |
size_t decp_len = strlen (decimal_point); |
char softsign; /* temporary negative sign for floats */ |
union { int i; _PRINTF_FLOAT_TYPE fp; } _double_ = {0}; |
# define _fpvalue (_double_.fp) |
int expt; /* integer value of exponent */ |
int expsize = 0; /* character count for expstr */ |
char expstr[MAXEXPLEN]; /* buffer for exponent string */ |
int lead; /* sig figs before decimal or group sep */ |
#endif /* FLOATING_POINT */ |
#if defined (FLOATING_POINT) || defined (_WANT_IO_C99_FORMATS) |
int ndig = 0; /* actual number of digits returned by cvt */ |
#endif |
#ifdef _WANT_IO_C99_FORMATS |
int nseps; /* number of group separators with ' */ |
int nrepeats; /* number of repeats of the last group */ |
#endif |
u_quad_t _uquad; /* integer arguments %[diouxX] */ |
enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */ |
int dprec; /* a copy of prec if [diouxX], 0 otherwise */ |
int realsz; /* field size expanded by dprec */ |
int size; /* size of converted field or string */ |
char *xdigs = NULL; /* digits for [xX] conversion */ |
#define NIOV 8 |
struct __suio uio; /* output information: summary */ |
struct __siov iov[NIOV];/* ... and individual io vectors */ |
char buf[BUF]; /* space for %c, %S, %[diouxX], %[aA] */ |
char ox[2]; /* space for 0x hex-prefix */ |
#ifdef _MB_CAPABLE |
wchar_t wc; |
mbstate_t state; /* mbtowc calls from library must not change state */ |
#endif |
char *malloc_buf = NULL;/* handy pointer for malloced buffers */ |
/* |
* Choose PADSIZE to trade efficiency vs. size. If larger printf |
* fields occur frequently, increase PADSIZE and make the initialisers |
* below longer. |
*/ |
#define PADSIZE 16 /* pad chunk size */ |
static _CONST char blanks[PADSIZE] = |
{' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}; |
static _CONST char zeroes[PADSIZE] = |
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; |
#ifdef _MB_CAPABLE |
memset (&state, '\0', sizeof (state)); |
#endif |
/* |
* BEWARE, these `goto error' on error, and PAD uses `n'. |
*/ |
#define PRINT(ptr, len) { \ |
iovp->iov_base = (ptr); \ |
iovp->iov_len = (len); \ |
uio.uio_resid += (len); \ |
iovp++; \ |
if (++uio.uio_iovcnt >= NIOV) { \ |
if (__SPRINT(data, fp, &uio)) \ |
goto error; \ |
iovp = iov; \ |
} \ |
} |
#define PAD(howmany, with) { \ |
if ((n = (howmany)) > 0) { \ |
while (n > PADSIZE) { \ |
PRINT (with, PADSIZE); \ |
n -= PADSIZE; \ |
} \ |
PRINT (with, n); \ |
} \ |
} |
#define PRINTANDPAD(p, ep, len, with) { \ |
int n = (ep) - (p); \ |
if (n > (len)) \ |
n = (len); \ |
if (n > 0) \ |
PRINT((p), n); \ |
PAD((len) - (n > 0 ? n : 0), (with)); \ |
} |
#define FLUSH() { \ |
if (uio.uio_resid && __SPRINT(data, fp, &uio)) \ |
goto error; \ |
uio.uio_iovcnt = 0; \ |
iovp = iov; \ |
} |
/* Macros to support positional arguments */ |
#ifndef _NO_POS_ARGS |
# define GET_ARG(n, ap, type) \ |
(is_pos_arg \ |
? (n < numargs \ |
? args[n].val_##type \ |
: get_arg (data, n, fmt_anchor, &ap, &numargs, args, \ |
arg_type, &saved_fmt)->val_##type) \ |
: (arg_index++ < numargs \ |
? args[n].val_##type \ |
: (numargs < MAX_POS_ARGS \ |
? args[numargs++].val_##type = va_arg (ap, type) \ |
: va_arg (ap, type)))) |
#else |
# define GET_ARG(n, ap, type) (va_arg (ap, type)) |
#endif |
/* |
* To extend shorts properly, we need both signed and unsigned |
* argument extraction methods. |
*/ |
#ifndef _NO_LONGLONG |
#define SARG() \ |
(flags&QUADINT ? GET_ARG (N, ap, quad_t) : \ |
flags&LONGINT ? GET_ARG (N, ap, long) : \ |
flags&SHORTINT ? (long)(short)GET_ARG (N, ap, int) : \ |
flags&CHARINT ? (long)(signed char)GET_ARG (N, ap, int) : \ |
(long)GET_ARG (N, ap, int)) |
#define UARG() \ |
(flags&QUADINT ? GET_ARG (N, ap, u_quad_t) : \ |
flags&LONGINT ? GET_ARG (N, ap, u_long) : \ |
flags&SHORTINT ? (u_long)(u_short)GET_ARG (N, ap, int) : \ |
flags&CHARINT ? (u_long)(unsigned char)GET_ARG (N, ap, int) : \ |
(u_long)GET_ARG (N, ap, u_int)) |
#else |
#define SARG() \ |
(flags&LONGINT ? GET_ARG (N, ap, long) : \ |
flags&SHORTINT ? (long)(short)GET_ARG (N, ap, int) : \ |
flags&CHARINT ? (long)(signed char)GET_ARG (N, ap, int) : \ |
(long)GET_ARG (N, ap, int)) |
#define UARG() \ |
(flags&LONGINT ? GET_ARG (N, ap, u_long) : \ |
flags&SHORTINT ? (u_long)(u_short)GET_ARG (N, ap, int) : \ |
flags&CHARINT ? (u_long)(unsigned char)GET_ARG (N, ap, int) : \ |
(u_long)GET_ARG (N, ap, u_int)) |
#endif |
#ifndef STRING_ONLY |
/* Initialize std streams if not dealing with sprintf family. */ |
CHECK_INIT (data, fp); |
_flockfile (fp); |
ORIENT(fp, -1); |
/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ |
if (cantwrite (data, fp)) { |
_funlockfile (fp); |
return (EOF); |
} |
/* optimise fprintf(stderr) (and other unbuffered Unix files) */ |
if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && |
fp->_file >= 0) { |
_funlockfile (fp); |
return (__sbprintf (data, fp, fmt0, ap)); |
} |
#else /* STRING_ONLY */ |
/* Create initial buffer if we are called by asprintf family. */ |
if (fp->_flags & __SMBF && !fp->_bf._base) |
{ |
fp->_bf._base = fp->_p = _malloc_r (data, 64); |
if (!fp->_p) |
{ |
data->_errno = ENOMEM; |
return EOF; |
} |
fp->_bf._size = 64; |
} |
#endif /* STRING_ONLY */ |
fmt = (char *)fmt0; |
uio.uio_iov = iovp = iov; |
uio.uio_resid = 0; |
uio.uio_iovcnt = 0; |
ret = 0; |
#ifndef _NO_POS_ARGS |
arg_index = 0; |
saved_fmt = NULL; |
arg_type[0] = -1; |
numargs = 0; |
is_pos_arg = 0; |
#endif |
/* |
* Scan the format for conversions (`%' character). |
*/ |
for (;;) { |
cp = fmt; |
#ifdef _MB_CAPABLE |
while ((n = __mbtowc (data, &wc, fmt, MB_CUR_MAX, |
__locale_charset (), &state)) != 0) { |
if (n < 0) { |
/* Wave invalid chars through. */ |
memset (&state, 0, sizeof state); |
n = 1; |
} |
else if (wc == '%') |
break; |
fmt += n; |
} |
#else |
while (*fmt != '\0' && *fmt != '%') |
fmt += 1; |
#endif |
if ((m = fmt - cp) != 0) { |
PRINT (cp, m); |
ret += m; |
} |
#ifdef _MB_CAPABLE |
if (n <= 0) |
goto done; |
#else |
if (*fmt == '\0') |
goto done; |
#endif |
fmt_anchor = fmt; |
fmt++; /* skip over '%' */ |
flags = 0; |
dprec = 0; |
width = 0; |
prec = -1; |
sign = '\0'; |
#ifdef FLOATING_POINT |
lead = 0; |
#endif |
#ifdef _WANT_IO_C99_FORMATS |
nseps = nrepeats = 0; |
#endif |
#ifndef _NO_POS_ARGS |
N = arg_index; |
is_pos_arg = 0; |
#endif |
rflag: ch = *fmt++; |
reswitch: switch (ch) { |
#ifdef _WANT_IO_C99_FORMATS |
case '\'': |
thousands_sep = _localeconv_r (data)->thousands_sep; |
thsnd_len = strlen (thousands_sep); |
grouping = _localeconv_r (data)->grouping; |
if (thsnd_len > 0 && grouping && *grouping) |
flags |= GROUPING; |
goto rflag; |
#endif |
case ' ': |
/* |
* ``If the space and + flags both appear, the space |
* flag will be ignored.'' |
* -- ANSI X3J11 |
*/ |
if (!sign) |
sign = ' '; |
goto rflag; |
case '#': |
flags |= ALT; |
goto rflag; |
case '*': |
#ifndef _NO_POS_ARGS |
/* we must check for positional arg used for dynamic width */ |
n = N; |
old_is_pos_arg = is_pos_arg; |
is_pos_arg = 0; |
if (is_digit (*fmt)) { |
char *old_fmt = fmt; |
n = 0; |
ch = *fmt++; |
do { |
n = 10 * n + to_digit (ch); |
ch = *fmt++; |
} while (is_digit (ch)); |
if (ch == '$') { |
if (n <= MAX_POS_ARGS) { |
n -= 1; |
is_pos_arg = 1; |
} |
else |
goto error; |
} |
else { |
fmt = old_fmt; |
goto rflag; |
} |
} |
#endif /* !_NO_POS_ARGS */ |
/* |
* ``A negative field width argument is taken as a |
* - flag followed by a positive field width.'' |
* -- ANSI X3J11 |
* They don't exclude field widths read from args. |
*/ |
width = GET_ARG (n, ap, int); |
#ifndef _NO_POS_ARGS |
is_pos_arg = old_is_pos_arg; |
#endif |
if (width >= 0) |
goto rflag; |
width = -width; |
/* FALLTHROUGH */ |
case '-': |
flags |= LADJUST; |
goto rflag; |
case '+': |
sign = '+'; |
goto rflag; |
case '.': |
if ((ch = *fmt++) == '*') { |
#ifndef _NO_POS_ARGS |
/* we must check for positional arg used for dynamic width */ |
n = N; |
old_is_pos_arg = is_pos_arg; |
is_pos_arg = 0; |
if (is_digit (*fmt)) { |
char *old_fmt = fmt; |
n = 0; |
ch = *fmt++; |
do { |
n = 10 * n + to_digit (ch); |
ch = *fmt++; |
} while (is_digit (ch)); |
if (ch == '$') { |
if (n <= MAX_POS_ARGS) { |
n -= 1; |
is_pos_arg = 1; |
} |
else |
goto error; |
} |
else { |
fmt = old_fmt; |
goto rflag; |
} |
} |
#endif /* !_NO_POS_ARGS */ |
prec = GET_ARG (n, ap, int); |
#ifndef _NO_POS_ARGS |
is_pos_arg = old_is_pos_arg; |
#endif |
if (prec < 0) |
prec = -1; |
goto rflag; |
} |
n = 0; |
while (is_digit (ch)) { |
n = 10 * n + to_digit (ch); |
ch = *fmt++; |
} |
prec = n < 0 ? -1 : n; |
goto reswitch; |
case '0': |
/* |
* ``Note that 0 is taken as a flag, not as the |
* beginning of a field width.'' |
* -- ANSI X3J11 |
*/ |
flags |= ZEROPAD; |
goto rflag; |
case '1': case '2': case '3': case '4': |
case '5': case '6': case '7': case '8': case '9': |
n = 0; |
do { |
n = 10 * n + to_digit (ch); |
ch = *fmt++; |
} while (is_digit (ch)); |
#ifndef _NO_POS_ARGS |
if (ch == '$') { |
if (n <= MAX_POS_ARGS) { |
N = n - 1; |
is_pos_arg = 1; |
goto rflag; |
} |
else |
goto error; |
} |
#endif /* !_NO_POS_ARGS */ |
width = n; |
goto reswitch; |
#ifdef FLOATING_POINT |
case 'L': |
flags |= LONGDBL; |
goto rflag; |
#endif |
case 'h': |
#ifdef _WANT_IO_C99_FORMATS |
if (*fmt == 'h') { |
fmt++; |
flags |= CHARINT; |
} else |
#endif |
flags |= SHORTINT; |
goto rflag; |
case 'l': |
#if defined _WANT_IO_C99_FORMATS || !defined _NO_LONGLONG |
if (*fmt == 'l') { |
fmt++; |
flags |= QUADINT; |
} else |
#endif |
flags |= LONGINT; |
goto rflag; |
case 'q': /* extension */ |
flags |= QUADINT; |
goto rflag; |
#ifdef _WANT_IO_C99_FORMATS |
case 'j': |
if (sizeof (intmax_t) == sizeof (long)) |
flags |= LONGINT; |
else |
flags |= QUADINT; |
goto rflag; |
case 'z': |
if (sizeof (size_t) < sizeof (int)) |
/* POSIX states size_t is 16 or more bits, as is short. */ |
flags |= SHORTINT; |
else if (sizeof (size_t) == sizeof (int)) |
/* no flag needed */; |
else if (sizeof (size_t) <= sizeof (long)) |
flags |= LONGINT; |
else |
/* POSIX states that at least one programming |
environment must support size_t no wider than |
long, but that means other environments can |
have size_t as wide as long long. */ |
flags |= QUADINT; |
goto rflag; |
case 't': |
if (sizeof (ptrdiff_t) < sizeof (int)) |
/* POSIX states ptrdiff_t is 16 or more bits, as |
is short. */ |
flags |= SHORTINT; |
else if (sizeof (ptrdiff_t) == sizeof (int)) |
/* no flag needed */; |
else if (sizeof (ptrdiff_t) <= sizeof (long)) |
flags |= LONGINT; |
else |
/* POSIX states that at least one programming |
environment must support ptrdiff_t no wider than |
long, but that means other environments can |
have ptrdiff_t as wide as long long. */ |
flags |= QUADINT; |
goto rflag; |
case 'C': |
#endif /* _WANT_IO_C99_FORMATS */ |
case 'c': |
cp = buf; |
#ifdef _MB_CAPABLE |
if (ch == 'C' || (flags & LONGINT)) { |
mbstate_t ps; |
memset ((_PTR)&ps, '\0', sizeof (mbstate_t)); |
if ((size = (int)_wcrtomb_r (data, cp, |
(wchar_t)GET_ARG (N, ap, wint_t), |
&ps)) == -1) { |
fp->_flags |= __SERR; |
goto error; |
} |
} |
else |
#endif /* _MB_CAPABLE */ |
{ |
*cp = GET_ARG (N, ap, int); |
size = 1; |
} |
sign = '\0'; |
break; |
case 'D': /* extension */ |
flags |= LONGINT; |
/*FALLTHROUGH*/ |
case 'd': |
case 'i': |
_uquad = SARG (); |
#ifndef _NO_LONGLONG |
if ((quad_t)_uquad < 0) |
#else |
if ((long) _uquad < 0) |
#endif |
{ |
_uquad = -_uquad; |
sign = '-'; |
} |
base = DEC; |
goto number; |
#ifdef FLOATING_POINT |
# ifdef _WANT_IO_C99_FORMATS |
case 'a': |
case 'A': |
case 'F': |
# endif |
case 'e': |
case 'E': |
case 'f': |
case 'g': |
case 'G': |
# ifdef _NO_LONGDBL |
if (flags & LONGDBL) { |
_fpvalue = (double) GET_ARG (N, ap, _LONG_DOUBLE); |
} else { |
_fpvalue = GET_ARG (N, ap, double); |
} |
/* do this before tricky precision changes |
If the output is infinite or NaN, leading |
zeros are not permitted. Otherwise, scanf |
could not read what printf wrote. |
*/ |
if (isinf (_fpvalue)) { |
if (_fpvalue < 0) |
sign = '-'; |
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */ |
cp = "INF"; |
else |
cp = "inf"; |
size = 3; |
flags &= ~ZEROPAD; |
break; |
} |
if (isnan (_fpvalue)) { |
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */ |
cp = "NAN"; |
else |
cp = "nan"; |
size = 3; |
flags &= ~ZEROPAD; |
break; |
} |
# else /* !_NO_LONGDBL */ |
if (flags & LONGDBL) { |
_fpvalue = GET_ARG (N, ap, _LONG_DOUBLE); |
} else { |
_fpvalue = (_LONG_DOUBLE)GET_ARG (N, ap, double); |
} |
/* do this before tricky precision changes */ |
expt = _ldcheck (&_fpvalue); |
if (expt == 2) { |
if (_fpvalue < 0) |
sign = '-'; |
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */ |
cp = "INF"; |
else |
cp = "inf"; |
size = 3; |
flags &= ~ZEROPAD; |
break; |
} |
if (expt == 1) { |
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */ |
cp = "NAN"; |
else |
cp = "nan"; |
size = 3; |
flags &= ~ZEROPAD; |
break; |
} |
# endif /* !_NO_LONGDBL */ |
# ifdef _WANT_IO_C99_FORMATS |
if (ch == 'a' || ch == 'A') { |
ox[0] = '0'; |
ox[1] = ch == 'a' ? 'x' : 'X'; |
flags |= HEXPREFIX; |
if (prec >= BUF) |
{ |
if ((malloc_buf = |
(char *)_malloc_r (data, prec + 1)) |
== NULL) |
{ |
fp->_flags |= __SERR; |
goto error; |
} |
cp = malloc_buf; |
} |
else |
cp = buf; |
} else |
# endif /* _WANT_IO_C99_FORMATS */ |
if (prec == -1) { |
prec = DEFPREC; |
} else if ((ch == 'g' || ch == 'G') && prec == 0) { |
prec = 1; |
} |
flags |= FPT; |
cp = cvt (data, _fpvalue, prec, flags, &softsign, |
&expt, ch, &ndig, cp); |
if (ch == 'g' || ch == 'G') { |
if (expt <= -4 || expt > prec) |
ch -= 2; /* 'e' or 'E' */ |
else |
ch = 'g'; |
} |
# ifdef _WANT_IO_C99_FORMATS |
else if (ch == 'F') |
ch = 'f'; |
# endif |
if (ch <= 'e') { /* 'a', 'A', 'e', or 'E' fmt */ |
--expt; |
expsize = exponent (expstr, expt, ch); |
size = expsize + ndig; |
if (ndig > 1 || flags & ALT) |
++size; |
# ifdef _WANT_IO_C99_FORMATS |
flags &= ~GROUPING; |
# endif |
} else { |
if (ch == 'f') { /* f fmt */ |
if (expt > 0) { |
size = expt; |
if (prec || flags & ALT) |
size += prec + 1; |
} else /* "0.X" */ |
size = (prec || flags & ALT) |
? prec + 2 |
: 1; |
} else if (expt >= ndig) { /* fixed g fmt */ |
size = expt; |
if (flags & ALT) |
++size; |
} else |
size = ndig + (expt > 0 ? |
1 : 2 - expt); |
# ifdef _WANT_IO_C99_FORMATS |
if ((flags & GROUPING) && expt > 0) { |
/* space for thousands' grouping */ |
nseps = nrepeats = 0; |
lead = expt; |
while (*grouping != CHAR_MAX) { |
if (lead <= *grouping) |
break; |
lead -= *grouping; |
if (grouping[1]) { |
nseps++; |
grouping++; |
} else |
nrepeats++; |
} |
size += (nseps + nrepeats) * thsnd_len; |
} else |
# endif |
lead = expt; |
} |
if (softsign) |
sign = '-'; |
break; |
#endif /* FLOATING_POINT */ |
case 'n': |
#ifndef _NO_LONGLONG |
if (flags & QUADINT) |
*GET_ARG (N, ap, quad_ptr_t) = ret; |
else |
#endif |
if (flags & LONGINT) |
*GET_ARG (N, ap, long_ptr_t) = ret; |
else if (flags & SHORTINT) |
*GET_ARG (N, ap, short_ptr_t) = ret; |
#ifdef _WANT_IO_C99_FORMATS |
else if (flags & CHARINT) |
*GET_ARG (N, ap, char_ptr_t) = ret; |
#endif |
else |
*GET_ARG (N, ap, int_ptr_t) = ret; |
continue; /* no output */ |
case 'O': /* extension */ |
flags |= LONGINT; |
/*FALLTHROUGH*/ |
case 'o': |
_uquad = UARG (); |
base = OCT; |
#ifdef _WANT_IO_C99_FORMATS |
flags &= ~GROUPING; |
#endif |
goto nosign; |
case 'p': |
/* |
* ``The argument shall be a pointer to void. The |
* value of the pointer is converted to a sequence |
* of printable characters, in an implementation- |
* defined manner.'' |
* -- ANSI X3J11 |
*/ |
/* NOSTRICT */ |
_uquad = (uintptr_t) GET_ARG (N, ap, void_ptr_t); |
base = HEX; |
xdigs = "0123456789abcdef"; |
flags |= HEXPREFIX; |
ox[0] = '0'; |
ox[1] = ch = 'x'; |
goto nosign; |
case 's': |
#ifdef _WANT_IO_C99_FORMATS |
case 'S': |
#endif |
sign = '\0'; |
cp = GET_ARG (N, ap, char_ptr_t); |
#ifndef __OPTIMIZE_SIZE__ |
/* Behavior is undefined if the user passed a |
NULL string when precision is not 0. |
However, if we are not optimizing for size, |
we might as well mirror glibc behavior. */ |
if (cp == NULL) { |
cp = "(null)"; |
size = ((unsigned) prec > 6U) ? 6 : prec; |
} |
else |
#endif /* __OPTIMIZE_SIZE__ */ |
#ifdef _MB_CAPABLE |
if (ch == 'S' || (flags & LONGINT)) { |
mbstate_t ps; |
_CONST wchar_t *wcp; |
wcp = (_CONST wchar_t *)cp; |
size = m = 0; |
memset ((_PTR)&ps, '\0', sizeof (mbstate_t)); |
/* Count number of bytes needed for multibyte |
string that will be produced from widechar |
string. */ |
if (prec >= 0) { |
while (1) { |
if (wcp[m] == L'\0') |
break; |
if ((n = (int)_wcrtomb_r (data, |
buf, wcp[m], &ps)) == -1) { |
fp->_flags |= __SERR; |
goto error; |
} |
if (n + size > prec) |
break; |
m += 1; |
size += n; |
if (size == prec) |
break; |
} |
} |
else { |
if ((size = (int)_wcsrtombs_r (data, |
NULL, &wcp, 0, &ps)) == -1) { |
fp->_flags |= __SERR; |
goto error; |
} |
wcp = (_CONST wchar_t *)cp; |
} |
if (size == 0) |
break; |
if (size >= BUF) { |
if ((malloc_buf = |
(char *)_malloc_r (data, size + 1)) |
== NULL) { |
fp->_flags |= __SERR; |
goto error; |
} |
cp = malloc_buf; |
} else |
cp = buf; |
/* Convert widechar string to multibyte string. */ |
memset ((_PTR)&ps, '\0', sizeof (mbstate_t)); |
if (_wcsrtombs_r (data, cp, &wcp, size, &ps) |
!= size) { |
fp->_flags |= __SERR; |
goto error; |
} |
cp[size] = '\0'; |
} |
else |
#endif /* _MB_CAPABLE */ |
if (prec >= 0) { |
/* |
* can't use strlen; can only look for the |
* NUL in the first `prec' characters, and |
* strlen () will go further. |
*/ |
char *p = memchr (cp, 0, prec); |
if (p != NULL) { |
size = p - cp; |
if (size > prec) |
size = prec; |
} else |
size = prec; |
} else |
size = strlen (cp); |
break; |
case 'U': /* extension */ |
flags |= LONGINT; |
/*FALLTHROUGH*/ |
case 'u': |
_uquad = UARG (); |
base = DEC; |
goto nosign; |
case 'X': |
xdigs = "0123456789ABCDEF"; |
goto hex; |
case 'x': |
xdigs = "0123456789abcdef"; |
hex: _uquad = UARG (); |
base = HEX; |
/* leading 0x/X only if non-zero */ |
if (flags & ALT && _uquad != 0) { |
ox[0] = '0'; |
ox[1] = ch; |
flags |= HEXPREFIX; |
} |
#ifdef _WANT_IO_C99_FORMATS |
flags &= ~GROUPING; |
#endif |
/* unsigned conversions */ |
nosign: sign = '\0'; |
/* |
* ``... diouXx conversions ... if a precision is |
* specified, the 0 flag will be ignored.'' |
* -- ANSI X3J11 |
*/ |
number: if ((dprec = prec) >= 0) |
flags &= ~ZEROPAD; |
/* |
* ``The result of converting a zero value with an |
* explicit precision of zero is no characters.'' |
* -- ANSI X3J11 |
*/ |
cp = buf + BUF; |
if (_uquad != 0 || prec != 0) { |
/* |
* Unsigned mod is hard, and unsigned mod |
* by a constant is easier than that by |
* a variable; hence this switch. |
*/ |
switch (base) { |
case OCT: |
do { |
*--cp = to_char (_uquad & 7); |
_uquad >>= 3; |
} while (_uquad); |
/* handle octal leading 0 */ |
if (flags & ALT && *cp != '0') |
*--cp = '0'; |
break; |
case DEC: |
/* many numbers are 1 digit */ |
if (_uquad < 10) { |
*--cp = to_char(_uquad); |
break; |
} |
#ifdef _WANT_IO_C99_FORMATS |
ndig = 0; |
#endif |
do { |
*--cp = to_char (_uquad % 10); |
#ifdef _WANT_IO_C99_FORMATS |
ndig++; |
/* If (*grouping == CHAR_MAX) then no |
more grouping */ |
if ((flags & GROUPING) |
&& ndig == *grouping |
&& *grouping != CHAR_MAX |
&& _uquad > 9) { |
cp -= thsnd_len; |
strncpy (cp, thousands_sep, |
thsnd_len); |
ndig = 0; |
/* If (grouping[1] == '\0') then we |
have to use *grouping character |
(last grouping rule) for all |
next cases. */ |
if (grouping[1] != '\0') |
grouping++; |
} |
#endif |
_uquad /= 10; |
} while (_uquad != 0); |
break; |
case HEX: |
do { |
*--cp = xdigs[_uquad & 15]; |
_uquad >>= 4; |
} while (_uquad); |
break; |
default: |
cp = "bug in vfprintf: bad base"; |
size = strlen (cp); |
goto skipsize; |
} |
} |
/* |
* ...result is to be converted to an 'alternate form'. |
* For o conversion, it increases the precision to force |
* the first digit of the result to be a zero." |
* -- ANSI X3J11 |
* |
* To demonstrate this case, compile and run: |
* printf ("%#.0o",0); |
*/ |
else if (base == OCT && (flags & ALT)) |
*--cp = '0'; |
size = buf + BUF - cp; |
skipsize: |
break; |
default: /* "%?" prints ?, unless ? is NUL */ |
if (ch == '\0') |
goto done; |
/* pretend it was %c with argument ch */ |
cp = buf; |
*cp = ch; |
size = 1; |
sign = '\0'; |
break; |
} |
/* |
* All reasonable formats wind up here. At this point, `cp' |
* points to a string which (if not flags&LADJUST) should be |
* padded out to `width' places. If flags&ZEROPAD, it should |
* first be prefixed by any sign or other prefix; otherwise, |
* it should be blank padded before the prefix is emitted. |
* After any left-hand padding and prefixing, emit zeroes |
* required by a decimal [diouxX] precision, then print the |
* string proper, then emit zeroes required by any leftover |
* floating precision; finally, if LADJUST, pad with blanks. |
* If flags&FPT, ch must be in [aAeEfg]. |
* |
* Compute actual size, so we know how much to pad. |
* size excludes decimal prec; realsz includes it. |
*/ |
realsz = dprec > size ? dprec : size; |
if (sign) |
realsz++; |
if (flags & HEXPREFIX) |
realsz+= 2; |
/* right-adjusting blank padding */ |
if ((flags & (LADJUST|ZEROPAD)) == 0) |
PAD (width - realsz, blanks); |
/* prefix */ |
if (sign) |
PRINT (&sign, 1); |
if (flags & HEXPREFIX) |
PRINT (ox, 2); |
/* right-adjusting zero padding */ |
if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) |
PAD (width - realsz, zeroes); |
/* leading zeroes from decimal precision */ |
PAD (dprec - size, zeroes); |
/* the string or number proper */ |
#ifdef FLOATING_POINT |
if ((flags & FPT) == 0) { |
PRINT (cp, size); |
} else { /* glue together f_p fragments */ |
if (ch >= 'f') { /* 'f' or 'g' */ |
if (_fpvalue == 0) { |
/* kludge for __dtoa irregularity */ |
PRINT ("0", 1); |
if (expt < ndig || flags & ALT) { |
PRINT (decimal_point, decp_len); |
PAD (ndig - 1, zeroes); |
} |
} else if (expt <= 0) { |
PRINT ("0", 1); |
if (expt || ndig || flags & ALT) { |
PRINT (decimal_point, decp_len); |
PAD (-expt, zeroes); |
PRINT (cp, ndig); |
} |
} else { |
char *convbuf = cp; |
PRINTANDPAD(cp, convbuf + ndig, |
lead, zeroes); |
cp += lead; |
#ifdef _WANT_IO_C99_FORMATS |
if (flags & GROUPING) { |
while (nseps > 0 || nrepeats > 0) { |
if (nrepeats > 0) |
nrepeats--; |
else { |
grouping--; |
nseps--; |
} |
PRINT(thousands_sep, thsnd_len); |
PRINTANDPAD (cp, convbuf + ndig, |
*grouping, zeroes); |
cp += *grouping; |
} |
if (cp > convbuf + ndig) |
cp = convbuf + ndig; |
} |
#endif |
if (expt < ndig || flags & ALT) |
PRINT (decimal_point, decp_len); |
PRINTANDPAD (cp, convbuf + ndig, |
ndig - expt, zeroes); |
} |
} else { /* 'a', 'A', 'e', or 'E' */ |
if (ndig > 1 || flags & ALT) { |
PRINT (cp, 1); |
cp++; |
PRINT (decimal_point, decp_len); |
if (_fpvalue) { |
PRINT (cp, ndig - 1); |
} else /* 0.[0..] */ |
/* __dtoa irregularity */ |
PAD (ndig - 1, zeroes); |
} else /* XeYYY */ |
PRINT (cp, 1); |
PRINT (expstr, expsize); |
} |
} |
#else /* !FLOATING_POINT */ |
PRINT (cp, size); |
#endif |
/* left-adjusting padding (always blank) */ |
if (flags & LADJUST) |
PAD (width - realsz, blanks); |
/* finally, adjust ret */ |
ret += width > realsz ? width : realsz; |
FLUSH (); /* copy out the I/O vectors */ |
if (malloc_buf != NULL) { |
_free_r (data, malloc_buf); |
malloc_buf = NULL; |
} |
} |
done: |
FLUSH (); |
error: |
if (malloc_buf != NULL) |
_free_r (data, malloc_buf); |
#ifndef STRING_ONLY |
_funlockfile (fp); |
#endif |
return (__sferror (fp) ? EOF : ret); |
/* NOTREACHED */ |
} |
#ifdef FLOATING_POINT |
/* Using reentrant DATA, convert finite VALUE into a string of digits |
with no decimal point, using NDIGITS precision and FLAGS as guides |
to whether trailing zeros must be included. Set *SIGN to nonzero |
if VALUE was negative. Set *DECPT to the exponent plus one. Set |
*LENGTH to the length of the returned string. CH must be one of |
[aAeEfFgG]; if it is [aA], then the return string lives in BUF, |
otherwise the return value shares the mprec reentrant storage. */ |
static char * |
cvt(struct _reent *data, _PRINTF_FLOAT_TYPE value, int ndigits, int flags, |
char *sign, int *decpt, int ch, int *length, char *buf) |
{ |
int mode, dsgn; |
char *digits, *bp, *rve; |
# ifdef _NO_LONGDBL |
union double_union tmp; |
tmp.d = value; |
if (word0 (tmp) & Sign_bit) { /* this will check for < 0 and -0.0 */ |
value = -value; |
*sign = '-'; |
} else |
*sign = '\000'; |
# else /* !_NO_LONGDBL */ |
union |
{ |
struct ldieee ieee; |
_LONG_DOUBLE val; |
} ld; |
ld.val = value; |
if (ld.ieee.sign) { /* this will check for < 0 and -0.0 */ |
value = -value; |
*sign = '-'; |
} else |
*sign = '\000'; |
# endif /* !_NO_LONGDBL */ |
# ifdef _WANT_IO_C99_FORMATS |
if (ch == 'a' || ch == 'A') { |
/* This code assumes FLT_RADIX is a power of 2. The initial |
division ensures the digit before the decimal will be less |
than FLT_RADIX (unless it is rounded later). There is no |
loss of precision in these calculations. */ |
value = FREXP (value, decpt) / 8; |
if (!value) |
*decpt = 1; |
digits = ch == 'a' ? "0123456789abcdef" : "0123456789ABCDEF"; |
bp = buf; |
do { |
value *= 16; |
mode = (int) value; |
value -= mode; |
*bp++ = digits[mode]; |
} while (ndigits-- && value); |
if (value > 0.5 || (value == 0.5 && mode & 1)) { |
/* round to even */ |
rve = bp; |
while (*--rve == digits[0xf]) { |
*rve = '0'; |
} |
*rve = *rve == '9' ? digits[0xa] : *rve + 1; |
} else { |
while (ndigits-- >= 0) { |
*bp++ = '0'; |
} |
} |
*length = bp - buf; |
return buf; |
} |
# endif /* _WANT_IO_C99_FORMATS */ |
if (ch == 'f' || ch == 'F') { |
mode = 3; /* ndigits after the decimal point */ |
} else { |
/* To obtain ndigits after the decimal point for the 'e' |
* and 'E' formats, round to ndigits + 1 significant |
* figures. |
*/ |
if (ch == 'e' || ch == 'E') { |
ndigits++; |
} |
mode = 2; /* ndigits significant digits */ |
} |
digits = _DTOA_R (data, value, mode, ndigits, decpt, &dsgn, &rve); |
if ((ch != 'g' && ch != 'G') || flags & ALT) { /* Print trailing zeros */ |
bp = digits + ndigits; |
if (ch == 'f' || ch == 'F') { |
if (*digits == '0' && value) |
*decpt = -ndigits + 1; |
bp += *decpt; |
} |
if (value == 0) /* kludge for __dtoa irregularity */ |
rve = bp; |
while (rve < bp) |
*rve++ = '0'; |
} |
*length = rve - digits; |
return (digits); |
} |
static int |
exponent(char *p0, int exp, int fmtch) |
{ |
register char *p, *t; |
char expbuf[MAXEXPLEN]; |
# ifdef _WANT_IO_C99_FORMATS |
int isa = fmtch == 'a' || fmtch == 'A'; |
# else |
# define isa 0 |
# endif |
p = p0; |
*p++ = isa ? 'p' - 'a' + fmtch : fmtch; |
if (exp < 0) { |
exp = -exp; |
*p++ = '-'; |
} |
else |
*p++ = '+'; |
t = expbuf + MAXEXPLEN; |
if (exp > 9) { |
do { |
*--t = to_char (exp % 10); |
} while ((exp /= 10) > 9); |
*--t = to_char (exp); |
for (; t < expbuf + MAXEXPLEN; *p++ = *t++); |
} |
else { |
if (!isa) |
*p++ = '0'; |
*p++ = to_char (exp); |
} |
return (p - p0); |
} |
#endif /* FLOATING_POINT */ |
#ifndef _NO_POS_ARGS |
/* Positional argument support. |
Written by Jeff Johnston |
Copyright (c) 2002 Red Hat Incorporated. |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
The name of Red Hat Incorporated may not be used to endorse |
or promote products derived from this software without specific |
prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ |
/* The below constant state tables are shared between all versions of |
vfprintf and vfwprintf. They must only be defined once, which we do in |
the STRING_ONLY/INTEGER_ONLY versions here. */ |
#if defined (STRING_ONLY) && defined(INTEGER_ONLY) |
_CONST __CH_CLASS __chclass[256] = { |
/* 00-07 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 08-0f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 10-17 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 18-1f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 20-27 */ FLAG, OTHER, OTHER, FLAG, DOLLAR, OTHER, OTHER, FLAG, |
/* 28-2f */ OTHER, OTHER, STAR, FLAG, OTHER, FLAG, DOT, OTHER, |
/* 30-37 */ ZERO, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, |
/* 38-3f */ DIGIT, DIGIT, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 40-47 */ OTHER, SPEC, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC, |
/* 48-4f */ OTHER, OTHER, OTHER, OTHER, MODFR, OTHER, OTHER, SPEC, |
/* 50-57 */ OTHER, OTHER, OTHER, SPEC, OTHER, SPEC, OTHER, OTHER, |
/* 58-5f */ SPEC, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 60-67 */ OTHER, SPEC, OTHER, SPEC, SPEC, SPEC, SPEC, SPEC, |
/* 68-6f */ MODFR, SPEC, MODFR, OTHER, MODFR, OTHER, SPEC, SPEC, |
/* 70-77 */ SPEC, MODFR, OTHER, SPEC, MODFR, SPEC, OTHER, OTHER, |
/* 78-7f */ SPEC, OTHER, MODFR, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 80-87 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 88-8f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 90-97 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* 98-9f */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* a0-a7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* a8-af */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* b0-b7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* b8-bf */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* c0-c7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* c8-cf */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* d0-d7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* d8-df */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* e0-e7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* e8-ef */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* f0-f7 */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
/* f8-ff */ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, |
}; |
_CONST __STATE __state_table[MAX_STATE][MAX_CH_CLASS] = { |
/* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ |
/* START */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE }, |
/* SFLAG */ { SFLAG, WDIG, DONE, SMOD, DONE, SDOT, VARW, SFLAG, DONE }, |
/* WDIG */ { DONE, DONE, WIDTH, SMOD, DONE, SDOT, DONE, DONE, DONE }, |
/* WIDTH */ { DONE, DONE, DONE, SMOD, DONE, SDOT, DONE, DONE, DONE }, |
/* SMOD */ { DONE, DONE, DONE, DONE, DONE, DONE, DONE, DONE, DONE }, |
/* SDOT */ { SDOT, PREC, DONE, SMOD, DONE, DONE, VARP, DONE, DONE }, |
/* VARW */ { DONE, VWDIG, DONE, SMOD, DONE, SDOT, DONE, DONE, DONE }, |
/* VARP */ { DONE, VPDIG, DONE, SMOD, DONE, DONE, DONE, DONE, DONE }, |
/* PREC */ { DONE, DONE, DONE, SMOD, DONE, DONE, DONE, DONE, DONE }, |
/* VWDIG */ { DONE, DONE, WIDTH, DONE, DONE, DONE, DONE, DONE, DONE }, |
/* VPDIG */ { DONE, DONE, PREC, DONE, DONE, DONE, DONE, DONE, DONE }, |
}; |
_CONST __ACTION __action_table[MAX_STATE][MAX_CH_CLASS] = { |
/* '0' '1-9' '$' MODFR SPEC '.' '*' FLAG OTHER */ |
/* START */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* SFLAG */ { NOOP, NUMBER, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* WDIG */ { NOOP, NOOP, GETPOS, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* WIDTH */ { NOOP, NOOP, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* SMOD */ { NOOP, NOOP, NOOP, NOOP, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* SDOT */ { NOOP, SKIPNUM, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* VARW */ { NOOP, NUMBER, NOOP, GETPW, GETPWB, GETPW, NOOP, NOOP, NOOP }, |
/* VARP */ { NOOP, NUMBER, NOOP, GETPW, GETPWB, NOOP, NOOP, NOOP, NOOP }, |
/* PREC */ { NOOP, NOOP, NOOP, GETMOD, GETARG, NOOP, NOOP, NOOP, NOOP }, |
/* VWDIG */ { NOOP, NOOP, PWPOS, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP }, |
/* VPDIG */ { NOOP, NOOP, PWPOS, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP }, |
}; |
#endif /* STRING_ONLY && INTEGER_ONLY */ |
/* function to get positional parameter N where n = N - 1 */ |
static union arg_val * |
_DEFUN(get_arg, (data, n, fmt, ap, numargs_p, args, arg_type, last_fmt), |
struct _reent *data _AND |
int n _AND |
char *fmt _AND |
va_list *ap _AND |
int *numargs_p _AND |
union arg_val *args _AND |
int *arg_type _AND |
char **last_fmt) |
{ |
int ch; |
int number, flags; |
int spec_type; |
int numargs = *numargs_p; |
__CH_CLASS chtype; |
__STATE state, next_state; |
__ACTION action; |
int pos, last_arg; |
int max_pos_arg = n; |
/* Only need types that can be reached via vararg promotions. */ |
enum types { INT, LONG_INT, QUAD_INT, CHAR_PTR, DOUBLE, LONG_DOUBLE, WIDE_CHAR }; |
# ifdef _MB_CAPABLE |
wchar_t wc; |
mbstate_t wc_state; |
int nbytes; |
# endif |
/* if this isn't the first call, pick up where we left off last time */ |
if (*last_fmt != NULL) |
fmt = *last_fmt; |
# ifdef _MB_CAPABLE |
memset (&wc_state, '\0', sizeof (wc_state)); |
# endif |
/* we need to process either to end of fmt string or until we have actually |
read the desired parameter from the vararg list. */ |
while (*fmt && n >= numargs) |
{ |
# ifdef _MB_CAPABLE |
while ((nbytes = __mbtowc (data, &wc, fmt, MB_CUR_MAX, |
__locale_charset (), &wc_state)) > 0) |
{ |
fmt += nbytes; |
if (wc == '%') |
break; |
} |
if (nbytes <= 0) |
break; |
# else |
while (*fmt != '\0' && *fmt != '%') |
fmt += 1; |
if (*fmt == '\0') |
break; |
# endif /* ! _MB_CAPABLE */ |
state = START; |
flags = 0; |
pos = -1; |
number = 0; |
spec_type = INT; |
/* Use state/action table to process format specifiers. We ignore invalid |
formats and we are only interested in information that tells us how to |
read the vararg list. */ |
while (state != DONE) |
{ |
ch = *fmt++; |
chtype = __chclass[ch]; |
next_state = __state_table[state][chtype]; |
action = __action_table[state][chtype]; |
state = next_state; |
switch (action) |
{ |
case GETMOD: /* we have format modifier */ |
switch (ch) |
{ |
case 'h': |
/* No flag needed, since short and char promote to int. */ |
break; |
case 'L': |
flags |= LONGDBL; |
break; |
case 'q': |
flags |= QUADINT; |
break; |
# ifdef _WANT_IO_C99_FORMATS |
case 'j': |
if (sizeof (intmax_t) == sizeof (long)) |
flags |= LONGINT; |
else |
flags |= QUADINT; |
break; |
case 'z': |
if (sizeof (size_t) <= sizeof (int)) |
/* no flag needed */; |
else if (sizeof (size_t) <= sizeof (long)) |
flags |= LONGINT; |
else |
/* POSIX states that at least one programming |
environment must support size_t no wider than |
long, but that means other environments can |
have size_t as wide as long long. */ |
flags |= QUADINT; |
break; |
case 't': |
if (sizeof (ptrdiff_t) <= sizeof (int)) |
/* no flag needed */; |
else if (sizeof (ptrdiff_t) <= sizeof (long)) |
flags |= LONGINT; |
else |
/* POSIX states that at least one programming |
environment must support ptrdiff_t no wider than |
long, but that means other environments can |
have ptrdiff_t as wide as long long. */ |
flags |= QUADINT; |
break; |
# endif /* _WANT_IO_C99_FORMATS */ |
case 'l': |
default: |
# if defined _WANT_IO_C99_FORMATS || !defined _NO_LONGLONG |
if (*fmt == 'l') |
{ |
flags |= QUADINT; |
++fmt; |
} |
else |
# endif |
flags |= LONGINT; |
break; |
} |
break; |
case GETARG: /* we have format specifier */ |
{ |
numargs &= (MAX_POS_ARGS - 1); |
/* process the specifier and translate it to a type to fetch from varargs */ |
switch (ch) |
{ |
case 'd': |
case 'i': |
case 'o': |
case 'x': |
case 'X': |
case 'u': |
if (flags & LONGINT) |
spec_type = LONG_INT; |
# ifndef _NO_LONGLONG |
else if (flags & QUADINT) |
spec_type = QUAD_INT; |
# endif |
else |
spec_type = INT; |
break; |
case 'D': |
case 'U': |
case 'O': |
spec_type = LONG_INT; |
break; |
# ifdef _WANT_IO_C99_FORMATS |
case 'a': |
case 'A': |
case 'F': |
# endif |
case 'f': |
case 'g': |
case 'G': |
case 'E': |
case 'e': |
# ifndef _NO_LONGDBL |
if (flags & LONGDBL) |
spec_type = LONG_DOUBLE; |
else |
# endif |
spec_type = DOUBLE; |
break; |
case 's': |
# ifdef _WANT_IO_C99_FORMATS |
case 'S': |
# endif |
case 'p': |
case 'n': |
spec_type = CHAR_PTR; |
break; |
case 'c': |
# ifdef _WANT_IO_C99_FORMATS |
if (flags & LONGINT) |
spec_type = WIDE_CHAR; |
else |
# endif |
spec_type = INT; |
break; |
# ifdef _WANT_IO_C99_FORMATS |
case 'C': |
spec_type = WIDE_CHAR; |
break; |
# endif |
} |
/* if we have a positional parameter, just store the type, otherwise |
fetch the parameter from the vararg list */ |
if (pos != -1) |
arg_type[pos] = spec_type; |
else |
{ |
switch (spec_type) |
{ |
case LONG_INT: |
args[numargs++].val_long = va_arg (*ap, long); |
break; |
case QUAD_INT: |
args[numargs++].val_quad_t = va_arg (*ap, quad_t); |
break; |
case WIDE_CHAR: |
args[numargs++].val_wint_t = va_arg (*ap, wint_t); |
break; |
case INT: |
args[numargs++].val_int = va_arg (*ap, int); |
break; |
case CHAR_PTR: |
args[numargs++].val_char_ptr_t = va_arg (*ap, char *); |
break; |
case DOUBLE: |
args[numargs++].val_double = va_arg (*ap, double); |
break; |
case LONG_DOUBLE: |
args[numargs++].val__LONG_DOUBLE = va_arg (*ap, _LONG_DOUBLE); |
break; |
} |
} |
} |
break; |
case GETPOS: /* we have positional specifier */ |
if (arg_type[0] == -1) |
memset (arg_type, 0, sizeof (int) * MAX_POS_ARGS); |
pos = number - 1; |
max_pos_arg = (max_pos_arg > pos ? max_pos_arg : pos); |
break; |
case PWPOS: /* we have positional specifier for width or precision */ |
if (arg_type[0] == -1) |
memset (arg_type, 0, sizeof (int) * MAX_POS_ARGS); |
number -= 1; |
arg_type[number] = INT; |
max_pos_arg = (max_pos_arg > number ? max_pos_arg : number); |
break; |
case GETPWB: /* we require format pushback */ |
--fmt; |
/* fallthrough */ |
case GETPW: /* we have a variable precision or width to acquire */ |
args[numargs++].val_int = va_arg (*ap, int); |
break; |
case NUMBER: /* we have a number to process */ |
number = (ch - '0'); |
while ((ch = *fmt) != '\0' && is_digit (ch)) |
{ |
number = number * 10 + (ch - '0'); |
++fmt; |
} |
break; |
case SKIPNUM: /* we have a number to skip */ |
while ((ch = *fmt) != '\0' && is_digit (ch)) |
++fmt; |
break; |
case NOOP: |
default: |
break; /* do nothing */ |
} |
} |
} |
/* process all arguments up to at least the one we are looking for and if we |
have seen the end of the string, then process up to the max argument needed */ |
if (*fmt == '\0') |
last_arg = max_pos_arg; |
else |
last_arg = n; |
while (numargs <= last_arg) |
{ |
switch (arg_type[numargs]) |
{ |
case LONG_INT: |
args[numargs++].val_long = va_arg (*ap, long); |
break; |
case QUAD_INT: |
args[numargs++].val_quad_t = va_arg (*ap, quad_t); |
break; |
case CHAR_PTR: |
args[numargs++].val_char_ptr_t = va_arg (*ap, char *); |
break; |
case DOUBLE: |
args[numargs++].val_double = va_arg (*ap, double); |
break; |
case LONG_DOUBLE: |
args[numargs++].val__LONG_DOUBLE = va_arg (*ap, _LONG_DOUBLE); |
break; |
case WIDE_CHAR: |
args[numargs++].val_wint_t = va_arg (*ap, wint_t); |
break; |
case INT: |
default: |
args[numargs++].val_int = va_arg (*ap, int); |
break; |
} |
} |
/* alter the global numargs value and keep a reference to the last bit of the fmt |
string we processed here because the caller will continue processing where we started */ |
*numargs_p = numargs; |
*last_fmt = fmt; |
return &args[n]; |
} |
#endif /* !_NO_POS_ARGS */ |
/contrib/sdk/sources/libc/stdio/vfscanf.c |
---|
0,0 → 1,1620 |
/*- |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* |
FUNCTION |
<<vfscanf>>, <<vscanf>>, <<vsscanf>>---format argument list |
INDEX |
vfscanf |
INDEX |
_vfscanf_r |
INDEX |
vscanf |
INDEX |
_vscanf_r |
INDEX |
vsscanf |
INDEX |
_vsscanf_r |
ANSI_SYNOPSIS |
#include <stdio.h> |
#include <stdarg.h> |
int vscanf(const char *<[fmt]>, va_list <[list]>); |
int vfscanf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>); |
int vsscanf(const char *<[str]>, const char *<[fmt]>, va_list <[list]>); |
int _vscanf_r(struct _reent *<[reent]>, const char *<[fmt]>, |
va_list <[list]>); |
int _vfscanf_r(struct _reent *<[reent]>, FILE *<[fp]>, const char *<[fmt]>, |
va_list <[list]>); |
int _vsscanf_r(struct _reent *<[reent]>, const char *<[str]>, |
const char *<[fmt]>, va_list <[list]>); |
TRAD_SYNOPSIS |
#include <stdio.h> |
#include <varargs.h> |
int vscanf( <[fmt]>, <[ist]>) |
char *<[fmt]>; |
va_list <[list]>; |
int vfscanf( <[fp]>, <[fmt]>, <[list]>) |
FILE *<[fp]>; |
char *<[fmt]>; |
va_list <[list]>; |
int vsscanf( <[str]>, <[fmt]>, <[list]>) |
char *<[str]>; |
char *<[fmt]>; |
va_list <[list]>; |
int _vscanf_r( <[reent]>, <[fmt]>, <[ist]>) |
struct _reent *<[reent]>; |
char *<[fmt]>; |
va_list <[list]>; |
int _vfscanf_r( <[reent]>, <[fp]>, <[fmt]>, <[list]>) |
struct _reent *<[reent]>; |
FILE *<[fp]>; |
char *<[fmt]>; |
va_list <[list]>; |
int _vsscanf_r( <[reent]>, <[str]>, <[fmt]>, <[list]>) |
struct _reent *<[reent]>; |
char *<[str]>; |
char *<[fmt]>; |
va_list <[list]>; |
DESCRIPTION |
<<vscanf>>, <<vfscanf>>, and <<vsscanf>> are (respectively) variants |
of <<scanf>>, <<fscanf>>, and <<sscanf>>. They differ only in |
allowing their caller to pass the variable argument list as a |
<<va_list>> object (initialized by <<va_start>>) rather than |
directly accepting a variable number of arguments. |
RETURNS |
The return values are consistent with the corresponding functions: |
<<vscanf>> returns the number of input fields successfully scanned, |
converted, and stored; the return value does not include scanned |
fields which were not stored. |
If <<vscanf>> attempts to read at end-of-file, the return value |
is <<EOF>>. |
If no fields were stored, the return value is <<0>>. |
The routines <<_vscanf_r>>, <<_vfscanf_f>>, and <<_vsscanf_r>> are |
reentrant versions which take an additional first parameter which points to the |
reentrancy structure. |
PORTABILITY |
These are GNU extensions. |
Supporting OS subroutines required: |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <newlib.h> |
#include <ctype.h> |
#include <wctype.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdint.h> |
#include <limits.h> |
#include <wchar.h> |
#include <string.h> |
#include <stdarg.h> |
#include <errno.h> |
#include "local.h" |
#include "../stdlib/local.h" |
#ifdef INTEGER_ONLY |
#define VFSCANF vfiscanf |
#define _VFSCANF_R _vfiscanf_r |
#define __SVFSCANF __svfiscanf |
#ifdef STRING_ONLY |
# define __SVFSCANF_R __ssvfiscanf_r |
#else |
# define __SVFSCANF_R __svfiscanf_r |
#endif |
#else |
#define VFSCANF vfscanf |
#define _VFSCANF_R _vfscanf_r |
#define __SVFSCANF __svfscanf |
#ifdef STRING_ONLY |
# define __SVFSCANF_R __ssvfscanf_r |
#else |
# define __SVFSCANF_R __svfscanf_r |
#endif |
#ifndef NO_FLOATING_POINT |
#define FLOATING_POINT |
#endif |
#endif |
#ifdef STRING_ONLY |
#undef _flockfile |
#undef _funlockfile |
#define _flockfile(x) {} |
#define _funlockfile(x) {} |
#define _ungetc_r _sungetc_r |
#define __srefill_r __ssrefill_r |
#define _fread_r _sfread_r |
#endif |
#ifdef FLOATING_POINT |
#include <math.h> |
#include <float.h> |
/* Currently a test is made to see if long double processing is warranted. |
This could be changed in the future should the _ldtoa_r code be |
preferred over _dtoa_r. */ |
#define _NO_LONGDBL |
#if defined _WANT_IO_LONG_DOUBLE && (LDBL_MANT_DIG > DBL_MANT_DIG) |
#undef _NO_LONGDBL |
extern _LONG_DOUBLE _strtold _PARAMS((char *s, char **sptr)); |
#endif |
#include "floatio.h" |
#if ((MAXEXP+MAXFRACT+3) > MB_LEN_MAX) |
# define BUF (MAXEXP+MAXFRACT+3) /* 3 = sign + decimal point + NUL */ |
#else |
# define BUF MB_LEN_MAX |
#endif |
/* An upper bound for how long a long prints in decimal. 4 / 13 approximates |
log (2). Add one char for roundoff compensation and one for the sign. */ |
#define MAX_LONG_LEN ((CHAR_BIT * sizeof (long) - 1) * 4 / 13 + 2) |
#else |
#define BUF 40 |
#endif |
#define _NO_LONGLONG |
#if defined _WANT_IO_LONG_LONG \ |
&& (defined __GNUC__ || __STDC_VERSION__ >= 199901L) |
# undef _NO_LONGLONG |
#endif |
#define _NO_POS_ARGS |
#ifdef _WANT_IO_POS_ARGS |
# undef _NO_POS_ARGS |
# ifdef NL_ARGMAX |
# define MAX_POS_ARGS NL_ARGMAX |
# else |
# define MAX_POS_ARGS 32 |
# endif |
static void * get_arg (int, va_list *, int *, void **); |
#endif /* _WANT_IO_POS_ARGS */ |
/* |
* Flags used during conversion. |
*/ |
#define LONG 0x01 /* l: long or double */ |
#define LONGDBL 0x02 /* L/ll: long double or long long */ |
#define SHORT 0x04 /* h: short */ |
#define CHAR 0x08 /* hh: 8 bit integer */ |
#define SUPPRESS 0x10 /* suppress assignment */ |
#define POINTER 0x20 /* weird %p pointer (`fake hex') */ |
#define NOSKIP 0x40 /* do not skip blanks */ |
/* |
* The following are used in numeric conversions only: |
* SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point; |
* SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral. |
*/ |
#define SIGNOK 0x80 /* +/- is (still) legal */ |
#define NDIGITS 0x100 /* no digits detected */ |
#define DPTOK 0x200 /* (float) decimal point is still legal */ |
#define EXPOK 0x400 /* (float) exponent (e+3, etc) still legal */ |
#define PFXOK 0x200 /* 0x prefix is (still) legal */ |
#define NZDIGITS 0x400 /* no zero digits detected */ |
#define NNZDIGITS 0x800 /* no non-zero digits detected */ |
/* |
* Conversion types. |
*/ |
#define CT_CHAR 0 /* %c conversion */ |
#define CT_CCL 1 /* %[...] conversion */ |
#define CT_STRING 2 /* %s conversion */ |
#define CT_INT 3 /* integer, i.e., strtol or strtoul */ |
#define CT_FLOAT 4 /* floating, i.e., strtod */ |
#if 0 |
#define u_char unsigned char |
#endif |
#define u_char char |
#define u_long unsigned long |
#ifndef _NO_LONGLONG |
typedef unsigned long long u_long_long; |
#endif |
/* |
* vfscanf |
*/ |
#define BufferEmpty (fp->_r <= 0 && __srefill_r(rptr, fp)) |
#ifndef STRING_ONLY |
#ifndef _REENT_ONLY |
int |
_DEFUN(VFSCANF, (fp, fmt, ap), |
register FILE *fp _AND |
_CONST char *fmt _AND |
va_list ap) |
{ |
CHECK_INIT(_REENT, fp); |
return __SVFSCANF_R (_REENT, fp, fmt, ap); |
} |
int |
_DEFUN(__SVFSCANF, (fp, fmt0, ap), |
register FILE *fp _AND |
char _CONST *fmt0 _AND |
va_list ap) |
{ |
return __SVFSCANF_R (_REENT, fp, fmt0, ap); |
} |
#endif /* !_REENT_ONLY */ |
int |
_DEFUN(_VFSCANF_R, (data, fp, fmt, ap), |
struct _reent *data _AND |
register FILE *fp _AND |
_CONST char *fmt _AND |
va_list ap) |
{ |
CHECK_INIT(data, fp); |
return __SVFSCANF_R (data, fp, fmt, ap); |
} |
#endif /* !STRING_ONLY */ |
#if defined (STRING_ONLY) && defined (INTEGER_ONLY) |
/* When dealing with the sscanf family, we don't want to use the |
* regular ungetc which will drag in file I/O items we don't need. |
* So, we create our own trimmed-down version. */ |
int |
_DEFUN(_sungetc_r, (data, fp, ch), |
struct _reent *data _AND |
int c _AND |
register FILE *fp) |
{ |
if (c == EOF) |
return (EOF); |
/* After ungetc, we won't be at eof anymore */ |
fp->_flags &= ~__SEOF; |
c = (unsigned char) c; |
/* |
* If we are in the middle of ungetc'ing, just continue. |
* This may require expanding the current ungetc buffer. |
*/ |
if (HASUB (fp)) |
{ |
if (fp->_r >= fp->_ub._size && __submore (data, fp)) |
{ |
return EOF; |
} |
*--fp->_p = c; |
fp->_r++; |
return c; |
} |
/* |
* If we can handle this by simply backing up, do so, |
* but never replace the original character. |
* (This makes sscanf() work when scanning `const' data.) |
*/ |
if (fp->_bf._base != NULL && fp->_p > fp->_bf._base && fp->_p[-1] == c) |
{ |
fp->_p--; |
fp->_r++; |
return c; |
} |
/* |
* Create an ungetc buffer. |
* Initially, we will use the `reserve' buffer. |
*/ |
fp->_ur = fp->_r; |
fp->_up = fp->_p; |
fp->_ub._base = fp->_ubuf; |
fp->_ub._size = sizeof (fp->_ubuf); |
fp->_ubuf[sizeof (fp->_ubuf) - 1] = c; |
fp->_p = &fp->_ubuf[sizeof (fp->_ubuf) - 1]; |
fp->_r = 1; |
return c; |
} |
/* String only version of __srefill_r for sscanf family. */ |
int |
_DEFUN(__ssrefill_r, (ptr, fp), |
struct _reent * ptr _AND |
register FILE * fp) |
{ |
/* |
* Our only hope of further input is the ungetc buffer. |
* If there is anything in that buffer to read, return. |
*/ |
if (HASUB (fp)) |
{ |
FREEUB (ptr, fp); |
if ((fp->_r = fp->_ur) != 0) |
{ |
fp->_p = fp->_up; |
return 0; |
} |
} |
/* Otherwise we are out of character input. */ |
fp->_p = fp->_bf._base; |
fp->_r = 0; |
fp->_flags |= __SEOF; |
return EOF; |
} |
size_t |
_DEFUN(_sfread_r, (ptr, buf, size, count, fp), |
struct _reent * ptr _AND |
_PTR buf _AND |
size_t size _AND |
size_t count _AND |
FILE * fp) |
{ |
register size_t resid; |
register char *p; |
register int r; |
size_t total; |
if ((resid = count * size) == 0) |
return 0; |
total = resid; |
p = buf; |
while (resid > (r = fp->_r)) |
{ |
_CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, (size_t) r); |
fp->_p += r; |
fp->_r = 0; |
p += r; |
resid -= r; |
if (__ssrefill_r (ptr, fp)) |
{ |
/* no more input: return partial result */ |
return (total - resid) / size; |
} |
} |
_CAST_VOID memcpy ((_PTR) p, (_PTR) fp->_p, resid); |
fp->_r -= resid; |
fp->_p += resid; |
return count; |
} |
#else /* !STRING_ONLY || !INTEGER_ONLY */ |
int _EXFUN (_sungetc_r, (struct _reent *, int, register FILE *)); |
int _EXFUN (__ssrefill_r, (struct _reent *, register FILE *)); |
size_t _EXFUN (_sfread_r, (struct _reent *, _PTR buf, size_t, size_t, FILE *)); |
#endif /* !STRING_ONLY || !INTEGER_ONLY */ |
int |
_DEFUN(__SVFSCANF_R, (rptr, fp, fmt0, ap), |
struct _reent *rptr _AND |
register FILE *fp _AND |
char _CONST *fmt0 _AND |
va_list ap) |
{ |
register u_char *fmt = (u_char *) fmt0; |
register int c; /* character from format, or conversion */ |
register size_t width; /* field width, or 0 */ |
register char *p; /* points into all kinds of strings */ |
register int n; /* handy integer */ |
register int flags; /* flags as defined above */ |
register char *p0; /* saves original value of p when necessary */ |
int nassigned; /* number of fields assigned */ |
int nread; /* number of characters consumed from fp */ |
#ifndef _NO_POS_ARGS |
int N; /* arg number */ |
int arg_index = 0; /* index into args processed directly */ |
int numargs = 0; /* number of varargs read */ |
void *args[MAX_POS_ARGS]; /* positional args read */ |
int is_pos_arg; /* is current format positional? */ |
#endif |
int base = 0; /* base argument to strtol/strtoul */ |
int nbytes = 1; /* number of bytes read from fmt string */ |
wchar_t wc; /* wchar to use to read format string */ |
wchar_t *wcp; /* handy wide character pointer */ |
size_t mbslen; /* length of converted multibyte sequence */ |
#ifdef _MB_CAPABLE |
mbstate_t state; /* value to keep track of multibyte state */ |
#endif |
#define CCFN_PARAMS _PARAMS((struct _reent *, const char *, char **, int)) |
u_long (*ccfn)CCFN_PARAMS=0; /* conversion function (strtol/strtoul) */ |
char ccltab[256]; /* character class table for %[...] */ |
char buf[BUF]; /* buffer for numeric conversions */ |
unsigned char *lptr; /* literal pointer */ |
char *cp; |
short *sp; |
int *ip; |
#ifdef FLOATING_POINT |
float *flp; |
_LONG_DOUBLE *ldp; |
double *dp; |
#endif |
long *lp; |
#ifndef _NO_LONGLONG |
long long *llp; |
#endif |
/* `basefix' is used to avoid `if' tests in the integer scanner */ |
static _CONST short basefix[17] = |
{10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; |
/* Macro to support positional arguments */ |
#ifndef _NO_POS_ARGS |
# define GET_ARG(n, ap, type) \ |
((type) (is_pos_arg \ |
? (n < numargs \ |
? args[n] \ |
: get_arg (n, &ap, &numargs, args)) \ |
: (arg_index++ < numargs \ |
? args[n] \ |
: (numargs < MAX_POS_ARGS \ |
? args[numargs++] = va_arg (ap, void *) \ |
: va_arg (ap, void *))))) |
#else |
# define GET_ARG(n, ap, type) (va_arg (ap, type)) |
#endif |
_flockfile (fp); |
ORIENT (fp, -1); |
nassigned = 0; |
nread = 0; |
#ifdef _MB_CAPABLE |
memset (&state, 0, sizeof (state)); |
#endif |
for (;;) |
{ |
#ifndef _MB_CAPABLE |
wc = *fmt; |
#else |
nbytes = __mbtowc (rptr, &wc, fmt, MB_CUR_MAX, __locale_charset (), |
&state); |
if (nbytes < 0) { |
wc = 0xFFFD; /* Unicode replacement character */ |
nbytes = 1; |
memset (&state, 0, sizeof (state)); |
} |
#endif |
fmt += nbytes; |
if (wc == 0) |
goto all_done; |
if (nbytes == 1 && isspace (wc)) |
{ |
for (;;) |
{ |
if (BufferEmpty || !isspace (*fp->_p)) |
break; |
nread++, fp->_r--, fp->_p++; |
} |
continue; |
} |
if (wc != '%') |
goto literal; |
width = 0; |
flags = 0; |
#ifndef _NO_POS_ARGS |
N = arg_index; |
is_pos_arg = 0; |
#endif |
/* |
* switch on the format. continue if done; break once format |
* type is derived. |
*/ |
again: |
c = *fmt++; |
switch (c) |
{ |
case '%': |
literal: |
lptr = fmt - nbytes; |
for (n = 0; n < nbytes; ++n) |
{ |
if (BufferEmpty) |
goto input_failure; |
if (*fp->_p != *lptr) |
goto match_failure; |
fp->_r--, fp->_p++; |
nread++; |
++lptr; |
} |
continue; |
case '*': |
flags |= SUPPRESS; |
goto again; |
case 'l': |
#if defined _WANT_IO_C99_FORMATS || !defined _NO_LONGLONG |
if (*fmt == 'l') /* Check for 'll' = long long (SUSv3) */ |
{ |
++fmt; |
flags |= LONGDBL; |
} |
else |
#endif |
flags |= LONG; |
goto again; |
case 'L': |
flags |= LONGDBL; |
goto again; |
case 'h': |
#ifdef _WANT_IO_C99_FORMATS |
if (*fmt == 'h') /* Check for 'hh' = char int (SUSv3) */ |
{ |
++fmt; |
flags |= CHAR; |
} |
else |
#endif |
flags |= SHORT; |
goto again; |
#ifdef _WANT_IO_C99_FORMATS |
case 'j': /* intmax_t */ |
if (sizeof (intmax_t) == sizeof (long)) |
flags |= LONG; |
else |
flags |= LONGDBL; |
goto again; |
case 't': /* ptrdiff_t */ |
if (sizeof (ptrdiff_t) < sizeof (int)) |
/* POSIX states ptrdiff_t is 16 or more bits, as |
is short. */ |
flags |= SHORT; |
else if (sizeof (ptrdiff_t) == sizeof (int)) |
/* no flag needed */; |
else if (sizeof (ptrdiff_t) <= sizeof (long)) |
flags |= LONG; |
else |
/* POSIX states that at least one programming |
environment must support ptrdiff_t no wider than |
long, but that means other environments can |
have ptrdiff_t as wide as long long. */ |
flags |= LONGDBL; |
goto again; |
case 'z': /* size_t */ |
if (sizeof (size_t) < sizeof (int)) |
/* POSIX states size_t is 16 or more bits, as is short. */ |
flags |= SHORT; |
else if (sizeof (size_t) == sizeof (int)) |
/* no flag needed */; |
else if (sizeof (size_t) <= sizeof (long)) |
flags |= LONG; |
else |
/* POSIX states that at least one programming |
environment must support size_t no wider than |
long, but that means other environments can |
have size_t as wide as long long. */ |
flags |= LONGDBL; |
goto again; |
#endif /* _WANT_IO_C99_FORMATS */ |
case '0': |
case '1': |
case '2': |
case '3': |
case '4': |
case '5': |
case '6': |
case '7': |
case '8': |
case '9': |
width = width * 10 + c - '0'; |
goto again; |
#ifndef _NO_POS_ARGS |
case '$': |
if (width <= MAX_POS_ARGS) |
{ |
N = width - 1; |
is_pos_arg = 1; |
width = 0; |
goto again; |
} |
rptr->_errno = EINVAL; |
goto input_failure; |
#endif /* !_NO_POS_ARGS */ |
/* |
* Conversions. Those marked `compat' are for |
* 4.[123]BSD compatibility. |
* |
* (According to ANSI, E and X formats are supposed to |
* the same as e and x. Sorry about that.) |
*/ |
case 'D': /* compat */ |
flags |= LONG; |
/* FALLTHROUGH */ |
case 'd': |
c = CT_INT; |
ccfn = (u_long (*)CCFN_PARAMS)_strtol_r; |
base = 10; |
break; |
case 'i': |
c = CT_INT; |
ccfn = (u_long (*)CCFN_PARAMS)_strtol_r; |
base = 0; |
break; |
case 'O': /* compat */ |
flags |= LONG; |
/* FALLTHROUGH */ |
case 'o': |
c = CT_INT; |
ccfn = _strtoul_r; |
base = 8; |
break; |
case 'u': |
c = CT_INT; |
ccfn = _strtoul_r; |
base = 10; |
break; |
case 'X': |
case 'x': |
flags |= PFXOK; /* enable 0x prefixing */ |
c = CT_INT; |
ccfn = _strtoul_r; |
base = 16; |
break; |
#ifdef FLOATING_POINT |
# ifdef _WANT_IO_C99_FORMATS |
case 'a': |
case 'A': |
case 'F': |
# endif |
case 'E': |
case 'G': |
case 'e': |
case 'f': |
case 'g': |
c = CT_FLOAT; |
break; |
#endif |
#ifdef _WANT_IO_C99_FORMATS |
case 'S': |
flags |= LONG; |
/* FALLTHROUGH */ |
#endif |
case 's': |
c = CT_STRING; |
break; |
case '[': |
fmt = (u_char *) __sccl (ccltab, (unsigned char *) fmt); |
flags |= NOSKIP; |
c = CT_CCL; |
break; |
#ifdef _WANT_IO_C99_FORMATS |
case 'C': |
flags |= LONG; |
/* FALLTHROUGH */ |
#endif |
case 'c': |
flags |= NOSKIP; |
c = CT_CHAR; |
break; |
case 'p': /* pointer format is like hex */ |
flags |= POINTER | PFXOK; |
c = CT_INT; |
ccfn = _strtoul_r; |
base = 16; |
break; |
case 'n': |
if (flags & SUPPRESS) /* ??? */ |
continue; |
#ifdef _WANT_IO_C99_FORMATS |
if (flags & CHAR) |
{ |
cp = GET_ARG (N, ap, char *); |
*cp = nread; |
} |
else |
#endif |
if (flags & SHORT) |
{ |
sp = GET_ARG (N, ap, short *); |
*sp = nread; |
} |
else if (flags & LONG) |
{ |
lp = GET_ARG (N, ap, long *); |
*lp = nread; |
} |
#ifndef _NO_LONGLONG |
else if (flags & LONGDBL) |
{ |
llp = GET_ARG (N, ap, long long*); |
*llp = nread; |
} |
#endif |
else |
{ |
ip = GET_ARG (N, ap, int *); |
*ip = nread; |
} |
continue; |
/* |
* Disgusting backwards compatibility hacks. XXX |
*/ |
case '\0': /* compat */ |
_funlockfile (fp); |
return EOF; |
default: /* compat */ |
if (isupper (c)) |
flags |= LONG; |
c = CT_INT; |
ccfn = (u_long (*)CCFN_PARAMS)_strtol_r; |
base = 10; |
break; |
} |
/* |
* We have a conversion that requires input. |
*/ |
if (BufferEmpty) |
goto input_failure; |
/* |
* Consume leading white space, except for formats that |
* suppress this. |
*/ |
if ((flags & NOSKIP) == 0) |
{ |
while (isspace (*fp->_p)) |
{ |
nread++; |
if (--fp->_r > 0) |
fp->_p++; |
else |
if (__srefill_r (rptr, fp)) |
goto input_failure; |
} |
/* |
* Note that there is at least one character in the |
* buffer, so conversions that do not set NOSKIP ca |
* no longer result in an input failure. |
*/ |
} |
/* |
* Do the conversion. |
*/ |
switch (c) |
{ |
case CT_CHAR: |
/* scan arbitrary characters (sets NOSKIP) */ |
if (width == 0) |
width = 1; |
#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 2 |
if (flags & LONG) |
{ |
mbstate_t state; |
memset (&state, 0, sizeof (mbstate_t)); |
if ((flags & SUPPRESS) == 0) |
wcp = GET_ARG (N, ap, wchar_t *); |
else |
wcp = NULL; |
n = 0; |
while (width != 0) |
{ |
if (n == MB_CUR_MAX) |
goto input_failure; |
buf[n++] = *fp->_p; |
fp->_r -= 1; |
fp->_p += 1; |
if ((mbslen = _mbrtowc_r (rptr, wcp, buf, n, &state)) |
== (size_t)-1) |
goto input_failure; /* Invalid sequence */ |
if (mbslen == 0 && !(flags & SUPPRESS)) |
*wcp = L'\0'; |
if (mbslen != (size_t)-2) /* Incomplete sequence */ |
{ |
nread += n; |
width -= 1; |
if (!(flags & SUPPRESS)) |
wcp += 1; |
n = 0; |
} |
if (BufferEmpty) |
{ |
if (n != 0) |
goto input_failure; |
break; |
} |
} |
if (!(flags & SUPPRESS)) |
nassigned++; |
} |
else |
#endif |
if (flags & SUPPRESS) |
{ |
size_t sum = 0; |
for (;;) |
{ |
if ((n = fp->_r) < (int)width) |
{ |
sum += n; |
width -= n; |
fp->_p += n; |
if (__srefill_r (rptr, fp)) |
{ |
if (sum == 0) |
goto input_failure; |
break; |
} |
} |
else |
{ |
sum += width; |
fp->_r -= width; |
fp->_p += width; |
break; |
} |
} |
nread += sum; |
} |
else |
{ |
size_t r = _fread_r (rptr, (_PTR) GET_ARG (N, ap, char *), 1, width, fp); |
if (r == 0) |
goto input_failure; |
nread += r; |
nassigned++; |
} |
break; |
case CT_CCL: |
/* scan a (nonempty) character class (sets NOSKIP) */ |
if (width == 0) |
width = ~0; /* `infinity' */ |
/* take only those things in the class */ |
if (flags & SUPPRESS) |
{ |
n = 0; |
while (ccltab[*fp->_p]) |
{ |
n++, fp->_r--, fp->_p++; |
if (--width == 0) |
break; |
if (BufferEmpty) |
{ |
if (n == 0) |
goto input_failure; |
break; |
} |
} |
if (n == 0) |
goto match_failure; |
} |
else |
{ |
p0 = p = GET_ARG (N, ap, char *); |
while (ccltab[*fp->_p]) |
{ |
fp->_r--; |
*p++ = *fp->_p++; |
if (--width == 0) |
break; |
if (BufferEmpty) |
{ |
if (p == p0) |
goto input_failure; |
break; |
} |
} |
n = p - p0; |
if (n == 0) |
goto match_failure; |
*p = 0; |
nassigned++; |
} |
nread += n; |
break; |
case CT_STRING: |
/* like CCL, but zero-length string OK, & no NOSKIP */ |
if (width == 0) |
width = (size_t)~0; |
#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 2 |
if (flags & LONG) |
{ |
/* Process %S and %ls placeholders */ |
mbstate_t state; |
memset (&state, 0, sizeof (mbstate_t)); |
if ((flags & SUPPRESS) == 0) |
wcp = GET_ARG (N, ap, wchar_t *); |
else |
wcp = &wc; |
n = 0; |
while (!isspace (*fp->_p) && width != 0) |
{ |
if (n == MB_CUR_MAX) |
goto input_failure; |
buf[n++] = *fp->_p; |
fp->_r -= 1; |
fp->_p += 1; |
if ((mbslen = _mbrtowc_r (rptr, wcp, buf, n, &state)) |
== (size_t)-1) |
goto input_failure; |
if (mbslen == 0) |
*wcp = L'\0'; |
if (mbslen != (size_t)-2) /* Incomplete sequence */ |
{ |
if (iswspace(*wcp)) |
{ |
while (n != 0) |
_ungetc_r (rptr, (unsigned char) buf[--n], fp); |
break; |
} |
nread += n; |
width -= 1; |
if ((flags & SUPPRESS) == 0) |
wcp += 1; |
n = 0; |
} |
if (BufferEmpty) |
{ |
if (n != 0) |
goto input_failure; |
break; |
} |
} |
if (!(flags & SUPPRESS)) |
{ |
*wcp = L'\0'; |
nassigned++; |
} |
} |
else |
#endif |
if (flags & SUPPRESS) |
{ |
n = 0; |
while (!isspace (*fp->_p)) |
{ |
n++, fp->_r--, fp->_p++; |
if (--width == 0) |
break; |
if (BufferEmpty) |
break; |
} |
nread += n; |
} |
else |
{ |
p0 = p = GET_ARG (N, ap, char *); |
while (!isspace (*fp->_p)) |
{ |
fp->_r--; |
*p++ = *fp->_p++; |
if (--width == 0) |
break; |
if (BufferEmpty) |
break; |
} |
*p = 0; |
nread += p - p0; |
nassigned++; |
} |
continue; |
case CT_INT: |
{ |
/* scan an integer as if by strtol/strtoul */ |
unsigned width_left = 0; |
int skips = 0; |
#ifdef hardway |
if (width == 0 || width > sizeof (buf) - 1) |
#else |
/* size_t is unsigned, hence this optimisation */ |
if (width - 1 > sizeof (buf) - 2) |
#endif |
{ |
width_left = width - (sizeof (buf) - 1); |
width = sizeof (buf) - 1; |
} |
flags |= SIGNOK | NDIGITS | NZDIGITS | NNZDIGITS; |
for (p = buf; width; width--) |
{ |
c = *fp->_p; |
/* |
* Switch on the character; `goto ok' if we |
* accept it as a part of number. |
*/ |
switch (c) |
{ |
/* |
* The digit 0 is always legal, but is special. |
* For %i conversions, if no digits (zero or nonzero) |
* have been scanned (only signs), we will have base==0. |
* In that case, we should set it to 8 and enable 0x |
* prefixing. Also, if we have not scanned zero digits |
* before this, do not turn off prefixing (someone else |
* will turn it off if we have scanned any nonzero digits). |
*/ |
case '0': |
if (! (flags & NNZDIGITS)) |
goto ok; |
if (base == 0) |
{ |
base = 8; |
flags |= PFXOK; |
} |
if (flags & NZDIGITS) |
{ |
flags &= ~(SIGNOK | NZDIGITS | NDIGITS); |
goto ok; |
} |
flags &= ~(SIGNOK | PFXOK | NDIGITS); |
if (width_left) |
{ |
width_left--; |
width++; |
} |
++skips; |
goto skip; |
/* 1 through 7 always legal */ |
case '1': |
case '2': |
case '3': |
case '4': |
case '5': |
case '6': |
case '7': |
base = basefix[base]; |
flags &= ~(SIGNOK | PFXOK | NDIGITS | NNZDIGITS); |
goto ok; |
/* digits 8 and 9 ok iff decimal or hex */ |
case '8': |
case '9': |
base = basefix[base]; |
if (base <= 8) |
break; /* not legal here */ |
flags &= ~(SIGNOK | PFXOK | NDIGITS | NNZDIGITS); |
goto ok; |
/* letters ok iff hex */ |
case 'A': |
case 'B': |
case 'C': |
case 'D': |
case 'E': |
case 'F': |
case 'a': |
case 'b': |
case 'c': |
case 'd': |
case 'e': |
case 'f': |
/* no need to fix base here */ |
if (base <= 10) |
break; /* not legal here */ |
flags &= ~(SIGNOK | PFXOK | NDIGITS | NNZDIGITS); |
goto ok; |
/* sign ok only as first character */ |
case '+': |
case '-': |
if (flags & SIGNOK) |
{ |
flags &= ~SIGNOK; |
goto ok; |
} |
break; |
/* x ok iff flag still set & single 0 seen */ |
case 'x': |
case 'X': |
if ((flags & (PFXOK | NZDIGITS)) == PFXOK) |
{ |
base = 16;/* if %i */ |
flags &= ~PFXOK; |
/* We must reset the NZDIGITS and NDIGITS |
flags that would have been unset by seeing |
the zero that preceded the X or x. */ |
flags |= NZDIGITS | NDIGITS; |
goto ok; |
} |
break; |
} |
/* |
* If we got here, c is not a legal character |
* for a number. Stop accumulating digits. |
*/ |
break; |
ok: |
/* |
* c is legal: store it and look at the next. |
*/ |
*p++ = c; |
skip: |
if (--fp->_r > 0) |
fp->_p++; |
else |
if (__srefill_r (rptr, fp)) |
break; /* EOF */ |
} |
/* |
* If we had only a sign, it is no good; push back the sign. |
* If the number ends in `x', it was [sign] '0' 'x', so push back |
* the x and treat it as [sign] '0'. |
* Use of ungetc here and below assumes ASCII encoding; we are only |
* pushing back 7-bit characters, so casting to unsigned char is |
* not necessary. |
*/ |
if (flags & NDIGITS) |
{ |
if (p > buf) |
_ungetc_r (rptr, *--p, fp); /* [-+xX] */ |
if (p == buf) |
goto match_failure; |
} |
if ((flags & SUPPRESS) == 0) |
{ |
u_long res; |
*p = 0; |
res = (*ccfn) (rptr, buf, (char **) NULL, base); |
if (flags & POINTER) |
{ |
void **vp = GET_ARG (N, ap, void **); |
#ifndef _NO_LONGLONG |
if (sizeof (uintptr_t) > sizeof (u_long)) |
{ |
u_long_long resll; |
resll = _strtoull_r (rptr, buf, (char **) NULL, base); |
*vp = (void *) (uintptr_t) resll; |
} |
else |
#endif /* !_NO_LONGLONG */ |
*vp = (void *) (uintptr_t) res; |
} |
#ifdef _WANT_IO_C99_FORMATS |
else if (flags & CHAR) |
{ |
cp = GET_ARG (N, ap, char *); |
*cp = res; |
} |
#endif |
else if (flags & SHORT) |
{ |
sp = GET_ARG (N, ap, short *); |
*sp = res; |
} |
else if (flags & LONG) |
{ |
lp = GET_ARG (N, ap, long *); |
*lp = res; |
} |
#ifndef _NO_LONGLONG |
else if (flags & LONGDBL) |
{ |
u_long_long resll; |
if (ccfn == _strtoul_r) |
resll = _strtoull_r (rptr, buf, (char **) NULL, base); |
else |
resll = _strtoll_r (rptr, buf, (char **) NULL, base); |
llp = GET_ARG (N, ap, long long*); |
*llp = resll; |
} |
#endif |
else |
{ |
ip = GET_ARG (N, ap, int *); |
*ip = res; |
} |
nassigned++; |
} |
nread += p - buf + skips; |
break; |
} |
#ifdef FLOATING_POINT |
case CT_FLOAT: |
{ |
/* scan a floating point number as if by strtod */ |
/* This code used to assume that the number of digits is reasonable. |
However, ANSI / ISO C makes no such stipulation; we have to get |
exact results even when there is an unreasonable amount of |
leading zeroes. */ |
long leading_zeroes = 0; |
long zeroes, exp_adjust; |
char *exp_start = NULL; |
unsigned width_left = 0; |
char nancount = 0; |
char infcount = 0; |
#ifdef hardway |
if (width == 0 || width > sizeof (buf) - 1) |
#else |
/* size_t is unsigned, hence this optimisation */ |
if (width - 1 > sizeof (buf) - 2) |
#endif |
{ |
width_left = width - (sizeof (buf) - 1); |
width = sizeof (buf) - 1; |
} |
flags |= SIGNOK | NDIGITS | DPTOK | EXPOK; |
zeroes = 0; |
exp_adjust = 0; |
for (p = buf; width; ) |
{ |
c = *fp->_p; |
/* |
* This code mimicks the integer conversion |
* code, but is much simpler. |
*/ |
switch (c) |
{ |
case '0': |
if (flags & NDIGITS) |
{ |
flags &= ~SIGNOK; |
zeroes++; |
if (width_left) |
{ |
width_left--; |
width++; |
} |
goto fskip; |
} |
/* Fall through. */ |
case '1': |
case '2': |
case '3': |
case '4': |
case '5': |
case '6': |
case '7': |
case '8': |
case '9': |
if (nancount + infcount == 0) |
{ |
flags &= ~(SIGNOK | NDIGITS); |
goto fok; |
} |
break; |
case '+': |
case '-': |
if (flags & SIGNOK) |
{ |
flags &= ~SIGNOK; |
goto fok; |
} |
break; |
case 'n': |
case 'N': |
if (nancount == 0 && zeroes == 0 |
&& (flags & (NDIGITS | DPTOK | EXPOK)) == |
(NDIGITS | DPTOK | EXPOK)) |
{ |
flags &= ~(SIGNOK | DPTOK | EXPOK | NDIGITS); |
nancount = 1; |
goto fok; |
} |
if (nancount == 2) |
{ |
nancount = 3; |
goto fok; |
} |
if (infcount == 1 || infcount == 4) |
{ |
infcount++; |
goto fok; |
} |
break; |
case 'a': |
case 'A': |
if (nancount == 1) |
{ |
nancount = 2; |
goto fok; |
} |
break; |
case 'i': |
case 'I': |
if (infcount == 0 && zeroes == 0 |
&& (flags & (NDIGITS | DPTOK | EXPOK)) == |
(NDIGITS | DPTOK | EXPOK)) |
{ |
flags &= ~(SIGNOK | DPTOK | EXPOK | NDIGITS); |
infcount = 1; |
goto fok; |
} |
if (infcount == 3 || infcount == 5) |
{ |
infcount++; |
goto fok; |
} |
break; |
case 'f': |
case 'F': |
if (infcount == 2) |
{ |
infcount = 3; |
goto fok; |
} |
break; |
case 't': |
case 'T': |
if (infcount == 6) |
{ |
infcount = 7; |
goto fok; |
} |
break; |
case 'y': |
case 'Y': |
if (infcount == 7) |
{ |
infcount = 8; |
goto fok; |
} |
break; |
case '.': |
if (flags & DPTOK) |
{ |
flags &= ~(SIGNOK | DPTOK); |
leading_zeroes = zeroes; |
goto fok; |
} |
break; |
case 'e': |
case 'E': |
/* no exponent without some digits */ |
if ((flags & (NDIGITS | EXPOK)) == EXPOK |
|| ((flags & EXPOK) && zeroes)) |
{ |
if (! (flags & DPTOK)) |
{ |
exp_adjust = zeroes - leading_zeroes; |
exp_start = p; |
} |
flags = |
(flags & ~(EXPOK | DPTOK)) | |
SIGNOK | NDIGITS; |
zeroes = 0; |
goto fok; |
} |
break; |
} |
break; |
fok: |
*p++ = c; |
fskip: |
width--; |
++nread; |
if (--fp->_r > 0) |
fp->_p++; |
else |
if (__srefill_r (rptr, fp)) |
break; /* EOF */ |
} |
if (zeroes) |
flags &= ~NDIGITS; |
/* We may have a 'N' or possibly even [sign] 'N' 'a' as the |
start of 'NaN', only to run out of chars before it was |
complete (or having encountered a non-matching char). So |
check here if we have an outstanding nancount, and if so |
put back the chars we did swallow and treat as a failed |
match. |
FIXME - we still don't handle NAN([0xdigits]). */ |
if (nancount - 1U < 2U) /* nancount && nancount < 3 */ |
{ |
/* Newlib's ungetc works even if we called __srefill in |
the middle of a partial parse, but POSIX does not |
guarantee that in all implementations of ungetc. */ |
while (p > buf) |
{ |
_ungetc_r (rptr, *--p, fp); /* [-+nNaA] */ |
--nread; |
} |
goto match_failure; |
} |
/* Likewise for 'inf' and 'infinity'. But be careful that |
'infinite' consumes only 3 characters, leaving the stream |
at the second 'i'. */ |
if (infcount - 1U < 7U) /* infcount && infcount < 8 */ |
{ |
if (infcount >= 3) /* valid 'inf', but short of 'infinity' */ |
while (infcount-- > 3) |
{ |
_ungetc_r (rptr, *--p, fp); /* [iInNtT] */ |
--nread; |
} |
else |
{ |
while (p > buf) |
{ |
_ungetc_r (rptr, *--p, fp); /* [-+iInN] */ |
--nread; |
} |
goto match_failure; |
} |
} |
/* |
* If no digits, might be missing exponent digits |
* (just give back the exponent) or might be missing |
* regular digits, but had sign and/or decimal point. |
*/ |
if (flags & NDIGITS) |
{ |
if (flags & EXPOK) |
{ |
/* no digits at all */ |
while (p > buf) |
{ |
_ungetc_r (rptr, *--p, fp); /* [-+.] */ |
--nread; |
} |
goto match_failure; |
} |
/* just a bad exponent (e and maybe sign) */ |
c = *--p; |
--nread; |
if (c != 'e' && c != 'E') |
{ |
_ungetc_r (rptr, c, fp); /* [-+] */ |
c = *--p; |
--nread; |
} |
_ungetc_r (rptr, c, fp); /* [eE] */ |
} |
if ((flags & SUPPRESS) == 0) |
{ |
double res = 0; |
#ifdef _NO_LONGDBL |
#define QUAD_RES res; |
#else /* !_NO_LONG_DBL */ |
long double qres = 0; |
#define QUAD_RES qres; |
#endif /* !_NO_LONG_DBL */ |
long new_exp = 0; |
*p = 0; |
if ((flags & (DPTOK | EXPOK)) == EXPOK) |
{ |
exp_adjust = zeroes - leading_zeroes; |
new_exp = -exp_adjust; |
exp_start = p; |
} |
else if (exp_adjust) |
new_exp = _strtol_r (rptr, (exp_start + 1), NULL, 10) - exp_adjust; |
if (exp_adjust) |
{ |
/* If there might not be enough space for the new exponent, |
truncate some trailing digits to make room. */ |
if (exp_start >= buf + sizeof (buf) - MAX_LONG_LEN) |
exp_start = buf + sizeof (buf) - MAX_LONG_LEN - 1; |
sprintf (exp_start, "e%ld", new_exp); |
} |
/* Current _strtold routine is markedly slower than |
_strtod_r. Only use it if we have a long double |
result. */ |
#ifndef _NO_LONGDBL /* !_NO_LONGDBL */ |
if (flags & LONGDBL) |
qres = _strtold (buf, NULL); |
else |
#endif |
res = _strtod_r (rptr, buf, NULL); |
if (flags & LONG) |
{ |
dp = GET_ARG (N, ap, double *); |
*dp = res; |
} |
else if (flags & LONGDBL) |
{ |
ldp = GET_ARG (N, ap, _LONG_DOUBLE *); |
*ldp = QUAD_RES; |
} |
else |
{ |
flp = GET_ARG (N, ap, float *); |
if (isnan (res)) |
*flp = nanf (NULL); |
else |
*flp = res; |
} |
nassigned++; |
} |
break; |
} |
#endif /* FLOATING_POINT */ |
} |
} |
input_failure: |
/* On read failure, return EOF failure regardless of matches; errno |
should have been set prior to here. On EOF failure (including |
invalid format string), return EOF if no matches yet, else number |
of matches made prior to failure. */ |
_funlockfile (fp); |
return nassigned && !(fp->_flags & __SERR) ? nassigned : EOF; |
match_failure: |
all_done: |
/* Return number of matches, which can be 0 on match failure. */ |
_funlockfile (fp); |
return nassigned; |
} |
#ifndef _NO_POS_ARGS |
/* Process all intermediate arguments. Fortunately, with scanf, all |
intermediate arguments are sizeof(void*), so we don't need to scan |
ahead in the format string. */ |
static void * |
get_arg (int n, va_list *ap, int *numargs_p, void **args) |
{ |
int numargs = *numargs_p; |
while (n >= numargs) |
args[numargs++] = va_arg (*ap, void *); |
*numargs_p = numargs; |
return args[n]; |
} |
#endif /* !_NO_POS_ARGS */ |
/contrib/sdk/sources/libc/stdio/vscanf.c |
---|
0,0 → 1,52 |
/*- |
* Code created by modifying scanf.c which has following copyright. |
* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include "local.h" |
#ifndef _REENT_ONLY |
int |
_DEFUN(vscanf, (fmt, ap), |
_CONST char *fmt _AND |
va_list ap) |
{ |
_REENT_SMALL_CHECK_INIT (_REENT); |
return __svfscanf_r (_REENT, _stdin_r (_REENT), fmt, ap); |
} |
#endif /* !_REENT_ONLY */ |
int |
_DEFUN(_vscanf_r, (ptr, fmt, ap), |
struct _reent *ptr _AND |
_CONST char *fmt _AND |
va_list ap) |
{ |
_REENT_SMALL_CHECK_INIT (ptr); |
return __svfscanf_r (ptr, _stdin_r (ptr), fmt, ap); |
} |
/contrib/sdk/sources/libc/stdio/vsnprintf.c |
---|
0,0 → 1,72 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in vfprintf.c */ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <limits.h> |
#include <stdarg.h> |
#include <errno.h> |
#include "local.h" |
#ifndef _REENT_ONLY |
int |
_DEFUN(vsnprintf, (str, size, fmt, ap), |
char *str _AND |
size_t size _AND |
const char *fmt _AND |
va_list ap) |
{ |
return _vsnprintf_r (_REENT, str, size, fmt, ap); |
} |
#endif /* !_REENT_ONLY */ |
int |
_DEFUN(_vsnprintf_r, (ptr, str, size, fmt, ap), |
struct _reent *ptr _AND |
char *str _AND |
size_t size _AND |
const char *fmt _AND |
va_list ap) |
{ |
int ret; |
FILE f; |
if (size > INT_MAX) |
{ |
ptr->_errno = EOVERFLOW; |
return EOF; |
} |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = (size > 0 ? size - 1 : 0); |
f._file = -1; /* No file. */ |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
if (ret < EOF) |
ptr->_errno = EOVERFLOW; |
if (size > 0) |
*f._p = 0; |
return ret; |
} |
/contrib/sdk/sources/libc/stdio/vsprintf.c |
---|
0,0 → 1,61 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* doc in vfprintf.c */ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <limits.h> |
#include <stdarg.h> |
#include "local.h" |
#ifndef _REENT_ONLY |
int |
_DEFUN(vsprintf, (str, fmt, ap), |
char *str _AND |
const char *fmt _AND |
va_list ap) |
{ |
return _vsprintf_r (_REENT, str, fmt, ap); |
} |
#endif /* !_REENT_ONLY */ |
int |
_DEFUN(_vsprintf_r, (ptr, str, fmt, ap), |
struct _reent *ptr _AND |
char *str _AND |
const char *fmt _AND |
va_list ap) |
{ |
int ret; |
FILE f; |
f._flags = __SWR | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._w = INT_MAX; |
f._file = -1; /* No file. */ |
ret = _svfprintf_r (ptr, &f, fmt, ap); |
*f._p = 0; |
return ret; |
} |
/contrib/sdk/sources/libc/stdio/vsscanf.c |
---|
0,0 → 1,65 |
/* |
* Code created by modifying scanf.c which has following copyright. |
* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
#include <_ansi.h> |
#include <reent.h> |
#include <stdio.h> |
#include <string.h> |
#ifdef _HAVE_STDC |
#include <stdarg.h> |
#else |
#include <varargs.h> |
#endif |
#include "local.h" |
/* |
* vsscanf |
*/ |
#ifndef _REENT_ONLY |
int |
_DEFUN(vsscanf, (str, fmt, ap), |
_CONST char *str _AND |
_CONST char *fmt _AND |
va_list ap) |
{ |
return _vsscanf_r (_REENT, str, fmt, ap); |
} |
#endif /* !_REENT_ONLY */ |
int |
_DEFUN(_vsscanf_r, (ptr, str, fmt, ap), |
struct _reent *ptr _AND |
_CONST char *str _AND |
_CONST char *fmt _AND |
va_list ap) |
{ |
FILE f; |
f._flags = __SRD | __SSTR; |
f._bf._base = f._p = (unsigned char *) str; |
f._bf._size = f._r = strlen (str); |
f._read = __seofread; |
f._ub._base = NULL; |
f._lb._base = NULL; |
f._file = -1; /* No file. */ |
return __ssvfscanf_r (ptr, &f, fmt, ap); |
} |
/contrib/sdk/sources/libc/stdio/wbuf.c |
---|
0,0 → 1,96 |
/* |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
/* No user fns here. Pesch 15apr92. */ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "%W% (Berkeley) %G%"; |
#endif /* LIBC_SCCS and not lint */ |
#include <_ansi.h> |
#include <stdio.h> |
#include <errno.h> |
#include "local.h" |
#include "fvwrite.h" |
/* |
* Write the given character into the (probably full) buffer for |
* the given file. Flush the buffer out if it is or becomes full, |
* or if c=='\n' and the file is line buffered. |
*/ |
int |
_DEFUN(__swbuf_r, (ptr, c, fp), |
struct _reent *ptr _AND |
register int c _AND |
register FILE *fp) |
{ |
register int n; |
/* Ensure stdio has been initialized. */ |
CHECK_INIT (ptr, fp); |
/* |
* In case we cannot write, or longjmp takes us out early, |
* make sure _w is 0 (if fully- or un-buffered) or -_bf._size |
* (if line buffered) so that we will get called again. |
* If we did not do this, a sufficient number of putc() |
* calls might wrap _w from negative to positive. |
*/ |
fp->_w = fp->_lbfsize; |
if (cantwrite (ptr, fp)) |
return EOF; |
c = (unsigned char) c; |
ORIENT (fp, -1); |
/* |
* If it is completely full, flush it out. Then, in any case, |
* stuff c into the buffer. If this causes the buffer to fill |
* completely, or if c is '\n' and the file is line buffered, |
* flush it (perhaps a second time). The second flush will always |
* happen on unbuffered streams, where _bf._size==1; fflush() |
* guarantees that putc() will always call wbuf() by setting _w |
* to 0, so we need not do anything else. |
*/ |
n = fp->_p - fp->_bf._base; |
if (n >= fp->_bf._size) |
{ |
if (_fflush_r (ptr, fp)) |
return EOF; |
n = 0; |
} |
fp->_w--; |
*fp->_p++ = c; |
if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n')) |
if (_fflush_r (ptr, fp)) |
return EOF; |
return c; |
} |
/* This function isn't any longer declared in stdio.h, but it's |
required for backward compatibility with applications built against |
earlier dynamically built newlib libraries. */ |
int |
_DEFUN(__swbuf, (c, fp), |
register int c _AND |
register FILE *fp) |
{ |
return __swbuf_r (_REENT, c, fp); |
} |
/contrib/sdk/sources/libc/stdio/wsetup.c |
---|
0,0 → 1,94 |
/* No user fns here. Pesch 15apr92. */ |
/* |
* Copyright (c) 1990, 2007 The Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms are permitted |
* provided that the above copyright notice and this paragraph are |
* duplicated in all such forms and that any documentation, |
* advertising materials, and other materials related to such |
* distribution and use acknowledge that the software was developed |
* by the University of California, Berkeley. The name of the |
* University may not be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
*/ |
#include <_ansi.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <errno.h> |
#include "local.h" |
/* |
* Various output routines call wsetup to be sure it is safe to write, |
* because either _flags does not include __SWR, or _buf is NULL. |
* _wsetup returns 0 if OK to write, nonzero and set errno otherwise. |
*/ |
int |
_DEFUN(__swsetup_r, (ptr, fp), |
struct _reent *ptr _AND |
register FILE * fp) |
{ |
/* Make sure stdio is set up. */ |
CHECK_INIT (_REENT, fp); |
/* |
* If we are not writing, we had better be reading and writing. |
*/ |
if ((fp->_flags & __SWR) == 0) |
{ |
if ((fp->_flags & __SRW) == 0) |
{ |
ptr->_errno = EBADF; |
fp->_flags |= __SERR; |
return EOF; |
} |
if (fp->_flags & __SRD) |
{ |
/* clobber any ungetc data */ |
if (HASUB (fp)) |
FREEUB (ptr, fp); |
fp->_flags &= ~(__SRD | __SEOF); |
fp->_r = 0; |
fp->_p = fp->_bf._base; |
} |
fp->_flags |= __SWR; |
} |
/* |
* Make a buffer if necessary, then set _w. |
* A string I/O file should not explicitly allocate a buffer |
* unless asprintf is being used. |
*/ |
if (fp->_bf._base == NULL |
&& (!(fp->_flags & __SSTR) || (fp->_flags & __SMBF))) |
__smakebuf_r (ptr, fp); |
if (fp->_flags & __SLBF) |
{ |
/* |
* It is line buffered, so make _lbfsize be -_bufsize |
* for the putc() macro. We will change _lbfsize back |
* to 0 whenever we turn off __SWR. |
*/ |
fp->_w = 0; |
fp->_lbfsize = -fp->_bf._size; |
} |
else |
fp->_w = fp->_flags & __SNBF ? 0 : fp->_bf._size; |
if (!fp->_bf._base && (fp->_flags & __SMBF)) |
{ |
/* __smakebuf_r set errno, but not flag */ |
fp->_flags |= __SERR; |
return EOF; |
} |
return 0; |
} |
/contrib/sdk/sources/libc/string/local.h |
---|
0,0 → 1,9 |
#include <_ansi.h> |
#include <../ctype/local.h> |
/* internal function to compute width of wide char. */ |
int _EXFUN (__wcwidth, (wint_t)); |
/* Defined in locale/locale.c. Returns a value != 0 if the current |
language is assumed to use CJK fonts. */ |
int __locale_cjk_lang (); |
/contrib/sdk/sources/libc/string/memchr.c |
---|
0,0 → 1,134 |
/* |
FUNCTION |
<<memchr>>---find character in memory |
INDEX |
memchr |
ANSI_SYNOPSIS |
#include <string.h> |
void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
void *memchr(<[src]>, <[c]>, <[length]>) |
void *<[src]>; |
void *<[c]>; |
size_t <[length]>; |
DESCRIPTION |
This function searches memory starting at <<*<[src]>>> for the |
character <[c]>. The search only ends with the first |
occurrence of <[c]>, or after <[length]> characters; in |
particular, <<NUL>> does not terminate the search. |
RETURNS |
If the character <[c]> is found within <[length]> characters |
of <<*<[src]>>>, a pointer to the character is returned. If |
<[c]> is not found, then <<NULL>> is returned. |
PORTABILITY |
<<memchr>> is ANSI C. |
<<memchr>> requires no supporting OS subroutines. |
QUICKREF |
memchr ansi pure |
*/ |
#include <_ansi.h> |
#include <string.h> |
#include <limits.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X) ((long)X & (sizeof (long) - 1)) |
/* How many bytes are loaded each iteration of the word copy loop. */ |
#define LBLOCKSIZE (sizeof (long)) |
/* Threshhold for punting to the bytewise iterator. */ |
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
/* DETECTCHAR returns nonzero if (long)X contains the byte used |
to fill (long)MASK. */ |
#define DETECTCHAR(X,MASK) (DETECTNULL(X ^ MASK)) |
_PTR |
_DEFUN (memchr, (src_void, c, length), |
_CONST _PTR src_void _AND |
int c _AND |
size_t length) |
{ |
_CONST unsigned char *src = (_CONST unsigned char *) src_void; |
unsigned char d = c; |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
unsigned long *asrc; |
unsigned long mask; |
int i; |
while (UNALIGNED (src)) |
{ |
if (!length--) |
return NULL; |
if (*src == d) |
return (void *) src; |
src++; |
} |
if (!TOO_SMALL (length)) |
{ |
/* If we get this far, we know that length is large and src is |
word-aligned. */ |
/* The fast code reads the source one word at a time and only |
performs the bytewise search on word-sized segments if they |
contain the search character, which is detected by XORing |
the word-sized segment with a word-sized block of the search |
character and then detecting for the presence of NUL in the |
result. */ |
asrc = (unsigned long *) src; |
mask = d << 8 | d; |
mask = mask << 16 | mask; |
for (i = 32; i < LBLOCKSIZE * 8; i <<= 1) |
mask = (mask << i) | mask; |
while (length >= LBLOCKSIZE) |
{ |
if (DETECTCHAR (*asrc, mask)) |
break; |
length -= LBLOCKSIZE; |
asrc++; |
} |
/* If there are fewer than LBLOCKSIZE characters left, |
then we resort to the bytewise loop. */ |
src = (unsigned char *) asrc; |
} |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
while (length--) |
{ |
if (*src == d) |
return (void *) src; |
src++; |
} |
return NULL; |
} |
/contrib/sdk/sources/libc/string/memcmp.c |
---|
0,0 → 1,113 |
/* |
FUNCTION |
<<memcmp>>---compare two memory areas |
INDEX |
memcmp |
ANSI_SYNOPSIS |
#include <string.h> |
int memcmp(const void *<[s1]>, const void *<[s2]>, size_t <[n]>); |
TRAD_SYNOPSIS |
#include <string.h> |
int memcmp(<[s1]>, <[s2]>, <[n]>) |
void *<[s1]>; |
void *<[s2]>; |
size_t <[n]>; |
DESCRIPTION |
This function compares not more than <[n]> characters of the |
object pointed to by <[s1]> with the object pointed to by <[s2]>. |
RETURNS |
The function returns an integer greater than, equal to or |
less than zero according to whether the object pointed to by |
<[s1]> is greater than, equal to or less than the object |
pointed to by <[s2]>. |
PORTABILITY |
<<memcmp>> is ANSI C. |
<<memcmp>> requires no supporting OS subroutines. |
QUICKREF |
memcmp ansi pure |
*/ |
#include <string.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
/* How many bytes are copied each iteration of the word copy loop. */ |
#define LBLOCKSIZE (sizeof (long)) |
/* Threshhold for punting to the byte copier. */ |
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE) |
int |
_DEFUN (memcmp, (m1, m2, n), |
_CONST _PTR m1 _AND |
_CONST _PTR m2 _AND |
size_t n) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
unsigned char *s1 = (unsigned char *) m1; |
unsigned char *s2 = (unsigned char *) m2; |
while (n--) |
{ |
if (*s1 != *s2) |
{ |
return *s1 - *s2; |
} |
s1++; |
s2++; |
} |
return 0; |
#else |
unsigned char *s1 = (unsigned char *) m1; |
unsigned char *s2 = (unsigned char *) m2; |
unsigned long *a1; |
unsigned long *a2; |
/* If the size is too small, or either pointer is unaligned, |
then we punt to the byte compare loop. Hopefully this will |
not turn up in inner loops. */ |
if (!TOO_SMALL(n) && !UNALIGNED(s1,s2)) |
{ |
/* Otherwise, load and compare the blocks of memory one |
word at a time. */ |
a1 = (unsigned long*) s1; |
a2 = (unsigned long*) s2; |
while (n >= LBLOCKSIZE) |
{ |
if (*a1 != *a2) |
break; |
a1++; |
a2++; |
n -= LBLOCKSIZE; |
} |
/* check m mod LBLOCKSIZE remaining characters */ |
s1 = (unsigned char*)a1; |
s2 = (unsigned char*)a2; |
} |
while (n--) |
{ |
if (*s1 != *s2) |
return *s1 - *s2; |
s1++; |
s2++; |
} |
return 0; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/contrib/sdk/sources/libc/string/memcpy.c |
---|
0,0 → 1,110 |
/* |
FUNCTION |
<<memcpy>>---copy memory regions |
ANSI_SYNOPSIS |
#include <string.h> |
void* memcpy(void *<[out]>, const void *<[in]>, size_t <[n]>); |
TRAD_SYNOPSIS |
#include <string.h> |
void *memcpy(<[out]>, <[in]>, <[n]> |
void *<[out]>; |
void *<[in]>; |
size_t <[n]>; |
DESCRIPTION |
This function copies <[n]> bytes from the memory region |
pointed to by <[in]> to the memory region pointed to by |
<[out]>. |
If the regions overlap, the behavior is undefined. |
RETURNS |
<<memcpy>> returns a pointer to the first byte of the <[out]> |
region. |
PORTABILITY |
<<memcpy>> is ANSI C. |
<<memcpy>> requires no supporting OS subroutines. |
QUICKREF |
memcpy ansi pure |
*/ |
#include <_ansi.h> |
#include <string.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
/* How many bytes are copied each iteration of the 4X unrolled loop. */ |
#define BIGBLOCKSIZE (sizeof (long) << 2) |
/* How many bytes are copied each iteration of the word copy loop. */ |
#define LITTLEBLOCKSIZE (sizeof (long)) |
/* Threshhold for punting to the byte copier. */ |
#define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE) |
_PTR |
_DEFUN (memcpy, (dst0, src0, len0), |
_PTR dst0 _AND |
_CONST _PTR src0 _AND |
size_t len0) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
char *dst = (char *) dst0; |
char *src = (char *) src0; |
_PTR save = dst0; |
while (len0--) |
{ |
*dst++ = *src++; |
} |
return save; |
#else |
char *dst = dst0; |
_CONST char *src = src0; |
long *aligned_dst; |
_CONST long *aligned_src; |
/* If the size is small, or either SRC or DST is unaligned, |
then punt into the byte copy loop. This should be rare. */ |
if (!TOO_SMALL(len0) && !UNALIGNED (src, dst)) |
{ |
aligned_dst = (long*)dst; |
aligned_src = (long*)src; |
/* Copy 4X long words at a time if possible. */ |
while (len0 >= BIGBLOCKSIZE) |
{ |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
len0 -= BIGBLOCKSIZE; |
} |
/* Copy one long word at a time if possible. */ |
while (len0 >= LITTLEBLOCKSIZE) |
{ |
*aligned_dst++ = *aligned_src++; |
len0 -= LITTLEBLOCKSIZE; |
} |
/* Pick up any residual with a byte copier. */ |
dst = (char*)aligned_dst; |
src = (char*)aligned_src; |
} |
while (len0--) |
*dst++ = *src++; |
return dst0; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/contrib/sdk/sources/libc/string/memmove.c |
---|
0,0 → 1,142 |
/* |
FUNCTION |
<<memmove>>---move possibly overlapping memory |
INDEX |
memmove |
ANSI_SYNOPSIS |
#include <string.h> |
void *memmove(void *<[dst]>, const void *<[src]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
void *memmove(<[dst]>, <[src]>, <[length]>) |
void *<[dst]>; |
void *<[src]>; |
size_t <[length]>; |
DESCRIPTION |
This function moves <[length]> characters from the block of |
memory starting at <<*<[src]>>> to the memory starting at |
<<*<[dst]>>>. <<memmove>> reproduces the characters correctly |
at <<*<[dst]>>> even if the two areas overlap. |
RETURNS |
The function returns <[dst]> as passed. |
PORTABILITY |
<<memmove>> is ANSI C. |
<<memmove>> requires no supporting OS subroutines. |
QUICKREF |
memmove ansi pure |
*/ |
#include <string.h> |
#include <_ansi.h> |
#include <stddef.h> |
#include <limits.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
/* How many bytes are copied each iteration of the 4X unrolled loop. */ |
#define BIGBLOCKSIZE (sizeof (long) << 2) |
/* How many bytes are copied each iteration of the word copy loop. */ |
#define LITTLEBLOCKSIZE (sizeof (long)) |
/* Threshhold for punting to the byte copier. */ |
#define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE) |
/*SUPPRESS 20*/ |
_PTR |
_DEFUN (memmove, (dst_void, src_void, length), |
_PTR dst_void _AND |
_CONST _PTR src_void _AND |
size_t length) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
char *dst = dst_void; |
_CONST char *src = src_void; |
if (src < dst && dst < src + length) |
{ |
/* Have to copy backwards */ |
src += length; |
dst += length; |
while (length--) |
{ |
*--dst = *--src; |
} |
} |
else |
{ |
while (length--) |
{ |
*dst++ = *src++; |
} |
} |
return dst_void; |
#else |
char *dst = dst_void; |
_CONST char *src = src_void; |
long *aligned_dst; |
_CONST long *aligned_src; |
if (src < dst && dst < src + length) |
{ |
/* Destructive overlap...have to copy backwards */ |
src += length; |
dst += length; |
while (length--) |
{ |
*--dst = *--src; |
} |
} |
else |
{ |
/* Use optimizing algorithm for a non-destructive copy to closely |
match memcpy. If the size is small or either SRC or DST is unaligned, |
then punt into the byte copy loop. This should be rare. */ |
if (!TOO_SMALL(length) && !UNALIGNED (src, dst)) |
{ |
aligned_dst = (long*)dst; |
aligned_src = (long*)src; |
/* Copy 4X long words at a time if possible. */ |
while (length >= BIGBLOCKSIZE) |
{ |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
*aligned_dst++ = *aligned_src++; |
length -= BIGBLOCKSIZE; |
} |
/* Copy one long word at a time if possible. */ |
while (length >= LITTLEBLOCKSIZE) |
{ |
*aligned_dst++ = *aligned_src++; |
length -= LITTLEBLOCKSIZE; |
} |
/* Pick up any residual with a byte copier. */ |
dst = (char*)aligned_dst; |
src = (char*)aligned_src; |
} |
while (length--) |
{ |
*dst++ = *src++; |
} |
} |
return dst_void; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/contrib/sdk/sources/libc/string/memset.c |
---|
0,0 → 1,102 |
/* |
FUNCTION |
<<memset>>---set an area of memory |
INDEX |
memset |
ANSI_SYNOPSIS |
#include <string.h> |
void *memset(void *<[dst]>, int <[c]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
void *memset(<[dst]>, <[c]>, <[length]>) |
void *<[dst]>; |
int <[c]>; |
size_t <[length]>; |
DESCRIPTION |
This function converts the argument <[c]> into an unsigned |
char and fills the first <[length]> characters of the array |
pointed to by <[dst]> to the value. |
RETURNS |
<<memset>> returns the value of <[dst]>. |
PORTABILITY |
<<memset>> is ANSI C. |
<<memset>> requires no supporting OS subroutines. |
QUICKREF |
memset ansi pure |
*/ |
#include <string.h> |
#define LBLOCKSIZE (sizeof(long)) |
#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1)) |
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE) |
_PTR |
_DEFUN (memset, (m, c, n), |
_PTR m _AND |
int c _AND |
size_t n) |
{ |
char *s = (char *) m; |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
int i; |
unsigned long buffer; |
unsigned long *aligned_addr; |
unsigned int d = c & 0xff; /* To avoid sign extension, copy C to an |
unsigned variable. */ |
while (UNALIGNED (s)) |
{ |
if (n--) |
*s++ = (char) c; |
else |
return m; |
} |
if (!TOO_SMALL (n)) |
{ |
/* If we get this far, we know that n is large and s is word-aligned. */ |
aligned_addr = (unsigned long *) s; |
/* Store D into each char sized location in BUFFER so that |
we can set large blocks quickly. */ |
buffer = (d << 8) | d; |
buffer |= (buffer << 16); |
for (i = 32; i < LBLOCKSIZE * 8; i <<= 1) |
buffer = (buffer << i) | buffer; |
/* Unroll the loop. */ |
while (n >= LBLOCKSIZE*4) |
{ |
*aligned_addr++ = buffer; |
*aligned_addr++ = buffer; |
*aligned_addr++ = buffer; |
*aligned_addr++ = buffer; |
n -= 4*LBLOCKSIZE; |
} |
while (n >= LBLOCKSIZE) |
{ |
*aligned_addr++ = buffer; |
n -= LBLOCKSIZE; |
} |
/* Pick up the remainder with a bytewise loop. */ |
s = (char*)aligned_addr; |
} |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
while (n--) |
*s++ = (char) c; |
return m; |
} |
/contrib/sdk/sources/libc/string/stpcpy.c |
---|
0,0 → 1,91 |
/* |
FUNCTION |
<<stpcpy>>---copy string returning a pointer to its end |
INDEX |
stpcpy |
ANSI_SYNOPSIS |
#include <string.h> |
char *stpcpy(char *<[dst]>, const char *<[src]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *stpcpy(<[dst]>, <[src]>) |
char *<[dst]>; |
char *<[src]>; |
DESCRIPTION |
<<stpcpy>> copies the string pointed to by <[src]> |
(including the terminating null character) to the array |
pointed to by <[dst]>. |
RETURNS |
This function returns a pointer to the end of the destination string, |
thus pointing to the trailing '\0'. |
PORTABILITY |
<<stpcpy>> is a GNU extension, candidate for inclusion into POSIX/SUSv4. |
<<stpcpy>> requires no supporting OS subroutines. |
QUICKREF |
stpcpy gnu |
*/ |
#include <string.h> |
#include <limits.h> |
/*SUPPRESS 560*/ |
/*SUPPRESS 530*/ |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
char* |
_DEFUN (stpcpy, (dst, src), |
char *dst _AND |
_CONST char *src) |
{ |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
long *aligned_dst; |
_CONST long *aligned_src; |
/* If SRC or DEST is unaligned, then copy bytes. */ |
if (!UNALIGNED (src, dst)) |
{ |
aligned_dst = (long*)dst; |
aligned_src = (long*)src; |
/* SRC and DEST are both "long int" aligned, try to do "long int" |
sized copies. */ |
while (!DETECTNULL(*aligned_src)) |
{ |
*aligned_dst++ = *aligned_src++; |
} |
dst = (char*)aligned_dst; |
src = (char*)aligned_src; |
} |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
while ((*dst++ = *src++)) |
; |
return --dst; |
} |
/contrib/sdk/sources/libc/string/stpncpy.c |
---|
0,0 → 1,114 |
/* |
FUNCTION |
<<stpncpy>>---counted copy string returning a pointer to its end |
INDEX |
stpncpy |
ANSI_SYNOPSIS |
#include <string.h> |
char *stpncpy(char *<[dst]>, const char *<[src]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *stpncpy(<[dst]>, <[src]>, <[length]>) |
char *<[dst]>; |
char *<[src]>; |
size_t <[length]>; |
DESCRIPTION |
<<stpncpy>> copies not more than <[length]> characters from the |
the string pointed to by <[src]> (including the terminating |
null character) to the array pointed to by <[dst]>. If the |
string pointed to by <[src]> is shorter than <[length]> |
characters, null characters are appended to the destination |
array until a total of <[length]> characters have been |
written. |
RETURNS |
This function returns a pointer to the end of the destination string, |
thus pointing to the trailing '\0', or, if the destination string is |
not null-terminated, pointing to dst + n. |
PORTABILITY |
<<stpncpy>> is a GNU extension, candidate for inclusion into POSIX/SUSv4. |
<<stpncpy>> requires no supporting OS subroutines. |
QUICKREF |
stpncpy gnu |
*/ |
#include <string.h> |
#include <limits.h> |
/*SUPPRESS 560*/ |
/*SUPPRESS 530*/ |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
#define TOO_SMALL(LEN) ((LEN) < sizeof (long)) |
char * |
_DEFUN (stpncpy, (dst, src), |
char *dst _AND |
_CONST char *src _AND |
size_t count) |
{ |
char *ret = NULL; |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
long *aligned_dst; |
_CONST long *aligned_src; |
/* If SRC and DEST is aligned and count large enough, then copy words. */ |
if (!UNALIGNED (src, dst) && !TOO_SMALL (count)) |
{ |
aligned_dst = (long*)dst; |
aligned_src = (long*)src; |
/* SRC and DEST are both "long int" aligned, try to do "long int" |
sized copies. */ |
while (count >= sizeof (long int) && !DETECTNULL(*aligned_src)) |
{ |
count -= sizeof (long int); |
*aligned_dst++ = *aligned_src++; |
} |
dst = (char*)aligned_dst; |
src = (char*)aligned_src; |
} |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
while (count > 0) |
{ |
--count; |
if ((*dst++ = *src++) == '\0') |
{ |
ret = dst - 1; |
break; |
} |
} |
while (count-- > 0) |
*dst++ = '\0'; |
return ret ? ret : dst; |
} |
/contrib/sdk/sources/libc/string/str-two-way.h |
---|
0,0 → 1,415 |
/* Byte-wise substring search, using the Two-Way algorithm. |
* Copyright (C) 2008, 2010 Eric Blake |
* Permission to use, copy, modify, and distribute this software |
* is freely granted, provided that this notice is preserved. |
*/ |
/* Before including this file, you need to include <string.h>, and define: |
RESULT_TYPE A macro that expands to the return type. |
AVAILABLE(h, h_l, j, n_l) A macro that returns nonzero if there are |
at least N_L bytes left starting at |
H[J]. H is 'unsigned char *', H_L, J, |
and N_L are 'size_t'; H_L is an |
lvalue. For NUL-terminated searches, |
H_L can be modified each iteration to |
avoid having to compute the end of H |
up front. |
For case-insensitivity, you may optionally define: |
CMP_FUNC(p1, p2, l) A macro that returns 0 iff the first L |
characters of P1 and P2 are equal. |
CANON_ELEMENT(c) A macro that canonicalizes an element |
right after it has been fetched from |
one of the two strings. The argument |
is an 'unsigned char'; the result must |
be an 'unsigned char' as well. |
This file undefines the macros documented above, and defines |
LONG_NEEDLE_THRESHOLD. |
*/ |
#include <limits.h> |
#include <stdint.h> |
/* We use the Two-Way string matching algorithm, which guarantees |
linear complexity with constant space. Additionally, for long |
needles, we also use a bad character shift table similar to the |
Boyer-Moore algorithm to achieve improved (potentially sub-linear) |
performance. |
See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260 |
and http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm |
*/ |
/* Point at which computing a bad-byte shift table is likely to be |
worthwhile. Small needles should not compute a table, since it |
adds (1 << CHAR_BIT) + NEEDLE_LEN computations of preparation for a |
speedup no greater than a factor of NEEDLE_LEN. The larger the |
needle, the better the potential performance gain. On the other |
hand, on non-POSIX systems with CHAR_BIT larger than eight, the |
memory required for the table is prohibitive. */ |
#if CHAR_BIT < 10 |
# define LONG_NEEDLE_THRESHOLD 32U |
#else |
# define LONG_NEEDLE_THRESHOLD SIZE_MAX |
#endif |
#define MAX(a, b) ((a < b) ? (b) : (a)) |
#ifndef CANON_ELEMENT |
# define CANON_ELEMENT(c) c |
#endif |
#ifndef CMP_FUNC |
# define CMP_FUNC memcmp |
#endif |
/* Perform a critical factorization of NEEDLE, of length NEEDLE_LEN. |
Return the index of the first byte in the right half, and set |
*PERIOD to the global period of the right half. |
The global period of a string is the smallest index (possibly its |
length) at which all remaining bytes in the string are repetitions |
of the prefix (the last repetition may be a subset of the prefix). |
When NEEDLE is factored into two halves, a local period is the |
length of the smallest word that shares a suffix with the left half |
and shares a prefix with the right half. All factorizations of a |
non-empty NEEDLE have a local period of at least 1 and no greater |
than NEEDLE_LEN. |
A critical factorization has the property that the local period |
equals the global period. All strings have at least one critical |
factorization with the left half smaller than the global period. |
Given an ordered alphabet, a critical factorization can be computed |
in linear time, with 2 * NEEDLE_LEN comparisons, by computing the |
larger of two ordered maximal suffixes. The ordered maximal |
suffixes are determined by lexicographic comparison of |
periodicity. */ |
static size_t |
critical_factorization (const unsigned char *needle, size_t needle_len, |
size_t *period) |
{ |
/* Index of last byte of left half, or SIZE_MAX. */ |
size_t max_suffix, max_suffix_rev; |
size_t j; /* Index into NEEDLE for current candidate suffix. */ |
size_t k; /* Offset into current period. */ |
size_t p; /* Intermediate period. */ |
unsigned char a, b; /* Current comparison bytes. */ |
/* Invariants: |
0 <= j < NEEDLE_LEN - 1 |
-1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed) |
min(max_suffix, max_suffix_rev) < global period of NEEDLE |
1 <= p <= global period of NEEDLE |
p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] |
1 <= k <= p |
*/ |
/* Perform lexicographic search. */ |
max_suffix = SIZE_MAX; |
j = 0; |
k = p = 1; |
while (j + k < needle_len) |
{ |
a = CANON_ELEMENT (needle[j + k]); |
b = CANON_ELEMENT (needle[(size_t)(max_suffix + k)]); |
if (a < b) |
{ |
/* Suffix is smaller, period is entire prefix so far. */ |
j += k; |
k = 1; |
p = j - max_suffix; |
} |
else if (a == b) |
{ |
/* Advance through repetition of the current period. */ |
if (k != p) |
++k; |
else |
{ |
j += p; |
k = 1; |
} |
} |
else /* b < a */ |
{ |
/* Suffix is larger, start over from current location. */ |
max_suffix = j++; |
k = p = 1; |
} |
} |
*period = p; |
/* Perform reverse lexicographic search. */ |
max_suffix_rev = SIZE_MAX; |
j = 0; |
k = p = 1; |
while (j + k < needle_len) |
{ |
a = CANON_ELEMENT (needle[j + k]); |
b = CANON_ELEMENT (needle[max_suffix_rev + k]); |
if (b < a) |
{ |
/* Suffix is smaller, period is entire prefix so far. */ |
j += k; |
k = 1; |
p = j - max_suffix_rev; |
} |
else if (a == b) |
{ |
/* Advance through repetition of the current period. */ |
if (k != p) |
++k; |
else |
{ |
j += p; |
k = 1; |
} |
} |
else /* a < b */ |
{ |
/* Suffix is larger, start over from current location. */ |
max_suffix_rev = j++; |
k = p = 1; |
} |
} |
/* Choose the longer suffix. Return the first byte of the right |
half, rather than the last byte of the left half. */ |
if (max_suffix_rev + 1 < max_suffix + 1) |
return max_suffix + 1; |
*period = p; |
return max_suffix_rev + 1; |
} |
/* Return the first location of non-empty NEEDLE within HAYSTACK, or |
NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This |
method is optimized for NEEDLE_LEN < LONG_NEEDLE_THRESHOLD. |
Performance is guaranteed to be linear, with an initialization cost |
of 2 * NEEDLE_LEN comparisons. |
If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at |
most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. |
If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * |
HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ |
static RETURN_TYPE |
two_way_short_needle (const unsigned char *haystack, size_t haystack_len, |
const unsigned char *needle, size_t needle_len) |
{ |
size_t i; /* Index into current byte of NEEDLE. */ |
size_t j; /* Index into current window of HAYSTACK. */ |
size_t period; /* The period of the right half of needle. */ |
size_t suffix; /* The index of the right half of needle. */ |
/* Factor the needle into two halves, such that the left half is |
smaller than the global period, and the right half is |
periodic (with a period as large as NEEDLE_LEN - suffix). */ |
suffix = critical_factorization (needle, needle_len, &period); |
/* Perform the search. Each iteration compares the right half |
first. */ |
if (CMP_FUNC (needle, needle + period, suffix) == 0) |
{ |
/* Entire needle is periodic; a mismatch can only advance by the |
period, so use memory to avoid rescanning known occurrences |
of the period. */ |
size_t memory = 0; |
j = 0; |
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
{ |
/* Scan for matches in right half. */ |
i = MAX (suffix, memory); |
while (i < needle_len && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
++i; |
if (needle_len <= i) |
{ |
/* Scan for matches in left half. */ |
i = suffix - 1; |
while (memory < i + 1 && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
--i; |
if (i + 1 < memory + 1) |
return (RETURN_TYPE) (haystack + j); |
/* No match, so remember how many repetitions of period |
on the right half were scanned. */ |
j += period; |
memory = needle_len - period; |
} |
else |
{ |
j += i - suffix + 1; |
memory = 0; |
} |
} |
} |
else |
{ |
/* The two halves of needle are distinct; no extra memory is |
required, and any mismatch results in a maximal shift. */ |
period = MAX (suffix, needle_len - suffix) + 1; |
j = 0; |
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
{ |
/* Scan for matches in right half. */ |
i = suffix; |
while (i < needle_len && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
++i; |
if (needle_len <= i) |
{ |
/* Scan for matches in left half. */ |
i = suffix - 1; |
while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
--i; |
if (i == SIZE_MAX) |
return (RETURN_TYPE) (haystack + j); |
j += period; |
} |
else |
j += i - suffix + 1; |
} |
} |
return NULL; |
} |
/* Return the first location of non-empty NEEDLE within HAYSTACK, or |
NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This |
method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN. |
Performance is guaranteed to be linear, with an initialization cost |
of 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations. |
If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at |
most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, |
and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible. |
If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * |
HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and |
sublinear performance is not possible. */ |
static RETURN_TYPE |
two_way_long_needle (const unsigned char *haystack, size_t haystack_len, |
const unsigned char *needle, size_t needle_len) |
{ |
size_t i; /* Index into current byte of NEEDLE. */ |
size_t j; /* Index into current window of HAYSTACK. */ |
size_t period; /* The period of the right half of needle. */ |
size_t suffix; /* The index of the right half of needle. */ |
size_t shift_table[1U << CHAR_BIT]; /* See below. */ |
/* Factor the needle into two halves, such that the left half is |
smaller than the global period, and the right half is |
periodic (with a period as large as NEEDLE_LEN - suffix). */ |
suffix = critical_factorization (needle, needle_len, &period); |
/* Populate shift_table. For each possible byte value c, |
shift_table[c] is the distance from the last occurrence of c to |
the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE. |
shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */ |
for (i = 0; i < 1U << CHAR_BIT; i++) |
shift_table[i] = needle_len; |
for (i = 0; i < needle_len; i++) |
shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1; |
/* Perform the search. Each iteration compares the right half |
first. */ |
if (CMP_FUNC (needle, needle + period, suffix) == 0) |
{ |
/* Entire needle is periodic; a mismatch can only advance by the |
period, so use memory to avoid rescanning known occurrences |
of the period. */ |
size_t memory = 0; |
size_t shift; |
j = 0; |
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
{ |
/* Check the last byte first; if it does not match, then |
shift to the next possible match location. */ |
shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; |
if (0 < shift) |
{ |
if (memory && shift < period) |
{ |
/* Since needle is periodic, but the last period has |
a byte out of place, there can be no match until |
after the mismatch. */ |
shift = needle_len - period; |
} |
memory = 0; |
j += shift; |
continue; |
} |
/* Scan for matches in right half. The last byte has |
already been matched, by virtue of the shift table. */ |
i = MAX (suffix, memory); |
while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
++i; |
if (needle_len - 1 <= i) |
{ |
/* Scan for matches in left half. */ |
i = suffix - 1; |
while (memory < i + 1 && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
--i; |
if (i + 1 < memory + 1) |
return (RETURN_TYPE) (haystack + j); |
/* No match, so remember how many repetitions of period |
on the right half were scanned. */ |
j += period; |
memory = needle_len - period; |
} |
else |
{ |
j += i - suffix + 1; |
memory = 0; |
} |
} |
} |
else |
{ |
/* The two halves of needle are distinct; no extra memory is |
required, and any mismatch results in a maximal shift. */ |
size_t shift; |
period = MAX (suffix, needle_len - suffix) + 1; |
j = 0; |
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
{ |
/* Check the last byte first; if it does not match, then |
shift to the next possible match location. */ |
shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; |
if (0 < shift) |
{ |
j += shift; |
continue; |
} |
/* Scan for matches in right half. The last byte has |
already been matched, by virtue of the shift table. */ |
i = suffix; |
while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
++i; |
if (needle_len - 1 <= i) |
{ |
/* Scan for matches in left half. */ |
i = suffix - 1; |
while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) |
== CANON_ELEMENT (haystack[i + j]))) |
--i; |
if (i == SIZE_MAX) |
return (RETURN_TYPE) (haystack + j); |
j += period; |
} |
else |
j += i - suffix + 1; |
} |
} |
return NULL; |
} |
#undef AVAILABLE |
#undef CANON_ELEMENT |
#undef CMP_FUNC |
#undef MAX |
#undef RETURN_TYPE |
/contrib/sdk/sources/libc/string/strcasecmp.c |
---|
0,0 → 1,60 |
/* |
FUNCTION |
<<strcasecmp>>---case-insensitive character string compare |
INDEX |
strcasecmp |
ANSI_SYNOPSIS |
#include <strings.h> |
int strcasecmp(const char *<[a]>, const char *<[b]>); |
TRAD_SYNOPSIS |
#include <strings.h> |
int strcasecmp(<[a]>, <[b]>) |
char *<[a]>; |
char *<[b]>; |
DESCRIPTION |
<<strcasecmp>> compares the string at <[a]> to |
the string at <[b]> in a case-insensitive manner. |
RETURNS |
If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after |
both are converted to lowercase), <<strcasecmp>> returns a |
number greater than zero. If the two strings match, |
<<strcasecmp>> returns zero. If <<*<[a]>>> sorts |
lexicographically before <<*<[b]>>>, <<strcasecmp>> returns a |
number less than zero. |
PORTABILITY |
<<strcasecmp>> is in the Berkeley Software Distribution. |
<<strcasecmp>> requires no supporting OS subroutines. It uses |
tolower() from elsewhere in this library. |
QUICKREF |
strcasecmp |
*/ |
#include <strings.h> |
#include <ctype.h> |
int |
_DEFUN (strcasecmp, (s1, s2), |
_CONST char *s1 _AND |
_CONST char *s2) |
{ |
_CONST unsigned char *ucs1 = (_CONST unsigned char *) s1; |
_CONST unsigned char *ucs2 = (_CONST unsigned char *) s2; |
int d = 0; |
for ( ; ; ) |
{ |
_CONST int c1 = tolower(*ucs1++); |
_CONST int c2 = tolower(*ucs2++); |
if (((d = c1 - c2) != 0) || (c2 == '\0')) |
break; |
} |
return d; |
} |
/contrib/sdk/sources/libc/string/strcasestr.c |
---|
0,0 → 1,148 |
/* |
FUNCTION |
<<strcasestr>>---case-insensitive character string search |
INDEX |
strcasestr |
ANSI_SYNOPSIS |
#include <string.h> |
char *strcasestr(const char *<[s]>, const char *<[find]>); |
TRAD_SYNOPSIS |
#include <string.h> |
int strcasecmp(<[s]>, <[find]>) |
char *<[s]>; |
char *<[find]>; |
DESCRIPTION |
<<strcasestr>> searchs the string <[s]> for |
the first occurrence of the sequence <[find]>. <<strcasestr>> |
is identical to <<strstr>> except the search is |
case-insensitive. |
RETURNS |
A pointer to the first case-insensitive occurrence of the sequence |
<[find]> or <<NULL>> if no match was found. |
PORTABILITY |
<<strcasestr>> is in the Berkeley Software Distribution. |
<<strcasestr>> requires no supporting OS subroutines. It uses |
tolower() from elsewhere in this library. |
QUICKREF |
strcasestr |
*/ |
/*- |
* Copyright (c) 1990, 1993 |
* The Regents of the University of California. All rights reserved. |
* |
* The quadratic code is derived from software contributed to Berkeley by |
* Chris Torek. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 4. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
/* Linear algorithm Copyright (C) 2008 Eric Blake |
* Permission to use, copy, modify, and distribute the linear portion of |
* software is freely granted, provided that this notice is preserved. |
*/ |
#include <sys/cdefs.h> |
#include <ctype.h> |
#include <string.h> |
#include <strings.h> |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
# define RETURN_TYPE char * |
# define AVAILABLE(h, h_l, j, n_l) \ |
(!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ |
&& ((h_l) = (j) + (n_l))) |
# define CANON_ELEMENT(c) tolower (c) |
# define CMP_FUNC strncasecmp |
# include "str-two-way.h" |
#endif |
/* |
* Find the first occurrence of find in s, ignore case. |
*/ |
char * |
strcasestr(s, find) |
const char *s, *find; |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
/* Less code size, but quadratic performance in the worst case. */ |
char c, sc; |
size_t len; |
if ((c = *find++) != 0) { |
c = tolower((unsigned char)c); |
len = strlen(find); |
do { |
do { |
if ((sc = *s++) == 0) |
return (NULL); |
} while ((char)tolower((unsigned char)sc) != c); |
} while (strncasecmp(s, find, len) != 0); |
s--; |
} |
return ((char *)s); |
#else /* compilation for speed */ |
/* Larger code size, but guaranteed linear performance. */ |
const char *haystack = s; |
const char *needle = find; |
size_t needle_len; /* Length of NEEDLE. */ |
size_t haystack_len; /* Known minimum length of HAYSTACK. */ |
int ok = 1; /* True if NEEDLE is prefix of HAYSTACK. */ |
/* Determine length of NEEDLE, and in the process, make sure |
HAYSTACK is at least as long (no point processing all of a long |
NEEDLE if HAYSTACK is too short). */ |
while (*haystack && *needle) |
ok &= (tolower ((unsigned char) *haystack++) |
== tolower ((unsigned char) *needle++)); |
if (*needle) |
return NULL; |
if (ok) |
return (char *) s; |
needle_len = needle - find; |
haystack = s + 1; |
haystack_len = needle_len - 1; |
/* Perform the search. */ |
if (needle_len < LONG_NEEDLE_THRESHOLD) |
return two_way_short_needle ((const unsigned char *) haystack, |
haystack_len, |
(const unsigned char *) find, needle_len); |
return two_way_long_needle ((const unsigned char *) haystack, haystack_len, |
(const unsigned char *) find, needle_len); |
#endif /* compilation for speed */ |
} |
/contrib/sdk/sources/libc/string/strcat.c |
---|
0,0 → 1,104 |
/* |
FUNCTION |
<<strcat>>---concatenate strings |
INDEX |
strcat |
ANSI_SYNOPSIS |
#include <string.h> |
char *strcat(char *<[dst]>, const char *<[src]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strcat(<[dst]>, <[src]>) |
char *<[dst]>; |
char *<[src]>; |
DESCRIPTION |
<<strcat>> appends a copy of the string pointed to by <[src]> |
(including the terminating null character) to the end of the |
string pointed to by <[dst]>. The initial character of |
<[src]> overwrites the null character at the end of <[dst]>. |
RETURNS |
This function returns the initial value of <[dst]> |
PORTABILITY |
<<strcat>> is ANSI C. |
<<strcat>> requires no supporting OS subroutines. |
QUICKREF |
strcat ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/* Nonzero if X is aligned on a "long" boundary. */ |
#define ALIGNED(X) \ |
(((long)X & (sizeof (long) - 1)) == 0) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
/*SUPPRESS 560*/ |
/*SUPPRESS 530*/ |
char * |
_DEFUN (strcat, (s1, s2), |
char *s1 _AND |
_CONST char *s2) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
char *s = s1; |
while (*s1) |
s1++; |
while (*s1++ = *s2++) |
; |
return s; |
#else |
char *s = s1; |
/* Skip over the data in s1 as quickly as possible. */ |
if (ALIGNED (s1)) |
{ |
unsigned long *aligned_s1 = (unsigned long *)s1; |
while (!DETECTNULL (*aligned_s1)) |
aligned_s1++; |
s1 = (char *)aligned_s1; |
} |
while (*s1) |
s1++; |
/* s1 now points to the its trailing null character, we can |
just use strcpy to do the work for us now. |
?!? We might want to just include strcpy here. |
Also, this will cause many more unaligned string copies because |
s1 is much less likely to be aligned. I don't know if its worth |
tweaking strcpy to handle this better. */ |
strcpy (s1, s2); |
return s; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/contrib/sdk/sources/libc/string/strchr.c |
---|
0,0 → 1,123 |
/* |
FUNCTION |
<<strchr>>---search for character in string |
INDEX |
strchr |
ANSI_SYNOPSIS |
#include <string.h> |
char * strchr(const char *<[string]>, int <[c]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char * strchr(<[string]>, <[c]>); |
const char *<[string]>; |
int <[c]>; |
DESCRIPTION |
This function finds the first occurence of <[c]> (converted to |
a char) in the string pointed to by <[string]> (including the |
terminating null character). |
RETURNS |
Returns a pointer to the located character, or a null pointer |
if <[c]> does not occur in <[string]>. |
PORTABILITY |
<<strchr>> is ANSI C. |
<<strchr>> requires no supporting OS subroutines. |
QUICKREF |
strchr ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/* Nonzero if X is not aligned on a "long" boundary. */ |
#define UNALIGNED(X) ((long)X & (sizeof (long) - 1)) |
/* How many bytes are loaded each iteration of the word copy loop. */ |
#define LBLOCKSIZE (sizeof (long)) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
/* DETECTCHAR returns nonzero if (long)X contains the byte used |
to fill (long)MASK. */ |
#define DETECTCHAR(X,MASK) (DETECTNULL(X ^ MASK)) |
char * |
_DEFUN (strchr, (s1, i), |
_CONST char *s1 _AND |
int i) |
{ |
_CONST unsigned char *s = (_CONST unsigned char *)s1; |
unsigned char c = i; |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
unsigned long mask,j; |
unsigned long *aligned_addr; |
/* Special case for finding 0. */ |
if (!c) |
{ |
while (UNALIGNED (s)) |
{ |
if (!*s) |
return (char *) s; |
s++; |
} |
/* Operate a word at a time. */ |
aligned_addr = (unsigned long *) s; |
while (!DETECTNULL (*aligned_addr)) |
aligned_addr++; |
/* Found the end of string. */ |
s = (const unsigned char *) aligned_addr; |
while (*s) |
s++; |
return (char *) s; |
} |
/* All other bytes. Align the pointer, then search a long at a time. */ |
while (UNALIGNED (s)) |
{ |
if (!*s) |
return NULL; |
if (*s == c) |
return (char *) s; |
s++; |
} |
mask = c; |
for (j = 8; j < LBLOCKSIZE * 8; j <<= 1) |
mask = (mask << j) | mask; |
aligned_addr = (unsigned long *) s; |
while (!DETECTNULL (*aligned_addr) && !DETECTCHAR (*aligned_addr, mask)) |
aligned_addr++; |
/* The block of bytes currently pointed to by aligned_addr |
contains either a null or the target char, or both. We |
catch it using the bytewise search. */ |
s = (unsigned char *) aligned_addr; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
while (*s && *s != c) |
s++; |
if (*s == c) |
return (char *)s; |
return NULL; |
} |
/contrib/sdk/sources/libc/string/strcmp.c |
---|
0,0 → 1,106 |
/* |
FUNCTION |
<<strcmp>>---character string compare |
INDEX |
strcmp |
ANSI_SYNOPSIS |
#include <string.h> |
int strcmp(const char *<[a]>, const char *<[b]>); |
TRAD_SYNOPSIS |
#include <string.h> |
int strcmp(<[a]>, <[b]>) |
char *<[a]>; |
char *<[b]>; |
DESCRIPTION |
<<strcmp>> compares the string at <[a]> to |
the string at <[b]>. |
RETURNS |
If <<*<[a]>>> sorts lexicographically after <<*<[b]>>>, |
<<strcmp>> returns a number greater than zero. If the two |
strings match, <<strcmp>> returns zero. If <<*<[a]>>> |
sorts lexicographically before <<*<[b]>>>, <<strcmp>> returns a |
number less than zero. |
PORTABILITY |
<<strcmp>> is ANSI C. |
<<strcmp>> requires no supporting OS subroutines. |
QUICKREF |
strcmp ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
/* DETECTNULL returns nonzero if (long)X contains a NULL byte. */ |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
int |
_DEFUN (strcmp, (s1, s2), |
_CONST char *s1 _AND |
_CONST char *s2) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
while (*s1 != '\0' && *s1 == *s2) |
{ |
s1++; |
s2++; |
} |
return (*(unsigned char *) s1) - (*(unsigned char *) s2); |
#else |
unsigned long *a1; |
unsigned long *a2; |
/* If s1 or s2 are unaligned, then compare bytes. */ |
if (!UNALIGNED (s1, s2)) |
{ |
/* If s1 and s2 are word-aligned, compare them a word at a time. */ |
a1 = (unsigned long*)s1; |
a2 = (unsigned long*)s2; |
while (*a1 == *a2) |
{ |
/* To get here, *a1 == *a2, thus if we find a null in *a1, |
then the strings must be equal, so return zero. */ |
if (DETECTNULL (*a1)) |
return 0; |
a1++; |
a2++; |
} |
/* A difference was detected in last few bytes of s1, so search bytewise */ |
s1 = (char*)a1; |
s2 = (char*)a2; |
} |
while (*s1 != '\0' && *s1 == *s2) |
{ |
s1++; |
s2++; |
} |
return (*(unsigned char *) s1) - (*(unsigned char *) s2); |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/contrib/sdk/sources/libc/string/strcoll.c |
---|
0,0 → 1,48 |
/* |
FUNCTION |
<<strcoll>>---locale-specific character string compare |
INDEX |
strcoll |
ANSI_SYNOPSIS |
#include <string.h> |
int strcoll(const char *<[stra]>, const char * <[strb]>); |
TRAD_SYNOPSIS |
#include <string.h> |
int strcoll(<[stra]>, <[strb]>) |
char *<[stra]>; |
char *<[strb]>; |
DESCRIPTION |
<<strcoll>> compares the string pointed to by <[stra]> to |
the string pointed to by <[strb]>, using an interpretation |
appropriate to the current <<LC_COLLATE>> state. |
RETURNS |
If the first string is greater than the second string, |
<<strcoll>> returns a number greater than zero. If the two |
strings are equivalent, <<strcoll>> returns zero. If the first |
string is less than the second string, <<strcoll>> returns a |
number less than zero. |
PORTABILITY |
<<strcoll>> is ANSI C. |
<<strcoll>> requires no supporting OS subroutines. |
QUICKREF |
strcoll ansi pure |
*/ |
#include <string.h> |
int |
_DEFUN (strcoll, (a, b), |
_CONST char *a _AND |
_CONST char *b) |
{ |
return strcmp (a, b); |
} |
/contrib/sdk/sources/libc/string/strcpy.c |
---|
0,0 → 1,99 |
/* |
FUNCTION |
<<strcpy>>---copy string |
INDEX |
strcpy |
ANSI_SYNOPSIS |
#include <string.h> |
char *strcpy(char *<[dst]>, const char *<[src]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strcpy(<[dst]>, <[src]>) |
char *<[dst]>; |
char *<[src]>; |
DESCRIPTION |
<<strcpy>> copies the string pointed to by <[src]> |
(including the terminating null character) to the array |
pointed to by <[dst]>. |
RETURNS |
This function returns the initial value of <[dst]>. |
PORTABILITY |
<<strcpy>> is ANSI C. |
<<strcpy>> requires no supporting OS subroutines. |
QUICKREF |
strcpy ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/*SUPPRESS 560*/ |
/*SUPPRESS 530*/ |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
char* |
_DEFUN (strcpy, (dst0, src0), |
char *dst0 _AND |
_CONST char *src0) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
char *s = dst0; |
while (*dst0++ = *src0++) |
; |
return s; |
#else |
char *dst = dst0; |
_CONST char *src = src0; |
long *aligned_dst; |
_CONST long *aligned_src; |
/* If SRC or DEST is unaligned, then copy bytes. */ |
if (!UNALIGNED (src, dst)) |
{ |
aligned_dst = (long*)dst; |
aligned_src = (long*)src; |
/* SRC and DEST are both "long int" aligned, try to do "long int" |
sized copies. */ |
while (!DETECTNULL(*aligned_src)) |
{ |
*aligned_dst++ = *aligned_src++; |
} |
dst = (char*)aligned_dst; |
src = (char*)aligned_src; |
} |
while ((*dst++ = *src++)) |
; |
return dst0; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/contrib/sdk/sources/libc/string/strcspn.c |
---|
0,0 → 1,54 |
/* |
FUNCTION |
<<strcspn>>---count characters not in string |
INDEX |
strcspn |
ANSI_SYNOPSIS |
size_t strcspn(const char *<[s1]>, const char *<[s2]>); |
TRAD_SYNOPSIS |
size_t strcspn(<[s1]>, <[s2]>) |
char *<[s1]>; |
char *<[s2]>; |
DESCRIPTION |
This function computes the length of the initial part of |
the string pointed to by <[s1]> which consists entirely of |
characters <[NOT]> from the string pointed to by <[s2]> |
(excluding the terminating null character). |
RETURNS |
<<strcspn>> returns the length of the substring found. |
PORTABILITY |
<<strcspn>> is ANSI C. |
<<strcspn>> requires no supporting OS subroutines. |
*/ |
#include <string.h> |
size_t |
_DEFUN (strcspn, (s1, s2), |
_CONST char *s1 _AND |
_CONST char *s2) |
{ |
_CONST char *s = s1; |
_CONST char *c; |
while (*s1) |
{ |
for (c = s2; *c; c++) |
{ |
if (*s1 == *c) |
break; |
} |
if (*c) |
break; |
s1++; |
} |
return s1 - s; |
} |
/contrib/sdk/sources/libc/string/strdup.c |
---|
0,0 → 1,13 |
#ifndef _REENT_ONLY |
#include <reent.h> |
#include <stdlib.h> |
#include <string.h> |
char * |
_DEFUN (strdup, (str), _CONST char *str) |
{ |
return _strdup_r (_REENT, str); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/string/strdup_r.c |
---|
0,0 → 1,17 |
#include <reent.h> |
#include <stdlib.h> |
#include <string.h> |
char * |
_DEFUN (_strdup_r, (reent_ptr, str), |
struct _reent *reent_ptr _AND |
_CONST char *str) |
{ |
size_t len = strlen (str) + 1; |
char *copy = _malloc_r (reent_ptr, len); |
if (copy) |
{ |
memcpy (copy, str, len); |
} |
return copy; |
} |
/contrib/sdk/sources/libc/string/strerror.c |
---|
0,0 → 1,838 |
/*** |
**** CAUTION!!! KEEP DOC CONSISTENT---if you change text of a message |
**** here, change two places: |
**** 1) the leading doc section (alphabetized by macro) |
**** 2) the real text inside switch(errnum) |
***/ |
/* |
FUNCTION |
<<strerror>>---convert error number to string |
INDEX |
strerror |
ANSI_SYNOPSIS |
#include <string.h> |
char *strerror(int <[errnum]>); |
char *_strerror_r(struct _reent <[ptr]>, int <[errnum]>, |
int <[internal]>, int *<[error]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strerror(<[errnum]>) |
int <[errnum]>; |
DESCRIPTION |
<<strerror>> converts the error number <[errnum]> into a |
string. The value of <[errnum]> is usually a copy of <<errno>>. |
If <<errnum>> is not a known error number, the result points to an |
empty string. |
This implementation of <<strerror>> prints out the following strings |
for each of the values defined in `<<errno.h>>': |
o+ |
o 0 |
Success |
o E2BIG |
Arg list too long |
o EACCES |
Permission denied |
o EADDRINUSE |
Address already in use |
o EADV |
Advertise error |
o EAFNOSUPPORT |
Address family not supported by protocol family |
o EAGAIN |
No more processes |
o EALREADY |
Socket already connected |
o EBADF |
Bad file number |
o EBADMSG |
Bad message |
o EBUSY |
Device or resource busy |
o ECHILD |
No children |
o ECOMM |
Communication error |
o ECONNABORTED |
Software caused connection abort |
o ECONNREFUSED |
Connection refused |
o EDEADLK |
Deadlock |
o EDESTADDRREQ |
Destination address required |
o EEXIST |
File exists |
o EDOM |
Math argument |
o EFAULT |
Bad address |
o EFBIG |
File too large |
o EHOSTDOWN |
Host is down |
o EHOSTUNREACH |
Host is unreachable |
o EIDRM |
Identifier removed |
o EINPROGRESS |
Connection already in progress |
o EINTR |
Interrupted system call |
o EINVAL |
Invalid argument |
o EIO |
I/O error |
o EISCONN |
Socket is already connected |
o EISDIR |
Is a directory |
o ELIBACC |
Cannot access a needed shared library |
o ELIBBAD |
Accessing a corrupted shared library |
o ELIBEXEC |
Cannot exec a shared library directly |
o ELIBMAX |
Attempting to link in more shared libraries than system limit |
o ELIBSCN |
<<.lib>> section in a.out corrupted |
o EMFILE |
Too many open files |
o EMLINK |
Too many links |
o EMSGSIZE |
Message too long |
o EMULTIHOP |
Multihop attempted |
o ENAMETOOLONG |
File or path name too long |
o ENETDOWN |
Network interface not configured |
o ENETUNREACH |
Network is unreachable |
o ENFILE |
Too many open files in system |
o ENODEV |
No such device |
o ENOENT |
No such file or directory |
o ENOEXEC |
Exec format error |
o ENOLCK |
No lock |
o ENOLINK |
Virtual circuit is gone |
o ENOMEM |
Not enough space |
o ENOMSG |
No message of desired type |
o ENONET |
Machine is not on the network |
o ENOPKG |
No package |
o ENOPROTOOPT |
Protocol not available |
o ENOSPC |
No space left on device |
o ENOSR |
No stream resources |
o ENOSTR |
Not a stream |
o ENOSYS |
Function not implemented |
o ENOTBLK |
Block device required |
o ENOTCONN |
Socket is not connected |
o ENOTDIR |
Not a directory |
o ENOTEMPTY |
Directory not empty |
o ENOTSOCK |
Socket operation on non-socket |
o ENOTSUP |
Not supported |
o ENOTTY |
Not a character device |
o ENXIO |
No such device or address |
o EPERM |
Not owner |
o EPIPE |
Broken pipe |
o EPROTO |
Protocol error |
o EPROTOTYPE |
Protocol wrong type for socket |
o EPROTONOSUPPORT |
Unknown protocol |
o ERANGE |
Result too large |
o EREMOTE |
Resource is remote |
o EROFS |
Read-only file system |
o ESHUTDOWN |
Can't send after socket shutdown |
o ESOCKTNOSUPPORT |
Socket type not supported |
o ESPIPE |
Illegal seek |
o ESRCH |
No such process |
o ESRMNT |
Srmount error |
o ETIME |
Stream ioctl timeout |
o ETIMEDOUT |
Connection timed out |
o ETXTBSY |
Text file busy |
o EXDEV |
Cross-device link |
o ECANCELED |
Operation canceled |
o ENOTRECOVERABLE |
State not recoverable |
o EOWNERDEAD |
Previous owner died |
o ESTRPIPE |
Strings pipe error |
o- |
<<_strerror_r>> is a reentrant version of the above. |
RETURNS |
This function returns a pointer to a string. Your application must |
not modify that string. |
PORTABILITY |
ANSI C requires <<strerror>>, but does not specify the strings used |
for each error number. |
Although this implementation of <<strerror>> is reentrant (depending |
on <<_user_strerror>>), ANSI C declares that subsequent calls to |
<<strerror>> may overwrite the result string; therefore portable |
code cannot depend on the reentrancy of this subroutine. |
Although this implementation of <<strerror>> guarantees a non-null |
result with a NUL-terminator, some implementations return <<NULL>> |
on failure. Although POSIX allows <<strerror>> to set <<errno>> |
to EINVAL on failure, this implementation does not do so (unless |
you provide <<_user_strerror>>). |
POSIX recommends that unknown <[errnum]> result in a message |
including that value, however it is not a requirement and this |
implementation does not provide that information (unless you |
provide <<_user_strerror>>). |
This implementation of <<strerror>> provides for user-defined |
extensibility. <<errno.h>> defines <[__ELASTERROR]>, which can be |
used as a base for user-defined error values. If the user supplies a |
routine named <<_user_strerror>>, and <[errnum]> passed to |
<<strerror>> does not match any of the supported values, |
<<_user_strerror>> is called with three arguments. The first is of |
type <[int]>, and is the <[errnum]> value unknown to <<strerror>>. |
The second is of type <[int]>, and matches the <[internal]> argument |
of <<_strerror_r>>; this should be zero if called from <<strerror>> |
and non-zero if called from any other function; <<_user_strerror>> can |
use this information to satisfy the POSIX rule that no other |
standardized function can overwrite a static buffer reused by |
<<strerror>>. The third is of type <[int *]>, and matches the |
<[error]> argument of <<_strerror_r>>; if a non-zero value is stored |
into that location (usually <[EINVAL]>), then <<strerror>> will set |
<<errno>> to that value, and the XPG variant of <<strerror_r>> will |
return that value instead of zero or <[ERANGE]>. <<_user_strerror>> |
returns a <[char *]> value; returning <[NULL]> implies that the user |
function did not choose to handle <[errnum]>. The default |
<<_user_strerror>> returns <[NULL]> for all input values. Note that |
<<_user_sterror>> must be thread-safe, and only denote errors via the |
third argument rather than modifying <<errno>>, if <<strerror>> and |
<<strerror_r>> are are to comply with POSIX. |
<<strerror>> requires no supporting OS subroutines. |
QUICKREF |
strerror ansi pure |
*/ |
#include <errno.h> |
#include <string.h> |
char * |
_DEFUN (_strerror_r, (ptr, errnum, internal, errptr), |
struct _reent *ptr _AND |
int errnum _AND |
int internal _AND |
int *errptr) |
{ |
char *error; |
extern char *_user_strerror _PARAMS ((int, int, int *)); |
switch (errnum) |
{ |
case 0: |
error = "Success"; |
break; |
/* go32 defines EPERM as EACCES */ |
#if defined (EPERM) && (!defined (EACCES) || (EPERM != EACCES)) |
case EPERM: |
error = "Not owner"; |
break; |
#endif |
#ifdef ENOENT |
case ENOENT: |
error = "No such file or directory"; |
break; |
#endif |
#ifdef ESRCH |
case ESRCH: |
error = "No such process"; |
break; |
#endif |
#ifdef EINTR |
case EINTR: |
error = "Interrupted system call"; |
break; |
#endif |
#ifdef EIO |
case EIO: |
error = "I/O error"; |
break; |
#endif |
/* go32 defines ENXIO as ENODEV */ |
#if defined (ENXIO) && (!defined (ENODEV) || (ENXIO != ENODEV)) |
case ENXIO: |
error = "No such device or address"; |
break; |
#endif |
#ifdef E2BIG |
case E2BIG: |
error = "Arg list too long"; |
break; |
#endif |
#ifdef ENOEXEC |
case ENOEXEC: |
error = "Exec format error"; |
break; |
#endif |
#ifdef EALREADY |
case EALREADY: |
error = "Socket already connected"; |
break; |
#endif |
#ifdef EBADF |
case EBADF: |
error = "Bad file number"; |
break; |
#endif |
#ifdef ECHILD |
case ECHILD: |
error = "No children"; |
break; |
#endif |
#ifdef EDESTADDRREQ |
case EDESTADDRREQ: |
error = "Destination address required"; |
break; |
#endif |
#ifdef EAGAIN |
case EAGAIN: |
error = "No more processes"; |
break; |
#endif |
#ifdef ENOMEM |
case ENOMEM: |
error = "Not enough space"; |
break; |
#endif |
#ifdef EACCES |
case EACCES: |
error = "Permission denied"; |
break; |
#endif |
#ifdef EFAULT |
case EFAULT: |
error = "Bad address"; |
break; |
#endif |
#ifdef ENOTBLK |
case ENOTBLK: |
error = "Block device required"; |
break; |
#endif |
#ifdef EBUSY |
case EBUSY: |
error = "Device or resource busy"; |
break; |
#endif |
#ifdef EEXIST |
case EEXIST: |
error = "File exists"; |
break; |
#endif |
#ifdef EXDEV |
case EXDEV: |
error = "Cross-device link"; |
break; |
#endif |
#ifdef ENODEV |
case ENODEV: |
error = "No such device"; |
break; |
#endif |
#ifdef ENOTDIR |
case ENOTDIR: |
error = "Not a directory"; |
break; |
#endif |
#ifdef EHOSTDOWN |
case EHOSTDOWN: |
error = "Host is down"; |
break; |
#endif |
#ifdef EINPROGRESS |
case EINPROGRESS: |
error = "Connection already in progress"; |
break; |
#endif |
#ifdef EISDIR |
case EISDIR: |
error = "Is a directory"; |
break; |
#endif |
#ifdef EINVAL |
case EINVAL: |
error = "Invalid argument"; |
break; |
#endif |
#ifdef ENETDOWN |
case ENETDOWN: |
error = "Network interface is not configured"; |
break; |
#endif |
#ifdef ENFILE |
case ENFILE: |
error = "Too many open files in system"; |
break; |
#endif |
#ifdef EMFILE |
case EMFILE: |
error = "Too many open files"; |
break; |
#endif |
#ifdef ENOTTY |
case ENOTTY: |
error = "Not a character device"; |
break; |
#endif |
#ifdef ETXTBSY |
case ETXTBSY: |
error = "Text file busy"; |
break; |
#endif |
#ifdef EFBIG |
case EFBIG: |
error = "File too large"; |
break; |
#endif |
#ifdef EHOSTUNREACH |
case EHOSTUNREACH: |
error = "Host is unreachable"; |
break; |
#endif |
#ifdef ENOSPC |
case ENOSPC: |
error = "No space left on device"; |
break; |
#endif |
#ifdef ENOTSUP |
case ENOTSUP: |
error = "Not supported"; |
break; |
#endif |
#ifdef ESPIPE |
case ESPIPE: |
error = "Illegal seek"; |
break; |
#endif |
#ifdef EROFS |
case EROFS: |
error = "Read-only file system"; |
break; |
#endif |
#ifdef EMLINK |
case EMLINK: |
error = "Too many links"; |
break; |
#endif |
#ifdef EPIPE |
case EPIPE: |
error = "Broken pipe"; |
break; |
#endif |
#ifdef EDOM |
case EDOM: |
error = "Math argument"; |
break; |
#endif |
#ifdef ERANGE |
case ERANGE: |
error = "Result too large"; |
break; |
#endif |
#ifdef ENOMSG |
case ENOMSG: |
error = "No message of desired type"; |
break; |
#endif |
#ifdef EIDRM |
case EIDRM: |
error = "Identifier removed"; |
break; |
#endif |
#ifdef EDEADLK |
case EDEADLK: |
error = "Deadlock"; |
break; |
#endif |
#ifdef ENETUNREACH |
case ENETUNREACH: |
error = "Network is unreachable"; |
break; |
#endif |
#ifdef ENOLCK |
case ENOLCK: |
error = "No lock"; |
break; |
#endif |
#ifdef ENOSTR |
case ENOSTR: |
error = "Not a stream"; |
break; |
#endif |
#ifdef ETIME |
case ETIME: |
error = "Stream ioctl timeout"; |
break; |
#endif |
#ifdef ENOSR |
case ENOSR: |
error = "No stream resources"; |
break; |
#endif |
#ifdef ENONET |
case ENONET: |
error = "Machine is not on the network"; |
break; |
#endif |
#ifdef ENOPKG |
case ENOPKG: |
error = "No package"; |
break; |
#endif |
#ifdef EREMOTE |
case EREMOTE: |
error = "Resource is remote"; |
break; |
#endif |
#ifdef ENOLINK |
case ENOLINK: |
error = "Virtual circuit is gone"; |
break; |
#endif |
#ifdef EADV |
case EADV: |
error = "Advertise error"; |
break; |
#endif |
#ifdef ESRMNT |
case ESRMNT: |
error = "Srmount error"; |
break; |
#endif |
#ifdef ECOMM |
case ECOMM: |
error = "Communication error"; |
break; |
#endif |
#ifdef EPROTO |
case EPROTO: |
error = "Protocol error"; |
break; |
#endif |
#ifdef EPROTONOSUPPORT |
case EPROTONOSUPPORT: |
error = "Unknown protocol"; |
break; |
#endif |
#ifdef EMULTIHOP |
case EMULTIHOP: |
error = "Multihop attempted"; |
break; |
#endif |
#ifdef EBADMSG |
case EBADMSG: |
error = "Bad message"; |
break; |
#endif |
#ifdef ELIBACC |
case ELIBACC: |
error = "Cannot access a needed shared library"; |
break; |
#endif |
#ifdef ELIBBAD |
case ELIBBAD: |
error = "Accessing a corrupted shared library"; |
break; |
#endif |
#ifdef ELIBSCN |
case ELIBSCN: |
error = ".lib section in a.out corrupted"; |
break; |
#endif |
#ifdef ELIBMAX |
case ELIBMAX: |
error = "Attempting to link in more shared libraries than system limit"; |
break; |
#endif |
#ifdef ELIBEXEC |
case ELIBEXEC: |
error = "Cannot exec a shared library directly"; |
break; |
#endif |
#ifdef ENOSYS |
case ENOSYS: |
error = "Function not implemented"; |
break; |
#endif |
#ifdef ENMFILE |
case ENMFILE: |
error = "No more files"; |
break; |
#endif |
#ifdef ENOTEMPTY |
case ENOTEMPTY: |
error = "Directory not empty"; |
break; |
#endif |
#ifdef ENAMETOOLONG |
case ENAMETOOLONG: |
error = "File or path name too long"; |
break; |
#endif |
#ifdef ELOOP |
case ELOOP: |
error = "Too many symbolic links"; |
break; |
#endif |
#ifdef ENOBUFS |
case ENOBUFS: |
error = "No buffer space available"; |
break; |
#endif |
#ifdef EAFNOSUPPORT |
case EAFNOSUPPORT: |
error = "Address family not supported by protocol family"; |
break; |
#endif |
#ifdef EPROTOTYPE |
case EPROTOTYPE: |
error = "Protocol wrong type for socket"; |
break; |
#endif |
#ifdef ENOTSOCK |
case ENOTSOCK: |
error = "Socket operation on non-socket"; |
break; |
#endif |
#ifdef ENOPROTOOPT |
case ENOPROTOOPT: |
error = "Protocol not available"; |
break; |
#endif |
#ifdef ESHUTDOWN |
case ESHUTDOWN: |
error = "Can't send after socket shutdown"; |
break; |
#endif |
#ifdef ECONNREFUSED |
case ECONNREFUSED: |
error = "Connection refused"; |
break; |
#endif |
#ifdef EADDRINUSE |
case EADDRINUSE: |
error = "Address already in use"; |
break; |
#endif |
#ifdef ECONNABORTED |
case ECONNABORTED: |
error = "Software caused connection abort"; |
break; |
#endif |
#if (defined(EWOULDBLOCK) && (!defined (EAGAIN) || (EWOULDBLOCK != EAGAIN))) |
case EWOULDBLOCK: |
error = "Operation would block"; |
break; |
#endif |
#ifdef ENOTCONN |
case ENOTCONN: |
error = "Socket is not connected"; |
break; |
#endif |
#ifdef ESOCKTNOSUPPORT |
case ESOCKTNOSUPPORT: |
error = "Socket type not supported"; |
break; |
#endif |
#ifdef EISCONN |
case EISCONN: |
error = "Socket is already connected"; |
break; |
#endif |
#ifdef ECANCELED |
case ECANCELED: |
error = "Operation canceled"; |
break; |
#endif |
#ifdef ENOTRECOVERABLE |
case ENOTRECOVERABLE: |
error = "State not recoverable"; |
break; |
#endif |
#ifdef EOWNERDEAD |
case EOWNERDEAD: |
error = "Previous owner died"; |
break; |
#endif |
#ifdef ESTRPIPE |
case ESTRPIPE: |
error = "Streams pipe error"; |
break; |
#endif |
#if defined(EOPNOTSUPP) && (!defined(ENOTSUP) || (ENOTSUP != EOPNOTSUPP)) |
case EOPNOTSUPP: |
error = "Operation not supported on socket"; |
break; |
#endif |
#ifdef EMSGSIZE |
case EMSGSIZE: |
error = "Message too long"; |
break; |
#endif |
#ifdef ETIMEDOUT |
case ETIMEDOUT: |
error = "Connection timed out"; |
break; |
#endif |
default: |
if (!errptr) |
errptr = &ptr->_errno; |
if ((error = _user_strerror (errnum, internal, errptr)) == 0) |
error = ""; |
break; |
} |
return error; |
} |
char * |
_DEFUN(strerror, (int), |
int errnum) |
{ |
return _strerror_r (_REENT, errnum, 0, NULL); |
} |
/contrib/sdk/sources/libc/string/strlen.c |
---|
0,0 → 1,88 |
/* |
FUNCTION |
<<strlen>>---character string length |
INDEX |
strlen |
ANSI_SYNOPSIS |
#include <string.h> |
size_t strlen(const char *<[str]>); |
TRAD_SYNOPSIS |
#include <string.h> |
size_t strlen(<[str]>) |
char *<[src]>; |
DESCRIPTION |
The <<strlen>> function works out the length of the string |
starting at <<*<[str]>>> by counting chararacters until it |
reaches a <<NULL>> character. |
RETURNS |
<<strlen>> returns the character count. |
PORTABILITY |
<<strlen>> is ANSI C. |
<<strlen>> requires no supporting OS subroutines. |
QUICKREF |
strlen ansi pure |
*/ |
#include <_ansi.h> |
#include <string.h> |
#include <limits.h> |
#define LBLOCKSIZE (sizeof (long)) |
#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1)) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
size_t |
_DEFUN (strlen, (str), |
_CONST char *str) |
{ |
_CONST char *start = str; |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
unsigned long *aligned_addr; |
/* Align the pointer, so we can search a word at a time. */ |
while (UNALIGNED (str)) |
{ |
if (!*str) |
return str - start; |
str++; |
} |
/* If the string is word-aligned, we can check for the presence of |
a null in each word-sized block. */ |
aligned_addr = (unsigned long *)str; |
while (!DETECTNULL (*aligned_addr)) |
aligned_addr++; |
/* Once a null is detected, we check each byte in that block for a |
precise position of the null. */ |
str = (char *) aligned_addr; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
while (*str) |
str++; |
return str - start; |
} |
/contrib/sdk/sources/libc/string/strncasecmp.c |
---|
0,0 → 1,63 |
/* |
FUNCTION |
<<strncasecmp>>---case-insensitive character string compare |
INDEX |
strncasecmp |
ANSI_SYNOPSIS |
#include <strings.h> |
int strncasecmp(const char *<[a]>, const char * <[b]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <strings.h> |
int strncasecmp(<[a]>, <[b]>, <[length]>) |
char *<[a]>; |
char *<[b]>; |
size_t <[length]> |
DESCRIPTION |
<<strncasecmp>> compares up to <[length]> characters |
from the string at <[a]> to the string at <[b]> in a |
case-insensitive manner. |
RETURNS |
If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after |
both are converted to lowercase), <<strncasecmp>> returns a |
number greater than zero. If the two strings are equivalent, |
<<strncasecmp>> returns zero. If <<*<[a]>>> sorts |
lexicographically before <<*<[b]>>>, <<strncasecmp>> returns a |
number less than zero. |
PORTABILITY |
<<strncasecmp>> is in the Berkeley Software Distribution. |
<<strncasecmp>> requires no supporting OS subroutines. It uses |
tolower() from elsewhere in this library. |
QUICKREF |
strncasecmp |
*/ |
#include <strings.h> |
#include <ctype.h> |
int |
_DEFUN (strncasecmp, (s1, s2, n), |
_CONST char *s1 _AND |
_CONST char *s2 _AND |
size_t n) |
{ |
_CONST unsigned char *ucs1 = (_CONST unsigned char *) s1; |
_CONST unsigned char *ucs2 = (_CONST unsigned char *) s2; |
int d = 0; |
for ( ; n != 0; n--) |
{ |
_CONST int c1 = tolower(*ucs1++); |
_CONST int c2 = tolower(*ucs2++); |
if (((d = c1 - c2) != 0) || (c2 == '\0')) |
break; |
} |
return d; |
} |
/contrib/sdk/sources/libc/string/strncat.c |
---|
0,0 → 1,114 |
/* |
FUNCTION |
<<strncat>>---concatenate strings |
INDEX |
strncat |
ANSI_SYNOPSIS |
#include <string.h> |
char *strncat(char *<[dst]>, const char *<[src]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strncat(<[dst]>, <[src]>, <[length]>) |
char *<[dst]>; |
char *<[src]>; |
size_t <[length]>; |
DESCRIPTION |
<<strncat>> appends not more than <[length]> characters from |
the string pointed to by <[src]> (including the terminating |
null character) to the end of the string pointed to by |
<[dst]>. The initial character of <[src]> overwrites the null |
character at the end of <[dst]>. A terminating null character |
is always appended to the result |
WARNINGS |
Note that a null is always appended, so that if the copy is |
limited by the <[length]> argument, the number of characters |
appended to <[dst]> is <<n + 1>>. |
RETURNS |
This function returns the initial value of <[dst]> |
PORTABILITY |
<<strncat>> is ANSI C. |
<<strncat>> requires no supporting OS subroutines. |
QUICKREF |
strncat ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/* Nonzero if X is aligned on a "long" boundary. */ |
#define ALIGNED(X) \ |
(((long)X & (sizeof (long) - 1)) == 0) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
char * |
_DEFUN (strncat, (s1, s2, n), |
char *s1 _AND |
_CONST char *s2 _AND |
size_t n) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
char *s = s1; |
while (*s1) |
s1++; |
while (n-- != 0 && (*s1++ = *s2++)) |
{ |
if (n == 0) |
*s1 = '\0'; |
} |
return s; |
#else |
char *s = s1; |
/* Skip over the data in s1 as quickly as possible. */ |
if (ALIGNED (s1)) |
{ |
unsigned long *aligned_s1 = (unsigned long *)s1; |
while (!DETECTNULL (*aligned_s1)) |
aligned_s1++; |
s1 = (char *)aligned_s1; |
} |
while (*s1) |
s1++; |
/* s1 now points to the its trailing null character, now copy |
up to N bytes from S2 into S1 stopping if a NULL is encountered |
in S2. |
It is not safe to use strncpy here since it copies EXACTLY N |
characters, NULL padding if necessary. */ |
while (n-- != 0 && (*s1++ = *s2++)) |
{ |
if (n == 0) |
*s1 = '\0'; |
} |
return s; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/contrib/sdk/sources/libc/string/strncmp.c |
---|
0,0 → 1,122 |
/* |
FUNCTION |
<<strncmp>>---character string compare |
INDEX |
strncmp |
ANSI_SYNOPSIS |
#include <string.h> |
int strncmp(const char *<[a]>, const char * <[b]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
int strncmp(<[a]>, <[b]>, <[length]>) |
char *<[a]>; |
char *<[b]>; |
size_t <[length]> |
DESCRIPTION |
<<strncmp>> compares up to <[length]> characters |
from the string at <[a]> to the string at <[b]>. |
RETURNS |
If <<*<[a]>>> sorts lexicographically after <<*<[b]>>>, |
<<strncmp>> returns a number greater than zero. If the two |
strings are equivalent, <<strncmp>> returns zero. If <<*<[a]>>> |
sorts lexicographically before <<*<[b]>>>, <<strncmp>> returns a |
number less than zero. |
PORTABILITY |
<<strncmp>> is ANSI C. |
<<strncmp>> requires no supporting OS subroutines. |
QUICKREF |
strncmp ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
/* DETECTNULL returns nonzero if (long)X contains a NULL byte. */ |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
int |
_DEFUN (strncmp, (s1, s2, n), |
_CONST char *s1 _AND |
_CONST char *s2 _AND |
size_t n) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
if (n == 0) |
return 0; |
while (n-- != 0 && *s1 == *s2) |
{ |
if (n == 0 || *s1 == '\0') |
break; |
s1++; |
s2++; |
} |
return (*(unsigned char *) s1) - (*(unsigned char *) s2); |
#else |
unsigned long *a1; |
unsigned long *a2; |
if (n == 0) |
return 0; |
/* If s1 or s2 are unaligned, then compare bytes. */ |
if (!UNALIGNED (s1, s2)) |
{ |
/* If s1 and s2 are word-aligned, compare them a word at a time. */ |
a1 = (unsigned long*)s1; |
a2 = (unsigned long*)s2; |
while (n >= sizeof (long) && *a1 == *a2) |
{ |
n -= sizeof (long); |
/* If we've run out of bytes or hit a null, return zero |
since we already know *a1 == *a2. */ |
if (n == 0 || DETECTNULL (*a1)) |
return 0; |
a1++; |
a2++; |
} |
/* A difference was detected in last few bytes of s1, so search bytewise */ |
s1 = (char*)a1; |
s2 = (char*)a2; |
} |
while (n-- > 0 && *s1 == *s2) |
{ |
/* If we've run out of bytes or hit a null, return zero |
since we already know *s1 == *s2. */ |
if (n == 0 || *s1 == '\0') |
return 0; |
s1++; |
s2++; |
} |
return (*(unsigned char *) s1) - (*(unsigned char *) s2); |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/contrib/sdk/sources/libc/string/strncpy.c |
---|
0,0 → 1,125 |
/* |
FUNCTION |
<<strncpy>>---counted copy string |
INDEX |
strncpy |
ANSI_SYNOPSIS |
#include <string.h> |
char *strncpy(char *<[dst]>, const char *<[src]>, size_t <[length]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strncpy(<[dst]>, <[src]>, <[length]>) |
char *<[dst]>; |
char *<[src]>; |
size_t <[length]>; |
DESCRIPTION |
<<strncpy>> copies not more than <[length]> characters from the |
the string pointed to by <[src]> (including the terminating |
null character) to the array pointed to by <[dst]>. If the |
string pointed to by <[src]> is shorter than <[length]> |
characters, null characters are appended to the destination |
array until a total of <[length]> characters have been |
written. |
RETURNS |
This function returns the initial value of <[dst]>. |
PORTABILITY |
<<strncpy>> is ANSI C. |
<<strncpy>> requires no supporting OS subroutines. |
QUICKREF |
strncpy ansi pure |
*/ |
#include <string.h> |
#include <limits.h> |
/*SUPPRESS 560*/ |
/*SUPPRESS 530*/ |
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
#define UNALIGNED(X, Y) \ |
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) |
#if LONG_MAX == 2147483647L |
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
#else |
#if LONG_MAX == 9223372036854775807L |
/* Nonzero if X (a long int) contains a NULL byte. */ |
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) |
#else |
#error long int is not a 32bit or 64bit type. |
#endif |
#endif |
#ifndef DETECTNULL |
#error long int is not a 32bit or 64bit byte |
#endif |
#define TOO_SMALL(LEN) ((LEN) < sizeof (long)) |
char * |
_DEFUN (strncpy, (dst0, src0), |
char *dst0 _AND |
_CONST char *src0 _AND |
size_t count) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
char *dscan; |
_CONST char *sscan; |
dscan = dst0; |
sscan = src0; |
while (count > 0) |
{ |
--count; |
if ((*dscan++ = *sscan++) == '\0') |
break; |
} |
while (count-- > 0) |
*dscan++ = '\0'; |
return dst0; |
#else |
char *dst = dst0; |
_CONST char *src = src0; |
long *aligned_dst; |
_CONST long *aligned_src; |
/* If SRC and DEST is aligned and count large enough, then copy words. */ |
if (!UNALIGNED (src, dst) && !TOO_SMALL (count)) |
{ |
aligned_dst = (long*)dst; |
aligned_src = (long*)src; |
/* SRC and DEST are both "long int" aligned, try to do "long int" |
sized copies. */ |
while (count >= sizeof (long int) && !DETECTNULL(*aligned_src)) |
{ |
count -= sizeof (long int); |
*aligned_dst++ = *aligned_src++; |
} |
dst = (char*)aligned_dst; |
src = (char*)aligned_src; |
} |
while (count > 0) |
{ |
--count; |
if ((*dst++ = *src++) == '\0') |
break; |
} |
while (count-- > 0) |
*dst++ = '\0'; |
return dst0; |
#endif /* not PREFER_SIZE_OVER_SPEED */ |
} |
/contrib/sdk/sources/libc/string/strndup.c |
---|
0,0 → 1,16 |
#ifndef _REENT_ONLY |
#include <_ansi.h> |
#include <reent.h> |
#include <stdlib.h> |
#include <string.h> |
char * |
_DEFUN (strndup, (str, n), |
_CONST char *str _AND |
size_t n) |
{ |
return _strndup_r (_REENT, str, n); |
} |
#endif /* !_REENT_ONLY */ |
/contrib/sdk/sources/libc/string/strndup_r.c |
---|
0,0 → 1,27 |
#include <reent.h> |
#include <stdlib.h> |
#include <string.h> |
char * |
_DEFUN (_strndup_r, (reent_ptr, str, n), |
struct _reent *reent_ptr _AND |
_CONST char *str _AND |
size_t n) |
{ |
_CONST char *ptr = str; |
size_t len; |
char *copy; |
while (n-- > 0 && *ptr) |
ptr++; |
len = ptr - str; |
copy = _malloc_r (reent_ptr, len + 1); |
if (copy) |
{ |
memcpy (copy, str, len); |
copy[len] = '\0'; |
} |
return copy; |
} |
/contrib/sdk/sources/libc/string/strnlen.c |
---|
0,0 → 1,49 |
/* |
FUNCTION |
<<strnlen>>---character string length |
INDEX |
strnlen |
ANSI_SYNOPSIS |
#include <string.h> |
size_t strnlen(const char *<[str]>, size_t <[n]>); |
TRAD_SYNOPSIS |
#include <string.h> |
size_t strnlen(<[str]>, <[n]>) |
char *<[src]>; |
size_t <[n]>; |
DESCRIPTION |
The <<strnlen>> function works out the length of the string |
starting at <<*<[str]>>> by counting chararacters until it |
reaches a NUL character or the maximum: <[n]> number of |
characters have been inspected. |
RETURNS |
<<strnlen>> returns the character count or <[n]>. |
PORTABILITY |
<<strnlen>> is a GNU extension. |
<<strnlen>> requires no supporting OS subroutines. |
*/ |
#undef __STRICT_ANSI__ |
#include <_ansi.h> |
#include <string.h> |
size_t |
_DEFUN (strnlen, (str, n), |
_CONST char *str _AND |
size_t n) |
{ |
_CONST char *start = str; |
while (n-- > 0 && *str) |
str++; |
return str - start; |
} |
/contrib/sdk/sources/libc/string/strpbrk.c |
---|
0,0 → 1,58 |
/* |
FUNCTION |
<<strpbrk>>---find characters in string |
INDEX |
strpbrk |
ANSI_SYNOPSIS |
#include <string.h> |
char *strpbrk(const char *<[s1]>, const char *<[s2]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strpbrk(<[s1]>, <[s2]>) |
char *<[s1]>; |
char *<[s2]>; |
DESCRIPTION |
This function locates the first occurence in the string |
pointed to by <[s1]> of any character in string pointed to by |
<[s2]> (excluding the terminating null character). |
RETURNS |
<<strpbrk>> returns a pointer to the character found in <[s1]>, or a |
null pointer if no character from <[s2]> occurs in <[s1]>. |
PORTABILITY |
<<strpbrk>> requires no supporting OS subroutines. |
*/ |
#include <string.h> |
char * |
_DEFUN (strpbrk, (s1, s2), |
_CONST char *s1 _AND |
_CONST char *s2) |
{ |
_CONST char *c = s2; |
if (!*s1) |
return (char *) NULL; |
while (*s1) |
{ |
for (c = s2; *c; c++) |
{ |
if (*s1 == *c) |
break; |
} |
if (*c) |
break; |
s1++; |
} |
if (*c == '\0') |
s1 = NULL; |
return (char *) s1; |
} |
/contrib/sdk/sources/libc/string/strrchr.c |
---|
0,0 → 1,59 |
/* |
FUNCTION |
<<strrchr>>---reverse search for character in string |
INDEX |
strrchr |
ANSI_SYNOPSIS |
#include <string.h> |
char * strrchr(const char *<[string]>, int <[c]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char * strrchr(<[string]>, <[c]>); |
char *<[string]>; |
int *<[c]>; |
DESCRIPTION |
This function finds the last occurence of <[c]> (converted to |
a char) in the string pointed to by <[string]> (including the |
terminating null character). |
RETURNS |
Returns a pointer to the located character, or a null pointer |
if <[c]> does not occur in <[string]>. |
PORTABILITY |
<<strrchr>> is ANSI C. |
<<strrchr>> requires no supporting OS subroutines. |
QUICKREF |
strrchr ansi pure |
*/ |
#include <string.h> |
char * |
_DEFUN (strrchr, (s, i), |
_CONST char *s _AND |
int i) |
{ |
_CONST char *last = NULL; |
if (i) |
{ |
while ((s=strchr(s, i))) |
{ |
last = s; |
s++; |
} |
} |
else |
{ |
last = strchr(s, i); |
} |
return (char *) last; |
} |
/contrib/sdk/sources/libc/string/strsep.c |
---|
0,0 → 1,19 |
/* BSD strsep function */ |
/* Copyright 2002, Red Hat Inc. */ |
/* undef STRICT_ANSI so that strsep prototype will be defined */ |
#undef __STRICT_ANSI__ |
#include <string.h> |
#include <_ansi.h> |
#include <reent.h> |
extern char *__strtok_r (char *, const char *, char **, int); |
char * |
_DEFUN (strsep, (source_ptr, delim), |
register char **source_ptr _AND |
register const char *delim) |
{ |
return __strtok_r (*source_ptr, delim, source_ptr, 0); |
} |
/contrib/sdk/sources/libc/string/strspn.c |
---|
0,0 → 1,59 |
/* |
FUNCTION |
<<strspn>>---find initial match |
INDEX |
strspn |
ANSI_SYNOPSIS |
#include <string.h> |
size_t strspn(const char *<[s1]>, const char *<[s2]>); |
TRAD_SYNOPSIS |
#include <string.h> |
size_t strspn(<[s1]>, <[s2]>) |
char *<[s1]>; |
char *<[s2]>; |
DESCRIPTION |
This function computes the length of the initial segment of |
the string pointed to by <[s1]> which consists entirely of |
characters from the string pointed to by <[s2]> (excluding the |
terminating null character). |
RETURNS |
<<strspn>> returns the length of the segment found. |
PORTABILITY |
<<strspn>> is ANSI C. |
<<strspn>> requires no supporting OS subroutines. |
QUICKREF |
strspn ansi pure |
*/ |
#include <string.h> |
size_t |
_DEFUN (strspn, (s1, s2), |
_CONST char *s1 _AND |
_CONST char *s2) |
{ |
_CONST char *s = s1; |
_CONST char *c; |
while (*s1) |
{ |
for (c = s2; *c; c++) |
{ |
if (*s1 == *c) |
break; |
} |
if (*c == '\0') |
break; |
s1++; |
} |
return s1 - s; |
} |
/contrib/sdk/sources/libc/string/strstr.c |
---|
0,0 → 1,121 |
/* |
FUNCTION |
<<strstr>>---find string segment |
INDEX |
strstr |
ANSI_SYNOPSIS |
#include <string.h> |
char *strstr(const char *<[s1]>, const char *<[s2]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strstr(<[s1]>, <[s2]>) |
char *<[s1]>; |
char *<[s2]>; |
DESCRIPTION |
Locates the first occurrence in the string pointed to by <[s1]> of |
the sequence of characters in the string pointed to by <[s2]> |
(excluding the terminating null character). |
RETURNS |
Returns a pointer to the located string segment, or a null |
pointer if the string <[s2]> is not found. If <[s2]> points to |
a string with zero length, <[s1]> is returned. |
PORTABILITY |
<<strstr>> is ANSI C. |
<<strstr>> requires no supporting OS subroutines. |
QUICKREF |
strstr ansi pure |
*/ |
#include <string.h> |
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) |
# define RETURN_TYPE char * |
# define AVAILABLE(h, h_l, j, n_l) \ |
(!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ |
&& ((h_l) = (j) + (n_l))) |
# include "str-two-way.h" |
#endif |
char * |
_DEFUN (strstr, (searchee, lookfor), |
_CONST char *searchee _AND |
_CONST char *lookfor) |
{ |
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) |
/* Less code size, but quadratic performance in the worst case. */ |
if (*searchee == 0) |
{ |
if (*lookfor) |
return (char *) NULL; |
return (char *) searchee; |
} |
while (*searchee) |
{ |
size_t i; |
i = 0; |
while (1) |
{ |
if (lookfor[i] == 0) |
{ |
return (char *) searchee; |
} |
if (lookfor[i] != searchee[i]) |
{ |
break; |
} |
i++; |
} |
searchee++; |
} |
return (char *) NULL; |
#else /* compilation for speed */ |
/* Larger code size, but guaranteed linear performance. */ |
const char *haystack = searchee; |
const char *needle = lookfor; |
size_t needle_len; /* Length of NEEDLE. */ |
size_t haystack_len; /* Known minimum length of HAYSTACK. */ |
int ok = 1; /* True if NEEDLE is prefix of HAYSTACK. */ |
/* Determine length of NEEDLE, and in the process, make sure |
HAYSTACK is at least as long (no point processing all of a long |
NEEDLE if HAYSTACK is too short). */ |
while (*haystack && *needle) |
ok &= *haystack++ == *needle++; |
if (*needle) |
return NULL; |
if (ok) |
return (char *) searchee; |
/* Reduce the size of haystack using strchr, since it has a smaller |
linear coefficient than the Two-Way algorithm. */ |
needle_len = needle - lookfor; |
haystack = strchr (searchee + 1, *lookfor); |
if (!haystack || needle_len == 1) |
return (char *) haystack; |
haystack_len = (haystack > searchee + needle_len ? 1 |
: needle_len + searchee - haystack); |
/* Perform the search. */ |
if (needle_len < LONG_NEEDLE_THRESHOLD) |
return two_way_short_needle ((const unsigned char *) haystack, |
haystack_len, |
(const unsigned char *) lookfor, needle_len); |
return two_way_long_needle ((const unsigned char *) haystack, haystack_len, |
(const unsigned char *) lookfor, needle_len); |
#endif /* compilation for speed */ |
} |
/contrib/sdk/sources/libc/string/strtok.c |
---|
0,0 → 1,101 |
/* |
FUNCTION |
<<strtok>>, <<strtok_r>>, <<strsep>>---get next token from a string |
INDEX |
strtok |
INDEX |
strtok_r |
INDEX |
strsep |
ANSI_SYNOPSIS |
#include <string.h> |
char *strtok(char *<[source]>, const char *<[delimiters]>) |
char *strtok_r(char *<[source]>, const char *<[delimiters]>, |
char **<[lasts]>) |
char *strsep(char **<[source_ptr]>, const char *<[delimiters]>) |
TRAD_SYNOPSIS |
#include <string.h> |
char *strtok(<[source]>, <[delimiters]>) |
char *<[source]>; |
char *<[delimiters]>; |
char *strtok_r(<[source]>, <[delimiters]>, <[lasts]>) |
char *<[source]>; |
char *<[delimiters]>; |
char **<[lasts]>; |
char *strsep(<[source_ptr]>, <[delimiters]>) |
char **<[source_ptr]>; |
char *<[delimiters]>; |
DESCRIPTION |
The <<strtok>> function is used to isolate sequential tokens in a |
null-terminated string, <<*<[source]>>>. These tokens are delimited |
in the string by at least one of the characters in <<*<[delimiters]>>>. |
The first time that <<strtok>> is called, <<*<[source]>>> should be |
specified; subsequent calls, wishing to obtain further tokens from |
the same string, should pass a null pointer instead. The separator |
string, <<*<[delimiters]>>>, must be supplied each time and may |
change between calls. |
The <<strtok>> function returns a pointer to the beginning of each |
subsequent token in the string, after replacing the separator |
character itself with a null character. When no more tokens remain, |
a null pointer is returned. |
The <<strtok_r>> function has the same behavior as <<strtok>>, except |
a pointer to placeholder <<*<[lasts]>>> must be supplied by the caller. |
The <<strsep>> function is similar in behavior to <<strtok>>, except |
a pointer to the string pointer must be supplied <<<[source_ptr]>>> and |
the function does not skip leading delimiters. When the string starts |
with a delimiter, the delimiter is changed to the null character and |
the empty string is returned. Like <<strtok_r>> and <<strtok>>, the |
<<*<[source_ptr]>>> is updated to the next character following the |
last delimiter found or NULL if the end of string is reached with |
no more delimiters. |
RETURNS |
<<strtok>>, <<strtok_r>>, and <<strsep>> all return a pointer to the |
next token, or <<NULL>> if no more tokens can be found. For |
<<strsep>>, a token may be the empty string. |
NOTES |
<<strtok>> is unsafe for multi-threaded applications. <<strtok_r>> |
and <<strsep>> are thread-safe and should be used instead. |
PORTABILITY |
<<strtok>> is ANSI C. |
<<strtok_r>> is POSIX. |
<<strsep>> is a BSD extension. |
<<strtok>>, <<strtok_r>>, and <<strsep>> require no supporting OS subroutines. |
QUICKREF |
strtok ansi impure |
*/ |
/* undef STRICT_ANSI so that strtok_r prototype will be defined */ |
#undef __STRICT_ANSI__ |
#include <string.h> |
#include <_ansi.h> |
#include <reent.h> |
#ifndef _REENT_ONLY |
extern char *__strtok_r (char *, const char *, char **, int); |
char * |
_DEFUN (strtok, (s, delim), |
register char *s _AND |
register const char *delim) |
{ |
_REENT_CHECK_MISC(_REENT); |
return __strtok_r (s, delim, &(_REENT_STRTOK_LAST(_REENT)), 1); |
} |
#endif |
/contrib/sdk/sources/libc/string/strtok_r.c |
---|
0,0 → 1,99 |
/* |
* Copyright (c) 1988 Regents of the University of California. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* 1. Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* 3. Neither the name of the University nor the names of its contributors |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
* SUCH DAMAGE. |
*/ |
#include <string.h> |
char * |
_DEFUN (__strtok_r, (s, delim, lasts, skip_leading_delim), |
register char *s _AND |
register const char *delim _AND |
char **lasts _AND |
int skip_leading_delim) |
{ |
register char *spanp; |
register int c, sc; |
char *tok; |
if (s == NULL && (s = *lasts) == NULL) |
return (NULL); |
/* |
* Skip (span) leading delimiters (s += strspn(s, delim), sort of). |
*/ |
cont: |
c = *s++; |
for (spanp = (char *)delim; (sc = *spanp++) != 0;) { |
if (c == sc) { |
if (skip_leading_delim) { |
goto cont; |
} |
else { |
*lasts = s; |
s[-1] = 0; |
return (s - 1); |
} |
} |
} |
if (c == 0) { /* no non-delimiter characters */ |
*lasts = NULL; |
return (NULL); |
} |
tok = s - 1; |
/* |
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of). |
* Note that delim must have one NUL; we stop if we see that, too. |
*/ |
for (;;) { |
c = *s++; |
spanp = (char *)delim; |
do { |
if ((sc = *spanp++) == c) { |
if (c == 0) |
s = NULL; |
else |
s[-1] = 0; |
*lasts = s; |
return (tok); |
} |
} while (sc != 0); |
} |
/* NOTREACHED */ |
} |
char * |
_DEFUN (strtok_r, (s, delim, lasts), |
register char *s _AND |
register const char *delim _AND |
char **lasts) |
{ |
return __strtok_r (s, delim, lasts, 1); |
} |
/contrib/sdk/sources/libc/string/strupr.c |
---|
0,0 → 1,46 |
/* |
FUNCTION |
<<strupr>>---force string to uppercase |
INDEX |
strupr |
ANSI_SYNOPSIS |
#include <string.h> |
char *strupr(char *<[a]>); |
TRAD_SYNOPSIS |
#include <string.h> |
char *strupr(<[a]>) |
char *<[a]>; |
DESCRIPTION |
<<strupr>> converts each character in the string at <[a]> to |
uppercase. |
RETURNS |
<<strupr>> returns its argument, <[a]>. |
PORTABILITY |
<<strupr>> is not widely portable. |
<<strupr>> requires no supporting OS subroutines. |
QUICKREF |
strupr |
*/ |
#include <string.h> |
#include <ctype.h> |
char * |
_DEFUN (strupr, (s), |
char *s) |
{ |
unsigned char *ucs = (unsigned char *) s; |
for ( ; *ucs != '\0'; ucs++) |
{ |
*ucs = toupper(*ucs); |
} |
return s; |
} |
/contrib/sdk/sources/libc/string/u_strerr.c |
---|
0,0 → 1,10 |
#include <_ansi.h> |
char * |
_DEFUN(_user_strerror, (errnum, internal, errptr), |
int errnum _AND |
int internal _AND |
int *errptr) |
{ |
return 0; |
} |
/contrib/sdk/sources/libc/string/vsprintf.c |
---|
0,0 → 1,1379 |
/* |
* linux/lib/vsprintf.c |
* |
* Copyright (C) 1991, 1992 Linus Torvalds |
*/ |
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ |
/* |
* Wirzenius wrote this portably, Torvalds fucked it up :-) |
*/ |
/* |
* Fri Jul 13 2001 Crutcher Dunnavant <crutcher+kernel@datastacks.com> |
* - changed to provide snprintf and vsnprintf functions |
* So Feb 1 16:51:32 CET 2004 Juergen Quade <quade@hsnr.de> |
* - scnprintf and vscnprintf |
*/ |
#define likely(x) __builtin_expect(!!(x), 1) |
#define unlikely(x) __builtin_expect(!!(x), 0) |
#include <string.h> |
#include <ctype.h> |
#include <stdarg.h> |
#include <stdint.h> |
//#include <linux/module.h> |
//#include <types.h> |
//#include <linux/kernel.h> |
//#include <linux/kallsyms.h> |
//#include <linux/uaccess.h> |
//#include <linux/ioport.h> |
//#include <asm/page.h> /* for PAGE_SIZE */ |
//#include <asm/div64.h> |
//#include <asm/sections.h> /* for dereference_function_descriptor() */ |
#define do_div(n, base) \ |
({ \ |
unsigned long __upper, __low, __high, __mod, __base; \ |
__base = (base); \ |
asm("":"=a" (__low), "=d" (__high) : "A" (n)); \ |
__upper = __high; \ |
if (__high) { \ |
__upper = __high % (__base); \ |
__high = __high / (__base); \ |
} \ |
asm("divl %2":"=a" (__low), "=d" (__mod) \ |
: "rm" (__base), "0" (__low), "1" (__upper)); \ |
asm("":"=A" (n) : "a" (__low), "d" (__high)); \ |
__mod; \ |
}) |
#define EPERM 1 /* Operation not permitted */ |
#define ENOENT 2 /* No such file or directory */ |
#define ESRCH 3 /* No such process */ |
#define EINTR 4 /* Interrupted system call */ |
#define EIO 5 /* I/O error */ |
#define ENXIO 6 /* No such device or address */ |
#define E2BIG 7 /* Argument list too long */ |
#define ENOEXEC 8 /* Exec format error */ |
#define EBADF 9 /* Bad file number */ |
#define ECHILD 10 /* No child processes */ |
#define EAGAIN 11 /* Try again */ |
#define ENOMEM 12 /* Out of memory */ |
#define EACCES 13 /* Permission denied */ |
#define EFAULT 14 /* Bad address */ |
#define ENOTBLK 15 /* Block device required */ |
#define EBUSY 16 /* Device or resource busy */ |
#define EEXIST 17 /* File exists */ |
#define EXDEV 18 /* Cross-device link */ |
#define ENODEV 19 /* No such device */ |
#define ENOTDIR 20 /* Not a directory */ |
#define EISDIR 21 /* Is a directory */ |
#define EINVAL 22 /* Invalid argument */ |
#define ENFILE 23 /* File table overflow */ |
#define EMFILE 24 /* Too many open files */ |
#define ENOTTY 25 /* Not a typewriter */ |
#define ETXTBSY 26 /* Text file busy */ |
#define EFBIG 27 /* File too large */ |
#define ENOSPC 28 /* No space left on device */ |
#define ESPIPE 29 /* Illegal seek */ |
#define EROFS 30 /* Read-only file system */ |
#define EMLINK 31 /* Too many links */ |
#define EPIPE 32 /* Broken pipe */ |
#define EDOM 33 /* Math argument out of domain of func */ |
#define ERANGE 34 /* Math result not representable */ |
#define PAGE_SIZE 4096 |
/* Works only for digits and letters, but small and fast */ |
#define TOLOWER(x) ((x) | 0x20) |
static unsigned int simple_guess_base(const char *cp) |
{ |
if (cp[0] == '0') { |
if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2])) |
return 16; |
else |
return 8; |
} else { |
return 10; |
} |
} |
/** |
* simple_strtoul - convert a string to an unsigned long |
* @cp: The start of the string |
* @endp: A pointer to the end of the parsed string will be placed here |
* @base: The number base to use |
*/ |
unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) |
{ |
unsigned long result = 0; |
if (!base) |
base = simple_guess_base(cp); |
if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') |
cp += 2; |
while (isxdigit(*cp)) { |
unsigned int value; |
value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; |
if (value >= base) |
break; |
result = result * base + value; |
cp++; |
} |
if (endp) |
*endp = (char *)cp; |
return result; |
} |
/** |
* simple_strtol - convert a string to a signed long |
* @cp: The start of the string |
* @endp: A pointer to the end of the parsed string will be placed here |
* @base: The number base to use |
*/ |
long simple_strtol(const char *cp, char **endp, unsigned int base) |
{ |
if(*cp == '-') |
return -simple_strtoul(cp + 1, endp, base); |
return simple_strtoul(cp, endp, base); |
} |
/** |
* simple_strtoull - convert a string to an unsigned long long |
* @cp: The start of the string |
* @endp: A pointer to the end of the parsed string will be placed here |
* @base: The number base to use |
*/ |
unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) |
{ |
unsigned long long result = 0; |
if (!base) |
base = simple_guess_base(cp); |
if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x') |
cp += 2; |
while (isxdigit(*cp)) { |
unsigned int value; |
value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10; |
if (value >= base) |
break; |
result = result * base + value; |
cp++; |
} |
if (endp) |
*endp = (char *)cp; |
return result; |
} |
/** |
* simple_strtoll - convert a string to a signed long long |
* @cp: The start of the string |
* @endp: A pointer to the end of the parsed string will be placed here |
* @base: The number base to use |
*/ |
long long simple_strtoll(const char *cp, char **endp, unsigned int base) |
{ |
if(*cp=='-') |
return -simple_strtoull(cp + 1, endp, base); |
return simple_strtoull(cp, endp, base); |
} |
/** |
* strict_strtoul - convert a string to an unsigned long strictly |
* @cp: The string to be converted |
* @base: The number base to use |
* @res: The converted result value |
* |
* strict_strtoul converts a string to an unsigned long only if the |
* string is really an unsigned long string, any string containing |
* any invalid char at the tail will be rejected and -EINVAL is returned, |
* only a newline char at the tail is acceptible because people generally |
* change a module parameter in the following way: |
* |
* echo 1024 > /sys/module/e1000/parameters/copybreak |
* |
* echo will append a newline to the tail. |
* |
* It returns 0 if conversion is successful and *res is set to the converted |
* value, otherwise it returns -EINVAL and *res is set to 0. |
* |
* simple_strtoul just ignores the successive invalid characters and |
* return the converted value of prefix part of the string. |
*/ |
int strict_strtoul(const char *cp, unsigned int base, unsigned long *res) |
{ |
char *tail; |
unsigned long val; |
size_t len; |
*res = 0; |
len = strlen(cp); |
if (len == 0) |
return -EINVAL; |
val = simple_strtoul(cp, &tail, base); |
if (tail == cp) |
return -EINVAL; |
if ((*tail == '\0') || |
((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { |
*res = val; |
return 0; |
} |
return -EINVAL; |
} |
/** |
* strict_strtol - convert a string to a long strictly |
* @cp: The string to be converted |
* @base: The number base to use |
* @res: The converted result value |
* |
* strict_strtol is similiar to strict_strtoul, but it allows the first |
* character of a string is '-'. |
* |
* It returns 0 if conversion is successful and *res is set to the converted |
* value, otherwise it returns -EINVAL and *res is set to 0. |
*/ |
int strict_strtol(const char *cp, unsigned int base, long *res) |
{ |
int ret; |
if (*cp == '-') { |
ret = strict_strtoul(cp + 1, base, (unsigned long *)res); |
if (!ret) |
*res = -(*res); |
} else { |
ret = strict_strtoul(cp, base, (unsigned long *)res); |
} |
return ret; |
} |
/** |
* strict_strtoull - convert a string to an unsigned long long strictly |
* @cp: The string to be converted |
* @base: The number base to use |
* @res: The converted result value |
* |
* strict_strtoull converts a string to an unsigned long long only if the |
* string is really an unsigned long long string, any string containing |
* any invalid char at the tail will be rejected and -EINVAL is returned, |
* only a newline char at the tail is acceptible because people generally |
* change a module parameter in the following way: |
* |
* echo 1024 > /sys/module/e1000/parameters/copybreak |
* |
* echo will append a newline to the tail of the string. |
* |
* It returns 0 if conversion is successful and *res is set to the converted |
* value, otherwise it returns -EINVAL and *res is set to 0. |
* |
* simple_strtoull just ignores the successive invalid characters and |
* return the converted value of prefix part of the string. |
*/ |
int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res) |
{ |
char *tail; |
unsigned long long val; |
size_t len; |
*res = 0; |
len = strlen(cp); |
if (len == 0) |
return -EINVAL; |
val = simple_strtoull(cp, &tail, base); |
if (tail == cp) |
return -EINVAL; |
if ((*tail == '\0') || |
((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) { |
*res = val; |
return 0; |
} |
return -EINVAL; |
} |
/** |
* strict_strtoll - convert a string to a long long strictly |
* @cp: The string to be converted |
* @base: The number base to use |
* @res: The converted result value |
* |
* strict_strtoll is similiar to strict_strtoull, but it allows the first |
* character of a string is '-'. |
* |
* It returns 0 if conversion is successful and *res is set to the converted |
* value, otherwise it returns -EINVAL and *res is set to 0. |
*/ |
int strict_strtoll(const char *cp, unsigned int base, long long *res) |
{ |
int ret; |
if (*cp == '-') { |
ret = strict_strtoull(cp + 1, base, (unsigned long long *)res); |
if (!ret) |
*res = -(*res); |
} else { |
ret = strict_strtoull(cp, base, (unsigned long long *)res); |
} |
return ret; |
} |
static int skip_atoi(const char **s) |
{ |
int i=0; |
while (isdigit(**s)) |
i = i*10 + *((*s)++) - '0'; |
return i; |
} |
/* Decimal conversion is by far the most typical, and is used |
* for /proc and /sys data. This directly impacts e.g. top performance |
* with many processes running. We optimize it for speed |
* using code from |
* http://www.cs.uiowa.edu/~jones/bcd/decimal.html |
* (with permission from the author, Douglas W. Jones). */ |
/* Formats correctly any integer in [0,99999]. |
* Outputs from one to five digits depending on input. |
* On i386 gcc 4.1.2 -O2: ~250 bytes of code. */ |
static char* put_dec_trunc(char *buf, unsigned q) |
{ |
unsigned d3, d2, d1, d0; |
d1 = (q>>4) & 0xf; |
d2 = (q>>8) & 0xf; |
d3 = (q>>12); |
d0 = 6*(d3 + d2 + d1) + (q & 0xf); |
q = (d0 * 0xcd) >> 11; |
d0 = d0 - 10*q; |
*buf++ = d0 + '0'; /* least significant digit */ |
d1 = q + 9*d3 + 5*d2 + d1; |
if (d1 != 0) { |
q = (d1 * 0xcd) >> 11; |
d1 = d1 - 10*q; |
*buf++ = d1 + '0'; /* next digit */ |
d2 = q + 2*d2; |
if ((d2 != 0) || (d3 != 0)) { |
q = (d2 * 0xd) >> 7; |
d2 = d2 - 10*q; |
*buf++ = d2 + '0'; /* next digit */ |
d3 = q + 4*d3; |
if (d3 != 0) { |
q = (d3 * 0xcd) >> 11; |
d3 = d3 - 10*q; |
*buf++ = d3 + '0'; /* next digit */ |
if (q != 0) |
*buf++ = q + '0'; /* most sign. digit */ |
} |
} |
} |
return buf; |
} |
/* Same with if's removed. Always emits five digits */ |
static char* put_dec_full(char *buf, unsigned q) |
{ |
/* BTW, if q is in [0,9999], 8-bit ints will be enough, */ |
/* but anyway, gcc produces better code with full-sized ints */ |
unsigned d3, d2, d1, d0; |
d1 = (q>>4) & 0xf; |
d2 = (q>>8) & 0xf; |
d3 = (q>>12); |
/* Possible ways to approx. divide by 10 */ |
/* gcc -O2 replaces multiply with shifts and adds */ |
// (x * 0xcd) >> 11: 11001101 - shorter code than * 0x67 (on i386) |
// (x * 0x67) >> 10: 1100111 |
// (x * 0x34) >> 9: 110100 - same |
// (x * 0x1a) >> 8: 11010 - same |
// (x * 0x0d) >> 7: 1101 - same, shortest code (on i386) |
d0 = 6*(d3 + d2 + d1) + (q & 0xf); |
q = (d0 * 0xcd) >> 11; |
d0 = d0 - 10*q; |
*buf++ = d0 + '0'; |
d1 = q + 9*d3 + 5*d2 + d1; |
q = (d1 * 0xcd) >> 11; |
d1 = d1 - 10*q; |
*buf++ = d1 + '0'; |
d2 = q + 2*d2; |
q = (d2 * 0xd) >> 7; |
d2 = d2 - 10*q; |
*buf++ = d2 + '0'; |
d3 = q + 4*d3; |
q = (d3 * 0xcd) >> 11; /* - shorter code */ |
/* q = (d3 * 0x67) >> 10; - would also work */ |
d3 = d3 - 10*q; |
*buf++ = d3 + '0'; |
*buf++ = q + '0'; |
return buf; |
} |
/* No inlining helps gcc to use registers better */ |
static char* put_dec(char *buf, unsigned long long num) |
{ |
while (1) { |
unsigned rem; |
if (num < 100000) |
return put_dec_trunc(buf, num); |
rem = do_div(num, 100000); |
buf = put_dec_full(buf, rem); |
} |
} |
#define ZEROPAD 1 /* pad with zero */ |
#define SIGN 2 /* unsigned/signed long */ |
#define PLUS 4 /* show plus */ |
#define SPACE 8 /* space if plus */ |
#define LEFT 16 /* left justified */ |
#define SMALL 32 /* Must be 32 == 0x20 */ |
#define SPECIAL 64 /* 0x */ |
enum format_type { |
FORMAT_TYPE_NONE, /* Just a string part */ |
FORMAT_TYPE_WIDTH, |
FORMAT_TYPE_PRECISION, |
FORMAT_TYPE_CHAR, |
FORMAT_TYPE_STR, |
FORMAT_TYPE_PTR, |
FORMAT_TYPE_PERCENT_CHAR, |
FORMAT_TYPE_INVALID, |
FORMAT_TYPE_LONG_LONG, |
FORMAT_TYPE_ULONG, |
FORMAT_TYPE_LONG, |
FORMAT_TYPE_UBYTE, |
FORMAT_TYPE_BYTE, |
FORMAT_TYPE_USHORT, |
FORMAT_TYPE_SHORT, |
FORMAT_TYPE_UINT, |
FORMAT_TYPE_INT, |
FORMAT_TYPE_NRCHARS, |
FORMAT_TYPE_SIZE_T, |
FORMAT_TYPE_PTRDIFF |
}; |
struct printf_spec { |
enum format_type type; |
int flags; /* flags to number() */ |
int field_width; /* width of output field */ |
int base; |
int precision; /* # of digits/chars */ |
int qualifier; |
}; |
static char *number(char *buf, char *end, unsigned long long num, |
struct printf_spec spec) |
{ |
/* we are called with base 8, 10 or 16, only, thus don't need "G..." */ |
static const char digits[16] = "0123456789ABCDEF"; /* "GHIJKLMNOPQRSTUVWXYZ"; */ |
char tmp[66]; |
char sign; |
char locase; |
int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10); |
int i; |
/* locase = 0 or 0x20. ORing digits or letters with 'locase' |
* produces same digits or (maybe lowercased) letters */ |
locase = (spec.flags & SMALL); |
if (spec.flags & LEFT) |
spec.flags &= ~ZEROPAD; |
sign = 0; |
if (spec.flags & SIGN) { |
if ((signed long long) num < 0) { |
sign = '-'; |
num = - (signed long long) num; |
spec.field_width--; |
} else if (spec.flags & PLUS) { |
sign = '+'; |
spec.field_width--; |
} else if (spec.flags & SPACE) { |
sign = ' '; |
spec.field_width--; |
} |
} |
if (need_pfx) { |
spec.field_width--; |
if (spec.base == 16) |
spec.field_width--; |
} |
/* generate full string in tmp[], in reverse order */ |
i = 0; |
if (num == 0) |
tmp[i++] = '0'; |
/* Generic code, for any base: |
else do { |
tmp[i++] = (digits[do_div(num,base)] | locase); |
} while (num != 0); |
*/ |
else if (spec.base != 10) { /* 8 or 16 */ |
int mask = spec.base - 1; |
int shift = 3; |
if (spec.base == 16) shift = 4; |
do { |
tmp[i++] = (digits[((unsigned char)num) & mask] | locase); |
num >>= shift; |
} while (num); |
} else { /* base 10 */ |
i = put_dec(tmp, num) - tmp; |
} |
/* printing 100 using %2d gives "100", not "00" */ |
if (i > spec.precision) |
spec.precision = i; |
/* leading space padding */ |
spec.field_width -= spec.precision; |
if (!(spec.flags & (ZEROPAD+LEFT))) { |
while(--spec.field_width >= 0) { |
if (buf < end) |
*buf = ' '; |
++buf; |
} |
} |
/* sign */ |
if (sign) { |
if (buf < end) |
*buf = sign; |
++buf; |
} |
/* "0x" / "0" prefix */ |
if (need_pfx) { |
if (buf < end) |
*buf = '0'; |
++buf; |
if (spec.base == 16) { |
if (buf < end) |
*buf = ('X' | locase); |
++buf; |
} |
} |
/* zero or space padding */ |
if (!(spec.flags & LEFT)) { |
char c = (spec.flags & ZEROPAD) ? '0' : ' '; |
while (--spec.field_width >= 0) { |
if (buf < end) |
*buf = c; |
++buf; |
} |
} |
/* hmm even more zero padding? */ |
while (i <= --spec.precision) { |
if (buf < end) |
*buf = '0'; |
++buf; |
} |
/* actual digits of result */ |
while (--i >= 0) { |
if (buf < end) |
*buf = tmp[i]; |
++buf; |
} |
/* trailing space padding */ |
while (--spec.field_width >= 0) { |
if (buf < end) |
*buf = ' '; |
++buf; |
} |
return buf; |
} |
static char *string(char *buf, char *end, char *s, struct printf_spec spec) |
{ |
int len, i; |
if ((unsigned long)s < PAGE_SIZE) |
s = "<NULL>"; |
len = strnlen(s, spec.precision); |
if (!(spec.flags & LEFT)) { |
while (len < spec.field_width--) { |
if (buf < end) |
*buf = ' '; |
++buf; |
} |
} |
for (i = 0; i < len; ++i) { |
if (buf < end) |
*buf = *s; |
++buf; ++s; |
} |
while (len < spec.field_width--) { |
if (buf < end) |
*buf = ' '; |
++buf; |
} |
return buf; |
} |
/* |
* Show a '%p' thing. |
*/ |
static char *pointer(const char *fmt, char *buf, char *end, void *ptr, |
struct printf_spec spec) |
{ |
if (!ptr) |
return string(buf, end, "(null)", spec); |
spec.flags |= SMALL; |
if (spec.field_width == -1) { |
spec.field_width = 2*sizeof(void *); |
spec.flags |= ZEROPAD; |
} |
spec.base = 16; |
return number(buf, end, (unsigned long) ptr, spec); |
} |
/* |
* Helper function to decode printf style format. |
* Each call decode a token from the format and return the |
* number of characters read (or likely the delta where it wants |
* to go on the next call). |
* The decoded token is returned through the parameters |
* |
* 'h', 'l', or 'L' for integer fields |
* 'z' support added 23/7/1999 S.H. |
* 'z' changed to 'Z' --davidm 1/25/99 |
* 't' added for ptrdiff_t |
* |
* @fmt: the format string |
* @type of the token returned |
* @flags: various flags such as +, -, # tokens.. |
* @field_width: overwritten width |
* @base: base of the number (octal, hex, ...) |
* @precision: precision of a number |
* @qualifier: qualifier of a number (long, size_t, ...) |
*/ |
static int format_decode(const char *fmt, struct printf_spec *spec) |
{ |
const char *start = fmt; |
/* we finished early by reading the field width */ |
if (spec->type == FORMAT_TYPE_WIDTH) { |
if (spec->field_width < 0) { |
spec->field_width = -spec->field_width; |
spec->flags |= LEFT; |
} |
spec->type = FORMAT_TYPE_NONE; |
goto precision; |
} |
/* we finished early by reading the precision */ |
if (spec->type == FORMAT_TYPE_PRECISION) { |
if (spec->precision < 0) |
spec->precision = 0; |
spec->type = FORMAT_TYPE_NONE; |
goto qualifier; |
} |
/* By default */ |
spec->type = FORMAT_TYPE_NONE; |
for (; *fmt ; ++fmt) { |
if (*fmt == '%') |
break; |
} |
/* Return the current non-format string */ |
if (fmt != start || !*fmt) |
return fmt - start; |
/* Process flags */ |
spec->flags = 0; |
while (1) { /* this also skips first '%' */ |
int found = 1; |
++fmt; |
switch (*fmt) { |
case '-': spec->flags |= LEFT; break; |
case '+': spec->flags |= PLUS; break; |
case ' ': spec->flags |= SPACE; break; |
case '#': spec->flags |= SPECIAL; break; |
case '0': spec->flags |= ZEROPAD; break; |
default: found = 0; |
} |
if (!found) |
break; |
} |
/* get field width */ |
spec->field_width = -1; |
if (isdigit(*fmt)) |
spec->field_width = skip_atoi(&fmt); |
else if (*fmt == '*') { |
/* it's the next argument */ |
spec->type = FORMAT_TYPE_WIDTH; |
return ++fmt - start; |
} |
precision: |
/* get the precision */ |
spec->precision = -1; |
if (*fmt == '.') { |
++fmt; |
if (isdigit(*fmt)) { |
spec->precision = skip_atoi(&fmt); |
if (spec->precision < 0) |
spec->precision = 0; |
} else if (*fmt == '*') { |
/* it's the next argument */ |
spec->type = FORMAT_TYPE_PRECISION; |
return ++fmt - start; |
} |
} |
qualifier: |
/* get the conversion qualifier */ |
spec->qualifier = -1; |
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || |
*fmt == 'Z' || *fmt == 'z' || *fmt == 't') { |
spec->qualifier = *fmt++; |
if (unlikely(spec->qualifier == *fmt)) { |
if (spec->qualifier == 'l') { |
spec->qualifier = 'L'; |
++fmt; |
} else if (spec->qualifier == 'h') { |
spec->qualifier = 'H'; |
++fmt; |
} |
} |
} |
/* default base */ |
spec->base = 10; |
switch (*fmt) { |
case 'c': |
spec->type = FORMAT_TYPE_CHAR; |
return ++fmt - start; |
case 's': |
spec->type = FORMAT_TYPE_STR; |
return ++fmt - start; |
case 'p': |
spec->type = FORMAT_TYPE_PTR; |
return fmt - start; |
/* skip alnum */ |
case 'n': |
spec->type = FORMAT_TYPE_NRCHARS; |
return ++fmt - start; |
case '%': |
spec->type = FORMAT_TYPE_PERCENT_CHAR; |
return ++fmt - start; |
/* integer number formats - set up the flags and "break" */ |
case 'o': |
spec->base = 8; |
break; |
case 'x': |
spec->flags |= SMALL; |
case 'X': |
spec->base = 16; |
break; |
case 'd': |
case 'i': |
spec->flags |= SIGN; |
case 'u': |
break; |
default: |
spec->type = FORMAT_TYPE_INVALID; |
return fmt - start; |
} |
if (spec->qualifier == 'L') |
spec->type = FORMAT_TYPE_LONG_LONG; |
else if (spec->qualifier == 'l') { |
if (spec->flags & SIGN) |
spec->type = FORMAT_TYPE_LONG; |
else |
spec->type = FORMAT_TYPE_ULONG; |
} else if (spec->qualifier == 'Z' || spec->qualifier == 'z') { |
spec->type = FORMAT_TYPE_SIZE_T; |
} else if (spec->qualifier == 't') { |
spec->type = FORMAT_TYPE_PTRDIFF; |
} else if (spec->qualifier == 'H') { |
if (spec->flags & SIGN) |
spec->type = FORMAT_TYPE_BYTE; |
else |
spec->type = FORMAT_TYPE_UBYTE; |
} else if (spec->qualifier == 'h') { |
if (spec->flags & SIGN) |
spec->type = FORMAT_TYPE_SHORT; |
else |
spec->type = FORMAT_TYPE_USHORT; |
} else { |
if (spec->flags & SIGN) |
spec->type = FORMAT_TYPE_INT; |
else |
spec->type = FORMAT_TYPE_UINT; |
} |
return ++fmt - start; |
} |
/** |
* vsnprintf - Format a string and place it in a buffer |
* @buf: The buffer to place the result into |
* @size: The size of the buffer, including the trailing null space |
* @fmt: The format string to use |
* @args: Arguments for the format string |
* |
* |
* The return value is the number of characters which would |
* be generated for the given input, excluding the trailing |
* '\0', as per ISO C99. If you want to have the exact |
* number of characters written into @buf as return value |
* (not including the trailing '\0'), use vscnprintf(). If the |
* return is greater than or equal to @size, the resulting |
* string is truncated. |
* |
* Call this function if you are already dealing with a va_list. |
* You probably want snprintf() instead. |
*/ |
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) |
{ |
unsigned long long num; |
char *str, *end, c; |
int read; |
struct printf_spec spec = {0}; |
/* Reject out-of-range values early. Large positive sizes are |
used for unknown buffer sizes. */ |
if (unlikely((int) size < 0)) { |
/* There can be only one.. */ |
static char warn = 1; |
// WARN_ON(warn); |
warn = 0; |
return 0; |
} |
str = buf; |
end = buf + size; |
/* Make sure end is always >= buf */ |
if (end < buf) { |
end = ((void *)-1); |
size = end - buf; |
} |
while (*fmt) { |
const char *old_fmt = fmt; |
read = format_decode(fmt, &spec); |
fmt += read; |
switch (spec.type) { |
case FORMAT_TYPE_NONE: { |
int copy = read; |
if (str < end) { |
if (copy > end - str) |
copy = end - str; |
memcpy(str, old_fmt, copy); |
} |
str += read; |
break; |
} |
case FORMAT_TYPE_WIDTH: |
spec.field_width = va_arg(args, int); |
break; |
case FORMAT_TYPE_PRECISION: |
spec.precision = va_arg(args, int); |
break; |
case FORMAT_TYPE_CHAR: |
if (!(spec.flags & LEFT)) { |
while (--spec.field_width > 0) { |
if (str < end) |
*str = ' '; |
++str; |
} |
} |
c = (unsigned char) va_arg(args, int); |
if (str < end) |
*str = c; |
++str; |
while (--spec.field_width > 0) { |
if (str < end) |
*str = ' '; |
++str; |
} |
break; |
case FORMAT_TYPE_STR: |
str = string(str, end, va_arg(args, char *), spec); |
break; |
case FORMAT_TYPE_PTR: |
str = pointer(fmt+1, str, end, va_arg(args, void *), |
spec); |
while (isalnum(*fmt)) |
fmt++; |
break; |
case FORMAT_TYPE_PERCENT_CHAR: |
if (str < end) |
*str = '%'; |
++str; |
break; |
case FORMAT_TYPE_INVALID: |
if (str < end) |
*str = '%'; |
++str; |
break; |
case FORMAT_TYPE_NRCHARS: { |
int qualifier = spec.qualifier; |
if (qualifier == 'l') { |
long *ip = va_arg(args, long *); |
*ip = (str - buf); |
} else if (qualifier == 'Z' || |
qualifier == 'z') { |
size_t *ip = va_arg(args, size_t *); |
*ip = (str - buf); |
} else { |
int *ip = va_arg(args, int *); |
*ip = (str - buf); |
} |
break; |
} |
default: |
switch (spec.type) { |
case FORMAT_TYPE_LONG_LONG: |
num = va_arg(args, long long); |
break; |
case FORMAT_TYPE_ULONG: |
num = va_arg(args, unsigned long); |
break; |
case FORMAT_TYPE_LONG: |
num = va_arg(args, long); |
break; |
case FORMAT_TYPE_SIZE_T: |
num = va_arg(args, size_t); |
break; |
// case FORMAT_TYPE_PTRDIFF: |
// num = va_arg(args, ptrdiff_t); |
// break; |
case FORMAT_TYPE_UBYTE: |
num = (unsigned char) va_arg(args, int); |
break; |
case FORMAT_TYPE_BYTE: |
num = (signed char) va_arg(args, int); |
break; |
case FORMAT_TYPE_USHORT: |
num = (unsigned short) va_arg(args, int); |
break; |
case FORMAT_TYPE_SHORT: |
num = (short) va_arg(args, int); |
break; |
case FORMAT_TYPE_INT: |
num = (int) va_arg(args, int); |
break; |
default: |
num = va_arg(args, unsigned int); |
} |
str = number(str, end, num, spec); |
} |
} |
if (size > 0) { |
if (str < end) |
*str = '\0'; |
else |
end[-1] = '\0'; |
} |
/* the trailing null byte doesn't count towards the total */ |
return str-buf; |
} |
/** |
* snprintf - Format a string and place it in a buffer |
* @buf: The buffer to place the result into |
* @size: The size of the buffer, including the trailing null space |
* @fmt: The format string to use |
* @...: Arguments for the format string |
* |
* The return value is the number of characters which would be |
* generated for the given input, excluding the trailing null, |
* as per ISO C99. If the return is greater than or equal to |
* @size, the resulting string is truncated. |
* |
* See the vsnprintf() documentation for format string extensions over C99. |
*/ |
int snprintf(char * buf, size_t size, const char *fmt, ...) |
{ |
va_list args; |
int i; |
va_start(args, fmt); |
i=vsnprintf(buf,size,fmt,args); |
va_end(args); |
return i; |
} |
/** |
* scnprintf - Format a string and place it in a buffer |
* @buf: The buffer to place the result into |
* @size: The size of the buffer, including the trailing null space |
* @fmt: The format string to use |
* @...: Arguments for the format string |
* |
* The return value is the number of characters written into @buf not including |
* the trailing '\0'. If @size is <= 0 the function returns 0. |
*/ |
int scnprintf(char * buf, size_t size, const char *fmt, ...) |
{ |
va_list args; |
int i; |
va_start(args, fmt); |
i = vsnprintf(buf, size, fmt, args); |
va_end(args); |
return (i >= size) ? (size - 1) : i; |
} |
/** |
* vsprintf - Format a string and place it in a buffer |
* @buf: The buffer to place the result into |
* @fmt: The format string to use |
* @args: Arguments for the format string |
* |
* The function returns the number of characters written |
* into @buf. Use vsnprintf() or vscnprintf() in order to avoid |
* buffer overflows. |
* |
* Call this function if you are already dealing with a va_list. |
* You probably want sprintf() instead. |
* |
* See the vsnprintf() documentation for format string extensions over C99. |
*/ |
int vsprintf(char *buf, const char *fmt, va_list args) |
{ |
return vsnprintf(buf, __INT_MAX__, fmt, args); |
} |
/** |
* sprintf - Format a string and place it in a buffer |
* @buf: The buffer to place the result into |
* @fmt: The format string to use |
* @...: Arguments for the format string |
* |
* The function returns the number of characters written |
* into @buf. Use snprintf() or scnprintf() in order to avoid |
* buffer overflows. |
* |
* See the vsnprintf() documentation for format string extensions over C99. |
*/ |
int sprintf(char * buf, const char *fmt, ...) |
{ |
va_list args; |
int i; |
va_start(args, fmt); |
i=vsnprintf(buf, __INT_MAX__, fmt, args); |
va_end(args); |
return i; |
} |
static inline |
void api_putc(char c) |
{ |
if (c == '\n') api_putc('\r'); |
__asm__ __volatile__( |
"int $0x40" |
::"a"(63),"b"(1),"c"(c)); |
} |
int API print(const char *fmt,...) |
{ |
char buf[256]; |
va_list args; |
int retval; |
int i; |
va_start(args, fmt); |
i = vsnprintf(buf, 256, fmt, args); |
va_end(args); |
retval = (i >= 256) ? (256 - 1) : i; |
for(i = 0; i< retval; i++) |
api_putc(buf[i]); |
return retval; |
}; |
#if 0 |
/** |
* vsscanf - Unformat a buffer into a list of arguments |
* @buf: input buffer |
* @fmt: format of buffer |
* @args: arguments |
*/ |
int vsscanf(const char * buf, const char * fmt, va_list args) |
{ |
const char *str = buf; |
char *next; |
char digit; |
int num = 0; |
int qualifier; |
int base; |
int field_width; |
int is_sign = 0; |
while(*fmt && *str) { |
/* skip any white space in format */ |
/* white space in format matchs any amount of |
* white space, including none, in the input. |
*/ |
if (isspace(*fmt)) { |
while (isspace(*fmt)) |
++fmt; |
while (isspace(*str)) |
++str; |
} |
/* anything that is not a conversion must match exactly */ |
if (*fmt != '%' && *fmt) { |
if (*fmt++ != *str++) |
break; |
continue; |
} |
if (!*fmt) |
break; |
++fmt; |
/* skip this conversion. |
* advance both strings to next white space |
*/ |
if (*fmt == '*') { |
while (!isspace(*fmt) && *fmt) |
fmt++; |
while (!isspace(*str) && *str) |
str++; |
continue; |
} |
/* get field width */ |
field_width = -1; |
if (isdigit(*fmt)) |
field_width = skip_atoi(&fmt); |
/* get conversion qualifier */ |
qualifier = -1; |
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || |
*fmt == 'Z' || *fmt == 'z') { |
qualifier = *fmt++; |
if (unlikely(qualifier == *fmt)) { |
if (qualifier == 'h') { |
qualifier = 'H'; |
fmt++; |
} else if (qualifier == 'l') { |
qualifier = 'L'; |
fmt++; |
} |
} |
} |
base = 10; |
is_sign = 0; |
if (!*fmt || !*str) |
break; |
switch(*fmt++) { |
case 'c': |
{ |
char *s = (char *) va_arg(args,char*); |
if (field_width == -1) |
field_width = 1; |
do { |
*s++ = *str++; |
} while (--field_width > 0 && *str); |
num++; |
} |
continue; |
case 's': |
{ |
char *s = (char *) va_arg(args, char *); |
if(field_width == -1) |
field_width = INT_MAX; |
/* first, skip leading white space in buffer */ |
while (isspace(*str)) |
str++; |
/* now copy until next white space */ |
while (*str && !isspace(*str) && field_width--) { |
*s++ = *str++; |
} |
*s = '\0'; |
num++; |
} |
continue; |
case 'n': |
/* return number of characters read so far */ |
{ |
int *i = (int *)va_arg(args,int*); |
*i = str - buf; |
} |
continue; |
case 'o': |
base = 8; |
break; |
case 'x': |
case 'X': |
base = 16; |
break; |
case 'i': |
base = 0; |
case 'd': |
is_sign = 1; |
case 'u': |
break; |
case '%': |
/* looking for '%' in str */ |
if (*str++ != '%') |
return num; |
continue; |
default: |
/* invalid format; stop here */ |
return num; |
} |
/* have some sort of integer conversion. |
* first, skip white space in buffer. |
*/ |
while (isspace(*str)) |
str++; |
digit = *str; |
if (is_sign && digit == '-') |
digit = *(str + 1); |
if (!digit |
|| (base == 16 && !isxdigit(digit)) |
|| (base == 10 && !isdigit(digit)) |
|| (base == 8 && (!isdigit(digit) || digit > '7')) |
|| (base == 0 && !isdigit(digit))) |
break; |
switch(qualifier) { |
case 'H': /* that's 'hh' in format */ |
if (is_sign) { |
signed char *s = (signed char *) va_arg(args,signed char *); |
*s = (signed char) simple_strtol(str,&next,base); |
} else { |
unsigned char *s = (unsigned char *) va_arg(args, unsigned char *); |
*s = (unsigned char) simple_strtoul(str, &next, base); |
} |
break; |
case 'h': |
if (is_sign) { |
short *s = (short *) va_arg(args,short *); |
*s = (short) simple_strtol(str,&next,base); |
} else { |
unsigned short *s = (unsigned short *) va_arg(args, unsigned short *); |
*s = (unsigned short) simple_strtoul(str, &next, base); |
} |
break; |
case 'l': |
if (is_sign) { |
long *l = (long *) va_arg(args,long *); |
*l = simple_strtol(str,&next,base); |
} else { |
unsigned long *l = (unsigned long*) va_arg(args,unsigned long*); |
*l = simple_strtoul(str,&next,base); |
} |
break; |
case 'L': |
if (is_sign) { |
long long *l = (long long*) va_arg(args,long long *); |
*l = simple_strtoll(str,&next,base); |
} else { |
unsigned long long *l = (unsigned long long*) va_arg(args,unsigned long long*); |
*l = simple_strtoull(str,&next,base); |
} |
break; |
case 'Z': |
case 'z': |
{ |
size_t *s = (size_t*) va_arg(args,size_t*); |
*s = (size_t) simple_strtoul(str,&next,base); |
} |
break; |
default: |
if (is_sign) { |
int *i = (int *) va_arg(args, int*); |
*i = (int) simple_strtol(str,&next,base); |
} else { |
unsigned int *i = (unsigned int*) va_arg(args, unsigned int*); |
*i = (unsigned int) simple_strtoul(str,&next,base); |
} |
break; |
} |
num++; |
if (!next) |
break; |
str = next; |
} |
/* |
* Now we've come all the way through so either the input string or the |
* format ended. In the former case, there can be a %n at the current |
* position in the format that needs to be filled. |
*/ |
if (*fmt == '%' && *(fmt + 1) == 'n') { |
int *p = (int *)va_arg(args, int *); |
*p = str - buf; |
} |
return num; |
} |
#endif |
/contrib/sdk/sources/libc/sys/create.c |
---|
0,0 → 1,25 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int create_file(const char *path) |
{ |
int retval; |
__asm__ __volatile__ ( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %0, 1(%%esp) \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $2 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"r" (path) |
:"ebx"); |
return retval; |
}; |
/contrib/sdk/sources/libc/sys/delete.c |
---|
0,0 → 1,26 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int delete_file(const char *path) |
{ |
int retval; |
__asm__ __volatile__ ( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %0, 1(%%esp) \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $8 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"r" (path) |
:"ebx"); |
return retval; |
}; |
/contrib/sdk/sources/libc/sys/finfo.c |
---|
0,0 → 1,26 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int get_fileinfo(const char *path, fileinfo_t *info) |
{ |
int retval; |
__asm__ __volatile__ ( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %1, 1(%%esp) \n\t" |
"pushl %%ebx \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $5 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"r" (path), "b" (info)); |
return retval; |
}; |
/contrib/sdk/sources/libc/sys/fload.c |
---|
0,0 → 1,37 |
#include <sys/types.h> |
#include <stdint.h> |
#include <sys/kos_io.h> |
void *load_file(const char *path, size_t *len) |
{ |
fileinfo_t info; |
size_t bytes; |
void *file = NULL; |
if( len) *len = 0; |
if( !get_fileinfo(path, &info) ) |
{ |
file = (void*)user_alloc( info.size ); |
read_file(path, file, 0, info.size, &bytes ); |
if( bytes == info.size ) |
{ |
if ( *(uint32_t*)file == 0x4B43504B ) |
{ |
void *tmp = NULL; |
info.size = ((size_t*)file)[1]; |
tmp = (void*)user_alloc(info.size); |
unpack(file, tmp); |
user_free(file); |
file = tmp; |
} |
if(len) *len = info.size; |
}; |
}; |
return file; |
}; |
/contrib/sdk/sources/libc/sys/fsize.c |
---|
0,0 → 1,26 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int set_file_size(const char *path, unsigned size) |
{ |
int retval; |
__asm__ __volatile__( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %%eax, 1(%%esp) \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"pushl %%ebx \n\t" |
"push $4 \n\t" |
"movl %%esp, %%ebx \n\t" |
"movl $70, %%eax \n\t" |
"int $0x40 \n\t" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"a" (path), "b" (size)); |
return retval; |
}; |
/contrib/sdk/sources/libc/sys/read.c |
---|
0,0 → 1,31 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int read_file(const char *path, void *buff, |
size_t offset, size_t count, size_t *reads) |
{ |
int retval; |
int d0; |
__asm__ __volatile__( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %%eax, 1(%%esp) \n\t" |
"pushl %%ebx \n\t" |
"pushl %%edx \n\t" |
"pushl $0 \n\t" |
"pushl %%ecx \n\t" |
"pushl $0 \n\t" |
"movl %%esp, %%ebx \n\t" |
"mov $70, %%eax \n\t" |
"int $0x40 \n\t" |
"testl %%esi, %%esi \n\t" |
"jz 1f \n\t" |
"movl %%ebx, (%%esi) \n\t" |
"1:" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(reads)); |
return retval; |
}; |
/contrib/sdk/sources/libc/sys/write.c |
---|
0,0 → 1,29 |
#include <sys/types.h> |
#include <sys/kos_io.h> |
int write_file(const char *path,const void *buff, |
size_t offset, size_t count, size_t *writes) |
{ |
int retval; |
__asm__ __volatile__( |
"pushl $0 \n\t" |
"pushl $0 \n\t" |
"movl %%eax, 1(%%esp) \n\t" |
"pushl %%ebx \n\t" |
"pushl %%edx \n\t" |
"pushl $0 \n\t" |
"pushl %%ecx \n\t" |
"pushl $3 \n\t" |
"movl %%esp, %%ebx \n\t" |
"mov $70, %%eax \n\t" |
"int $0x40 \n\t" |
"testl %%esi, %%esi \n\t" |
"jz 1f \n\t" |
"movl %%ebx, (%%esi) \n\t" |
"1:" |
"addl $28, %%esp \n\t" |
:"=a" (retval) |
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(writes)); |
return retval; |
}; |
/contrib/sdk/sources/libc/system.env |
---|
0,0 → 1,0 |
PATH=/hd0/1/Lib/:/sys/lib/ |
/contrib/sdk/sources/libc/tests/error.c |
---|
0,0 → 1,117 |
/* Error handler for noninteractive utilities |
Copyright (C) 1990-1998, 2000-2005, 2006 Free Software Foundation, Inc. |
This file is part of the GNU C Library. |
The GNU C Library is free software; you can redistribute it and/or |
modify it under the terms of the GNU Lesser General Public |
License as published by the Free Software Foundation; either |
version 2.1 of the License, or (at your option) any later version. |
The GNU C Library is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
Lesser General Public License for more details. |
You should have received a copy of the GNU Lesser General Public |
License along with the GNU C Library; if not, write to the Free |
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
02111-1307 USA. */ |
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */ |
#include <stdarg.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include <errno.h> |
#include "error.h" |
/* This variable is incremented each time `error' is called. */ |
unsigned int error_message_count; |
char *strerror_r (); |
/* The calling program should define program_name and set it to the |
name of the executing program. */ |
//extern char *program_name; |
static void |
print_errno_message (int errnum) |
{ |
char const *s; |
s = strerror (errnum); |
fprintf (stderr, ": %s", s); |
} |
static void |
error_tail (int status, int errnum, const char *message, va_list args) |
{ |
vfprintf (stderr, message, args); |
va_end (args); |
++error_message_count; |
if (errnum) |
print_errno_message (errnum); |
putc ('\n', stderr); |
fflush (stderr); |
if (status) |
exit (status); |
} |
/* Print the program name and error message MESSAGE, which is a printf-style |
format string with optional args. |
If ERRNUM is nonzero, print its corresponding system error message. |
Exit with status STATUS if it is nonzero. */ |
void |
error (int status, int errnum, const char *message, ...) |
{ |
va_list args; |
// fflush (stdout); |
// fprintf (stderr, "%s: ", program_name); |
va_start (args, message); |
error_tail (status, errnum, message, args); |
}; |
/* Sometimes we want to have at most one error per line. This |
variable controls whether this mode is selected or not. */ |
int error_one_per_line; |
void |
error_at_line (int status, int errnum, const char *file_name, |
unsigned int line_number, const char *message, ...) |
{ |
va_list args; |
if (error_one_per_line) |
{ |
static const char *old_file_name; |
static unsigned int old_line_number; |
if (old_line_number == line_number |
&& (file_name == old_file_name |
|| strcmp (old_file_name, file_name) == 0)) |
/* Simply return and print nothing. */ |
return; |
old_file_name = file_name; |
old_line_number = line_number; |
} |
// fflush (stdout); |
fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", |
file_name, line_number); |
va_start (args, message); |
error_tail (status, errnum, message, args); |
} |
/contrib/sdk/sources/libc/tests/error.h |
---|
0,0 → 1,47 |
/* Declaration for error-reporting function |
Copyright (C) 1995,1996,1997,2003,2006,2007 Free Software Foundation, Inc. |
This file is part of the GNU C Library. |
The GNU C Library is free software; you can redistribute it and/or |
modify it under the terms of the GNU Lesser General Public |
License as published by the Free Software Foundation; either |
version 2.1 of the License, or (at your option) any later version. |
The GNU C Library is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
Lesser General Public License for more details. |
You should have received a copy of the GNU Lesser General Public |
License along with the GNU C Library; if not, write to the Free |
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
02111-1307 USA. */ |
#ifndef _ERROR_H |
#define _ERROR_H 1 |
/* Print a message with `fprintf (stderr, FORMAT, ...)'; |
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). |
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ |
extern void error (int __status, int __errnum, __const char *__format, ...) |
__attribute__ ((__format__ (__printf__, 3, 4))); |
extern void error_at_line (int __status, int __errnum, __const char *__fname, |
unsigned int __lineno, __const char *__format, ...) |
__attribute__ ((__format__ (__printf__, 5, 6))); |
/* If NULL, error will flush stdout, then print on stderr the program |
name, a colon and a space. Otherwise, error will call this |
function without parameters instead. */ |
extern void (*error_print_progname) (void); |
/* This variable is incremented each time `error' is called. */ |
extern unsigned int error_message_count; |
/* Sometimes we want to have at most one error per line. This |
variable controls whether this mode is selected or not. */ |
extern int error_one_per_line; |
#endif /* error.h */ |
/contrib/sdk/sources/libc/tests/pe_demo.asm |
---|
0,0 → 1,133 |
use32 |
LIBC_VERSION = 1 |
DLL_ENTRY = 1 |
db 'MENUET02' |
dd 1 |
dd start |
dd i_end |
dd mem |
dd mem |
dd cmdline |
dd path |
dd 0 |
align 4 |
start: |
mov eax, LIBC_VERSION |
mov ecx, sz_libc |
mov edx, libc |
call load_library |
test eax, eax |
jz .fail |
push dword 0 ; no environment |
push cmdline |
push path |
push (my_app_end - my_app) |
push my_app |
call [libc.imp_exec] |
ret |
.fail: |
or eax, -1 |
int 0x40 |
align 4 |
load_library: ;eax=VERSION ecx=library path edx=import section |
sub esp, 16 |
mov [esp+8], edx |
mov [esp+12], eax |
mov eax, 68 |
mov ebx, 19 |
int 0x40 |
test eax, eax |
jz .fail |
mov [esp+4], eax |
mov esi, edx ;import section |
mov edx, eax ;export section |
.import_loop: |
lodsd |
test eax, eax |
jz .import_done |
.import_find: |
mov ebx, [edx] |
test ebx, ebx |
jz .fail ;import_not_found |
mov [esp], eax ;import name |
@@: |
mov cl, [eax] |
cmp cl, [ebx] |
jnz .import_find_next |
test cl, cl |
jz .import_found |
inc eax |
inc ebx |
jmp @b |
.import_find_next: |
mov eax, [esp] |
add edx, 8 |
jmp .import_find |
.import_found: |
mov eax, [edx+4] |
mov [esi-4], eax |
mov edx, [esp+4] |
jmp .import_loop |
.import_done: |
mov edx, [esp+8] |
mov eax, [esp+12] |
cmp word [edx+4], ax |
jb .fail |
cmp word [edx+6], ax |
ja .fail |
push DLL_ENTRY |
call dword [edx] |
.fail: |
add esp, 16 |
ret |
sz_libc db '/sys/lib/libc.obj',0 |
szStart db 'START',0 |
szVersion db 'version',0 |
szExec db 'exec',0 |
libc: |
.imp_start dd szStart |
.imp_ver dd szVersion |
.imp_exec dd szExec |
dd 0 |
; keep this aligned |
align 16 |
my_app: |
file 'myapp.exe' |
my_app_end: |
; keep this aligned |
align 4 |
i_end: |
path rb 1024 |
cmdline rb 256 |
rb 128 ;required stack |
; keep this aligned |
align 4096 |
mem: |
/contrib/sdk/sources/libc/tests/tst-calloc.c |
---|
0,0 → 1,126 |
/* Copyright (C) 2000, 2002 Free Software Foundation, Inc. |
This file is part of the GNU C Library. |
Contributed by Ulrich Drepper <drepper@redhat.com>. |
The GNU C Library is free software; you can redistribute it and/or |
modify it under the terms of the GNU Lesser General Public |
License as published by the Free Software Foundation; either |
version 2.1 of the License, or (at your option) any later version. |
The GNU C Library is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
Lesser General Public License for more details. |
You should have received a copy of the GNU Lesser General Public |
License along with the GNU C Library; if not, write to the Free |
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
02111-1307 USA. */ |
#include <errno.h> |
#include <error.h> |
#include <limits.h> |
#include <malloc.h> |
#include <stdlib.h> |
#include <stdio.h> |
/* Number of samples per size. */ |
#define N 50000 |
static void |
fixed_test (int size) |
{ |
char *ptrs[N]; |
int i; |
for (i = 0; i < N; ++i) |
{ |
int j; |
ptrs[i] = (char *) calloc (1, size); |
if (ptrs[i] == NULL) |
break; |
for (j = 0; j < size; ++j) |
{ |
if (ptrs[i][j] != '\0') |
error (EXIT_FAILURE, 0, |
"byte not cleared (size %d, element %d, byte %d)", |
size, i, j); |
ptrs[i][j] = '\xff'; |
} |
} |
while (i-- > 0) |
free (ptrs[i]); |
} |
static void |
random_test (void) |
{ |
char *ptrs[N]; |
int i; |
for (i = 0; i < N; ++i) |
{ |
int j; |
int n = 1 + random () % 10; |
int elem = 1 + random () % 100; |
int size = n * elem; |
ptrs[i] = (char *) calloc (n, elem); |
if (ptrs[i] == NULL) |
break; |
for (j = 0; j < size; ++j) |
{ |
if (ptrs[i][j] != '\0') |
error (EXIT_FAILURE, 0, |
"byte not cleared (size %d, element %d, byte %d)", |
size, i, j); |
ptrs[i][j] = '\xff'; |
} |
} |
while (i-- > 0) |
free (ptrs[i]); |
} |
static void |
null_test (void) |
{ |
/* If the size is 0 the result is implementation defined. Just make |
sure the program doesn't crash. */ |
calloc (0, 0); |
calloc (0, UINT_MAX); |
calloc (UINT_MAX, 0); |
calloc (0, ~((size_t) 0)); |
calloc (~((size_t) 0), 0); |
} |
int |
main (void) |
{ |
/* We are allocating blocks with `calloc' and check whether every |
block is completely cleared. We first try this for some fixed |
times and then with random size. */ |
fixed_test (15); |
fixed_test (5); |
fixed_test (17); |
fixed_test (6); |
fixed_test (31); |
fixed_test (96); |
random_test (); |
null_test (); |
return 0; |
} |
/contrib/sdk/sources/libc/time/asctime.c |
---|
0,0 → 1,64 |
/* |
* asctime.c |
* Original Author: G. Haley |
* |
* Converts the broken down time in the structure pointed to by tim_p into a |
* string of the form |
* |
* Wed Jun 15 11:38:07 1988\n\0 |
* |
* Returns a pointer to the string. |
*/ |
/* |
FUNCTION |
<<asctime>>---format time as string |
INDEX |
asctime |
INDEX |
_asctime_r |
ANSI_SYNOPSIS |
#include <time.h> |
char *asctime(const struct tm *<[clock]>); |
char *_asctime_r(const struct tm *<[clock]>, char *<[buf]>); |
TRAD_SYNOPSIS |
#include <time.h> |
char *asctime(<[clock]>) |
struct tm *<[clock]>; |
char *asctime_r(<[clock]>) |
struct tm *<[clock]>; |
char *<[buf]>; |
DESCRIPTION |
Format the time value at <[clock]> into a string of the form |
. Wed Jun 15 11:38:07 1988\n\0 |
The string is generated in a static buffer; each call to <<asctime>> |
overwrites the string generated by previous calls. |
RETURNS |
A pointer to the string containing a formatted timestamp. |
PORTABILITY |
ANSI C requires <<asctime>>. |
<<asctime>> requires no supporting OS subroutines. |
*/ |
#include <time.h> |
#include <_ansi.h> |
#include <reent.h> |
#ifndef _REENT_ONLY |
char * |
_DEFUN (asctime, (tim_p), |
_CONST struct tm *tim_p) |
{ |
_REENT_CHECK_ASCTIME_BUF(_REENT); |
return asctime_r (tim_p, _REENT_ASCTIME_BUF(_REENT)); |
} |
#endif |
/contrib/sdk/sources/libc/time/asctime_r.c |
---|
0,0 → 1,27 |
/* |
* asctime_r.c |
*/ |
#include <stdio.h> |
#include <time.h> |
char * |
_DEFUN (asctime_r, (tim_p, result), |
_CONST struct tm *tim_p _AND |
char *result) |
{ |
static _CONST char day_name[7][3] = { |
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" |
}; |
static _CONST char mon_name[12][3] = { |
"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" |
}; |
siprintf (result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n", |
day_name[tim_p->tm_wday], |
mon_name[tim_p->tm_mon], |
tim_p->tm_mday, tim_p->tm_hour, tim_p->tm_min, |
tim_p->tm_sec, 1900 + tim_p->tm_year); |
return result; |
} |
/contrib/sdk/sources/libc/time/clock.c |
---|
0,0 → 1,78 |
/* NetWare can not use this implementation of clock, since it does not |
have times or any similar function. It provides its own version of |
clock in clib.nlm. If we can not use clib.nlm, then we must write |
clock in sys/netware. */ |
#ifdef CLOCK_PROVIDED |
int _dummy_clock = 1; |
#else |
/* |
* clock.c |
* Original Author: G. Haley |
* |
* Determines the processor time used by the program since invocation. The time |
* in seconds is the value returned divided by the value of the macro CLK_TCK. |
* If the processor time used is not available, (clock_t) -1 is returned. |
*/ |
/* |
FUNCTION |
<<clock>>---cumulative processor time |
INDEX |
clock |
ANSI_SYNOPSIS |
#include <time.h> |
clock_t clock(void); |
TRAD_SYNOPSIS |
#include <time.h> |
clock_t clock(); |
DESCRIPTION |
Calculates the best available approximation of the cumulative amount |
of time used by your program since it started. To convert the result |
into seconds, divide by the macro <<CLOCKS_PER_SEC>>. |
RETURNS |
The amount of processor time used so far by your program, in units |
defined by the machine-dependent macro <<CLOCKS_PER_SEC>>. If no |
measurement is available, the result is (clock_t)<<-1>>. |
PORTABILITY |
ANSI C requires <<clock>> and <<CLOCKS_PER_SEC>>. |
Supporting OS subroutine required: <<times>>. |
*/ |
#include <time.h> |
#include <sys/times.h> |
#include <reent.h> |
clock_t |
_DEFUN (_times_r, (ptr, ptms), |
struct _reent *ptr _AND |
struct tms *ptms) |
{ |
return -1; |
} |
clock_t |
clock () |
{ |
struct tms tim_s; |
clock_t res; |
if ((res = (clock_t) _times_r (_REENT, &tim_s)) != -1) |
res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime + |
tim_s.tms_cutime + tim_s.tms_cstime); |
return res; |
} |
#endif /* CLOCK_PROVIDED */ |
/contrib/sdk/sources/libc/time/ctime.c |
---|
0,0 → 1,55 |
/* |
* ctime.c |
* Original Author: G. Haley |
*/ |
/* |
FUNCTION |
<<ctime>>---convert time to local and format as string |
INDEX |
ctime |
INDEX |
ctime_r |
ANSI_SYNOPSIS |
#include <time.h> |
char *ctime(const time_t *<[clock]>); |
char *ctime_r(const time_t *<[clock]>, char *<[buf]>); |
TRAD_SYNOPSIS |
#include <time.h> |
char *ctime(<[clock]>) |
time_t *<[clock]>; |
char *ctime_r(<[clock]>, <[buf]>) |
time_t *<[clock]>; |
char *<[buf]>; |
DESCRIPTION |
Convert the time value at <[clock]> to local time (like <<localtime>>) |
and format it into a string of the form |
. Wed Jun 15 11:38:07 1988\n\0 |
(like <<asctime>>). |
RETURNS |
A pointer to the string containing a formatted timestamp. |
PORTABILITY |
ANSI C requires <<ctime>>. |
<<ctime>> requires no supporting OS subroutines. |
*/ |
#include <time.h> |
#ifndef _REENT_ONLY |
char * |
_DEFUN (ctime, (tim_p), |
_CONST time_t * tim_p) |
{ |
return asctime (localtime (tim_p)); |
} |
#endif |
/contrib/sdk/sources/libc/time/ctime_r.c |
---|
0,0 → 1,15 |
/* |
* ctime_r.c |
*/ |
#include <time.h> |
char * |
_DEFUN (ctime_r, (tim_p, result), |
_CONST time_t * tim_p _AND |
char * result) |
{ |
struct tm tm; |
return asctime_r (localtime_r (tim_p, &tm), result); |
} |
/contrib/sdk/sources/libc/time/difftime.c |
---|
0,0 → 1,44 |
/* |
* difftime.c |
* Original Author: G. Haley |
*/ |
/* |
FUNCTION |
<<difftime>>---subtract two times |
INDEX |
difftime |
ANSI_SYNOPSIS |
#include <time.h> |
double difftime(time_t <[tim1]>, time_t <[tim2]>); |
TRAD_SYNOPSIS |
#include <time.h> |
double difftime(<[tim1]>, <[tim2]>) |
time_t <[tim1]>; |
time_t <[tim2]>; |
DESCRIPTION |
Subtracts the two times in the arguments: `<<<[tim1]> - <[tim2]>>>'. |
RETURNS |
The difference (in seconds) between <[tim2]> and <[tim1]>, as a <<double>>. |
PORTABILITY |
ANSI C requires <<difftime>>, and defines its result to be in seconds |
in all implementations. |
<<difftime>> requires no supporting OS subroutines. |
*/ |
#include <time.h> |
double |
_DEFUN (difftime, (tim1, tim2), |
time_t tim1 _AND |
time_t tim2) |
{ |
return (double)(tim1 - tim2); |
} |
/contrib/sdk/sources/libc/time/gettzinfo.c |
---|
0,0 → 1,15 |
#include <sys/types.h> |
#include "local.h" |
/* Shared timezone information for libc/time functions. */ |
static __tzinfo_type tzinfo = {1, 0, |
{ {'J', 0, 0, 0, 0, (time_t)0, 0L }, |
{'J', 0, 0, 0, 0, (time_t)0, 0L } |
} |
}; |
__tzinfo_type * |
__gettzinfo (void) |
{ |
return &tzinfo; |
} |
/contrib/sdk/sources/libc/time/gmtime.c |
---|
0,0 → 1,68 |
/* |
* gmtime.c |
* Original Author: G. Haley |
* |
* Converts the calendar time pointed to by tim_p into a broken-down time |
* expressed as Greenwich Mean Time (GMT). Returns a pointer to a structure |
* containing the broken-down time, or a null pointer if GMT is not |
* available. |
*/ |
/* |
FUNCTION |
<<gmtime>>---convert time to UTC traditional form |
INDEX |
gmtime |
INDEX |
gmtime_r |
ANSI_SYNOPSIS |
#include <time.h> |
struct tm *gmtime(const time_t *<[clock]>); |
struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>); |
TRAD_SYNOPSIS |
#include <time.h> |
struct tm *gmtime(<[clock]>) |
const time_t *<[clock]>; |
struct tm *gmtime_r(<[clock]>, <[res]>) |
const time_t *<[clock]>; |
struct tm *<[res]>; |
DESCRIPTION |
<<gmtime>> takes the time at <[clock]> representing the number |
of elapsed seconds since 00:00:00 on January 1, 1970, Universal |
Coordinated Time (UTC, also known in some countries as GMT, |
Greenwich Mean time) and converts it to a <<struct tm>> |
representation. |
<<gmtime>> constructs the traditional time representation in static |
storage; each call to <<gmtime>> or <<localtime>> will overwrite the |
information generated by previous calls to either function. |
RETURNS |
A pointer to the traditional time representation (<<struct tm>>). |
PORTABILITY |
ANSI C requires <<gmtime>>. |
<<gmtime>> requires no supporting OS subroutines. |
*/ |
#include <stdlib.h> |
#include <time.h> |
#define _GMT_OFFSET 0 |
#ifndef _REENT_ONLY |
struct tm * |
_DEFUN (gmtime, (tim_p), |
_CONST time_t * tim_p) |
{ |
_REENT_CHECK_TM(_REENT); |
return gmtime_r (tim_p, (struct tm *)_REENT_TM(_REENT)); |
} |
#endif |
/contrib/sdk/sources/libc/time/gmtime_r.c |
---|
0,0 → 1,14 |
/* |
* gmtime_r.c |
*/ |
#include <time.h> |
#include "local.h" |
struct tm * |
_DEFUN (gmtime_r, (tim_p, res), |
_CONST time_t * tim_p _AND |
struct tm *res) |
{ |
return (_mktm_r (tim_p, res, 1)); |
} |
/contrib/sdk/sources/libc/time/lcltime.c |
---|
0,0 → 1,60 |
/* |
* localtime.c |
*/ |
/* |
FUNCTION |
<<localtime>>---convert time to local representation |
INDEX |
localtime |
INDEX |
localtime_r |
ANSI_SYNOPSIS |
#include <time.h> |
struct tm *localtime(time_t *<[clock]>); |
struct tm *localtime_r(time_t *<[clock]>, struct tm *<[res]>); |
TRAD_SYNOPSIS |
#include <time.h> |
struct tm *localtime(<[clock]>) |
time_t *<[clock]>; |
struct tm *localtime(<[clock]>, <[res]>) |
time_t *<[clock]>; |
struct tm *<[res]>; |
DESCRIPTION |
<<localtime>> converts the time at <[clock]> into local time, then |
converts its representation from the arithmetic representation to the |
traditional representation defined by <<struct tm>>. |
<<localtime>> constructs the traditional time representation in static |
storage; each call to <<gmtime>> or <<localtime>> will overwrite the |
information generated by previous calls to either function. |
<<mktime>> is the inverse of <<localtime>>. |
RETURNS |
A pointer to the traditional time representation (<<struct tm>>). |
PORTABILITY |
ANSI C requires <<localtime>>. |
<<localtime>> requires no supporting OS subroutines. |
*/ |
#include <time.h> |
#include <reent.h> |
#ifndef _REENT_ONLY |
struct tm * |
_DEFUN (localtime, (tim_p), |
_CONST time_t * tim_p) |
{ |
_REENT_CHECK_TM(_REENT); |
return localtime_r (tim_p, (struct tm *)_REENT_TM(_REENT)); |
} |
#endif |
/contrib/sdk/sources/libc/time/lcltime_r.c |
---|
0,0 → 1,18 |
/* |
* localtime_r.c |
* |
* Converts the calendar time pointed to by tim_p into a broken-down time |
* expressed as local time. Returns a pointer to a structure containing the |
* broken-down time. |
*/ |
#include <time.h> |
#include "local.h" |
struct tm * |
_DEFUN (localtime_r, (tim_p, res), |
_CONST time_t * tim_p _AND |
struct tm *res) |
{ |
return _mktm_r (tim_p, res, 0); |
} |
/contrib/sdk/sources/libc/time/local.h |
---|
0,0 → 1,36 |
/* local header used by libc/time routines */ |
#include <_ansi.h> |
#include <time.h> |
#define SECSPERMIN 60L |
#define MINSPERHOUR 60L |
#define HOURSPERDAY 24L |
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) |
#define SECSPERDAY (SECSPERHOUR * HOURSPERDAY) |
#define DAYSPERWEEK 7 |
#define MONSPERYEAR 12 |
#define YEAR_BASE 1900 |
#define EPOCH_YEAR 1970 |
#define EPOCH_WDAY 4 |
#define EPOCH_YEARS_SINCE_LEAP 2 |
#define EPOCH_YEARS_SINCE_CENTURY 70 |
#define EPOCH_YEARS_SINCE_LEAP_CENTURY 370 |
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) |
struct tm * _EXFUN (_mktm_r, (_CONST time_t *, struct tm *, int __is_gmtime)); |
int _EXFUN (__tzcalc_limits, (int __year)); |
/* locks for multi-threading */ |
#ifdef __SINGLE_THREAD__ |
#define TZ_LOCK |
#define TZ_UNLOCK |
#else |
#define TZ_LOCK __tz_lock() |
#define TZ_UNLOCK __tz_unlock() |
#endif |
void _EXFUN(__tz_lock,(_VOID)); |
void _EXFUN(__tz_unlock,(_VOID)); |
/contrib/sdk/sources/libc/time/mktime.c |
---|
0,0 → 1,287 |
/* |
* mktime.c |
* Original Author: G. Haley |
* |
* Converts the broken-down time, expressed as local time, in the structure |
* pointed to by tim_p into a calendar time value. The original values of the |
* tm_wday and tm_yday fields of the structure are ignored, and the original |
* values of the other fields have no restrictions. On successful completion |
* the fields of the structure are set to represent the specified calendar |
* time. Returns the specified calendar time. If the calendar time can not be |
* represented, returns the value (time_t) -1. |
* |
* Modifications: Fixed tm_isdst usage - 27 August 2008 Craig Howland. |
*/ |
/* |
FUNCTION |
<<mktime>>---convert time to arithmetic representation |
INDEX |
mktime |
ANSI_SYNOPSIS |
#include <time.h> |
time_t mktime(struct tm *<[timp]>); |
TRAD_SYNOPSIS |
#include <time.h> |
time_t mktime(<[timp]>) |
struct tm *<[timp]>; |
DESCRIPTION |
<<mktime>> assumes the time at <[timp]> is a local time, and converts |
its representation from the traditional representation defined by |
<<struct tm>> into a representation suitable for arithmetic. |
<<localtime>> is the inverse of <<mktime>>. |
RETURNS |
If the contents of the structure at <[timp]> do not form a valid |
calendar time representation, the result is <<-1>>. Otherwise, the |
result is the time, converted to a <<time_t>> value. |
PORTABILITY |
ANSI C requires <<mktime>>. |
<<mktime>> requires no supporting OS subroutines. |
*/ |
#include <stdlib.h> |
#include <time.h> |
#include "local.h" |
#define _SEC_IN_MINUTE 60L |
#define _SEC_IN_HOUR 3600L |
#define _SEC_IN_DAY 86400L |
static _CONST int DAYS_IN_MONTH[12] = |
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
#define _DAYS_IN_MONTH(x) ((x == 1) ? days_in_feb : DAYS_IN_MONTH[x]) |
static _CONST int _DAYS_BEFORE_MONTH[12] = |
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; |
#define _ISLEAP(y) (((y) % 4) == 0 && (((y) % 100) != 0 || (((y)+1900) % 400) == 0)) |
#define _DAYS_IN_YEAR(year) (_ISLEAP(year) ? 366 : 365) |
static void |
_DEFUN(validate_structure, (tim_p), |
struct tm *tim_p) |
{ |
div_t res; |
int days_in_feb = 28; |
/* calculate time & date to account for out of range values */ |
if (tim_p->tm_sec < 0 || tim_p->tm_sec > 59) |
{ |
res = div (tim_p->tm_sec, 60); |
tim_p->tm_min += res.quot; |
if ((tim_p->tm_sec = res.rem) < 0) |
{ |
tim_p->tm_sec += 60; |
--tim_p->tm_min; |
} |
} |
if (tim_p->tm_min < 0 || tim_p->tm_min > 59) |
{ |
res = div (tim_p->tm_min, 60); |
tim_p->tm_hour += res.quot; |
if ((tim_p->tm_min = res.rem) < 0) |
{ |
tim_p->tm_min += 60; |
--tim_p->tm_hour; |
} |
} |
if (tim_p->tm_hour < 0 || tim_p->tm_hour > 23) |
{ |
res = div (tim_p->tm_hour, 24); |
tim_p->tm_mday += res.quot; |
if ((tim_p->tm_hour = res.rem) < 0) |
{ |
tim_p->tm_hour += 24; |
--tim_p->tm_mday; |
} |
} |
if (tim_p->tm_mon < 0 || tim_p->tm_mon > 11) |
{ |
res = div (tim_p->tm_mon, 12); |
tim_p->tm_year += res.quot; |
if ((tim_p->tm_mon = res.rem) < 0) |
{ |
tim_p->tm_mon += 12; |
--tim_p->tm_year; |
} |
} |
if (_DAYS_IN_YEAR (tim_p->tm_year) == 366) |
days_in_feb = 29; |
if (tim_p->tm_mday <= 0) |
{ |
while (tim_p->tm_mday <= 0) |
{ |
if (--tim_p->tm_mon == -1) |
{ |
tim_p->tm_year--; |
tim_p->tm_mon = 11; |
days_in_feb = |
((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ? |
29 : 28); |
} |
tim_p->tm_mday += _DAYS_IN_MONTH (tim_p->tm_mon); |
} |
} |
else |
{ |
while (tim_p->tm_mday > _DAYS_IN_MONTH (tim_p->tm_mon)) |
{ |
tim_p->tm_mday -= _DAYS_IN_MONTH (tim_p->tm_mon); |
if (++tim_p->tm_mon == 12) |
{ |
tim_p->tm_year++; |
tim_p->tm_mon = 0; |
days_in_feb = |
((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ? |
29 : 28); |
} |
} |
} |
} |
time_t |
_DEFUN(mktime, (tim_p), |
struct tm *tim_p) |
{ |
time_t tim = 0; |
long days = 0; |
int year, isdst=0; |
__tzinfo_type *tz = __gettzinfo (); |
/* validate structure */ |
validate_structure (tim_p); |
/* compute hours, minutes, seconds */ |
tim += tim_p->tm_sec + (tim_p->tm_min * _SEC_IN_MINUTE) + |
(tim_p->tm_hour * _SEC_IN_HOUR); |
/* compute days in year */ |
days += tim_p->tm_mday - 1; |
days += _DAYS_BEFORE_MONTH[tim_p->tm_mon]; |
if (tim_p->tm_mon > 1 && _DAYS_IN_YEAR (tim_p->tm_year) == 366) |
days++; |
/* compute day of the year */ |
tim_p->tm_yday = days; |
if (tim_p->tm_year > 10000 || tim_p->tm_year < -10000) |
return (time_t) -1; |
/* compute days in other years */ |
if ((year = tim_p->tm_year) > 70) |
{ |
for (year = 70; year < tim_p->tm_year; year++) |
days += _DAYS_IN_YEAR (year); |
} |
else if (year < 70) |
{ |
for (year = 69; year > tim_p->tm_year; year--) |
days -= _DAYS_IN_YEAR (year); |
days -= _DAYS_IN_YEAR (year); |
} |
/* compute total seconds */ |
tim += (days * _SEC_IN_DAY); |
TZ_LOCK; |
if (_daylight) |
{ |
int tm_isdst; |
int y = tim_p->tm_year + YEAR_BASE; |
/* Convert user positive into 1 */ |
tm_isdst = tim_p->tm_isdst > 0 ? 1 : tim_p->tm_isdst; |
isdst = tm_isdst; |
if (y == tz->__tzyear || __tzcalc_limits (y)) |
{ |
/* calculate start of dst in dst local time and |
start of std in both std local time and dst local time */ |
time_t startdst_dst = tz->__tzrule[0].change |
- (time_t) tz->__tzrule[1].offset; |
time_t startstd_dst = tz->__tzrule[1].change |
- (time_t) tz->__tzrule[1].offset; |
time_t startstd_std = tz->__tzrule[1].change |
- (time_t) tz->__tzrule[0].offset; |
/* if the time is in the overlap between dst and std local times */ |
if (tim >= startstd_std && tim < startstd_dst) |
; /* we let user decide or leave as -1 */ |
else |
{ |
isdst = (tz->__tznorth |
? (tim >= startdst_dst && tim < startstd_std) |
: (tim >= startdst_dst || tim < startstd_std)); |
/* if user committed and was wrong, perform correction, but not |
* if the user has given a negative value (which |
* asks mktime() to determine if DST is in effect or not) */ |
if (tm_isdst >= 0 && (isdst ^ tm_isdst) == 1) |
{ |
/* we either subtract or add the difference between |
time zone offsets, depending on which way the user got it |
wrong. The diff is typically one hour, or 3600 seconds, |
and should fit in a 16-bit int, even though offset |
is a long to accomodate 12 hours. */ |
int diff = (int) (tz->__tzrule[0].offset |
- tz->__tzrule[1].offset); |
if (!isdst) |
diff = -diff; |
tim_p->tm_sec += diff; |
tim += diff; /* we also need to correct our current time calculation */ |
int mday = tim_p->tm_mday; |
validate_structure (tim_p); |
mday = tim_p->tm_mday - mday; |
/* roll over occurred */ |
if (mday) { |
/* compensate for month roll overs */ |
if (mday > 1) |
mday = -1; |
else if (mday < -1) |
mday = 1; |
/* update days for wday calculation */ |
days += mday; |
/* handle yday */ |
if ((tim_p->tm_yday += mday) < 0) { |
--year; |
tim_p->tm_yday = _DAYS_IN_YEAR(year) - 1; |
} else { |
mday = _DAYS_IN_YEAR(year); |
if (tim_p->tm_yday > (mday - 1)) |
tim_p->tm_yday -= mday; |
} |
} |
} |
} |
} |
} |
/* add appropriate offset to put time in gmt format */ |
if (isdst == 1) |
tim += (time_t) tz->__tzrule[1].offset; |
else /* otherwise assume std time */ |
tim += (time_t) tz->__tzrule[0].offset; |
TZ_UNLOCK; |
/* reset isdst flag to what we have calculated */ |
tim_p->tm_isdst = isdst; |
/* compute day of the week */ |
if ((tim_p->tm_wday = (days + 4) % 7) < 0) |
tim_p->tm_wday += 7; |
return tim; |
} |
/contrib/sdk/sources/libc/time/mktm_r.c |
---|
0,0 → 1,259 |
/* |
* mktm_r.c |
* Original Author: Adapted from tzcode maintained by Arthur David Olson. |
* Modifications: Changed to mktm_r and added __tzcalc_limits - 04/10/02, Jeff Johnston |
* Fixed bug in mday computations - 08/12/04, Alex Mogilnikov <alx@intellectronika.ru> |
* Fixed bug in __tzcalc_limits - 08/12/04, Alex Mogilnikov <alx@intellectronika.ru> |
* |
* Converts the calendar time pointed to by tim_p into a broken-down time |
* expressed as local time. Returns a pointer to a structure containing the |
* broken-down time. |
*/ |
#include <stdlib.h> |
#include <time.h> |
#include "local.h" |
static _CONST int mon_lengths[2][MONSPERYEAR] = { |
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, |
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} |
} ; |
static _CONST int year_lengths[2] = { |
365, |
366 |
} ; |
struct tm * |
_DEFUN (_mktm_r, (tim_p, res, is_gmtime), |
_CONST time_t * tim_p _AND |
struct tm *res _AND |
int is_gmtime) |
{ |
long days, rem; |
time_t lcltime; |
int y; |
int yleap; |
_CONST int *ip; |
__tzinfo_type *tz = __gettzinfo (); |
/* base decision about std/dst time on current time */ |
lcltime = *tim_p; |
days = ((long)lcltime) / SECSPERDAY; |
rem = ((long)lcltime) % SECSPERDAY; |
while (rem < 0) |
{ |
rem += SECSPERDAY; |
--days; |
} |
while (rem >= SECSPERDAY) |
{ |
rem -= SECSPERDAY; |
++days; |
} |
/* compute hour, min, and sec */ |
res->tm_hour = (int) (rem / SECSPERHOUR); |
rem %= SECSPERHOUR; |
res->tm_min = (int) (rem / SECSPERMIN); |
res->tm_sec = (int) (rem % SECSPERMIN); |
/* compute day of week */ |
if ((res->tm_wday = ((EPOCH_WDAY + days) % DAYSPERWEEK)) < 0) |
res->tm_wday += DAYSPERWEEK; |
/* compute year & day of year */ |
y = EPOCH_YEAR; |
if (days >= 0) |
{ |
for (;;) |
{ |
yleap = isleap(y); |
if (days < year_lengths[yleap]) |
break; |
y++; |
days -= year_lengths[yleap]; |
} |
} |
else |
{ |
do |
{ |
--y; |
yleap = isleap(y); |
days += year_lengths[yleap]; |
} while (days < 0); |
} |
res->tm_year = y - YEAR_BASE; |
res->tm_yday = days; |
ip = mon_lengths[yleap]; |
for (res->tm_mon = 0; days >= ip[res->tm_mon]; ++res->tm_mon) |
days -= ip[res->tm_mon]; |
res->tm_mday = days + 1; |
if (!is_gmtime) |
{ |
long offset; |
int hours, mins, secs; |
TZ_LOCK; |
if (_daylight) |
{ |
if (y == tz->__tzyear || __tzcalc_limits (y)) |
res->tm_isdst = (tz->__tznorth |
? (*tim_p >= tz->__tzrule[0].change |
&& *tim_p < tz->__tzrule[1].change) |
: (*tim_p >= tz->__tzrule[0].change |
|| *tim_p < tz->__tzrule[1].change)); |
else |
res->tm_isdst = -1; |
} |
else |
res->tm_isdst = 0; |
offset = (res->tm_isdst == 1 |
? tz->__tzrule[1].offset |
: tz->__tzrule[0].offset); |
hours = (int) (offset / SECSPERHOUR); |
offset = offset % SECSPERHOUR; |
mins = (int) (offset / SECSPERMIN); |
secs = (int) (offset % SECSPERMIN); |
res->tm_sec -= secs; |
res->tm_min -= mins; |
res->tm_hour -= hours; |
if (res->tm_sec >= SECSPERMIN) |
{ |
res->tm_min += 1; |
res->tm_sec -= SECSPERMIN; |
} |
else if (res->tm_sec < 0) |
{ |
res->tm_min -= 1; |
res->tm_sec += SECSPERMIN; |
} |
if (res->tm_min >= MINSPERHOUR) |
{ |
res->tm_hour += 1; |
res->tm_min -= MINSPERHOUR; |
} |
else if (res->tm_min < 0) |
{ |
res->tm_hour -= 1; |
res->tm_min += MINSPERHOUR; |
} |
if (res->tm_hour >= HOURSPERDAY) |
{ |
++res->tm_yday; |
++res->tm_wday; |
if (res->tm_wday > 6) |
res->tm_wday = 0; |
++res->tm_mday; |
res->tm_hour -= HOURSPERDAY; |
if (res->tm_mday > ip[res->tm_mon]) |
{ |
res->tm_mday -= ip[res->tm_mon]; |
res->tm_mon += 1; |
if (res->tm_mon == 12) |
{ |
res->tm_mon = 0; |
res->tm_year += 1; |
res->tm_yday = 0; |
} |
} |
} |
else if (res->tm_hour < 0) |
{ |
res->tm_yday -= 1; |
res->tm_wday -= 1; |
if (res->tm_wday < 0) |
res->tm_wday = 6; |
res->tm_mday -= 1; |
res->tm_hour += 24; |
if (res->tm_mday == 0) |
{ |
res->tm_mon -= 1; |
if (res->tm_mon < 0) |
{ |
res->tm_mon = 11; |
res->tm_year -= 1; |
res->tm_yday = 364 + isleap(res->tm_year + 1900); |
} |
res->tm_mday = ip[res->tm_mon]; |
} |
} |
TZ_UNLOCK; |
} |
else |
res->tm_isdst = 0; |
return (res); |
} |
int |
_DEFUN (__tzcalc_limits, (year), |
int year) |
{ |
int days, year_days, years; |
int i, j; |
__tzinfo_type *tz = __gettzinfo (); |
if (year < EPOCH_YEAR) |
return 0; |
tz->__tzyear = year; |
years = (year - EPOCH_YEAR); |
year_days = years * 365 + |
(years - 1 + EPOCH_YEARS_SINCE_LEAP) / 4 - (years - 1 + EPOCH_YEARS_SINCE_CENTURY) / 100 + |
(years - 1 + EPOCH_YEARS_SINCE_LEAP_CENTURY) / 400; |
for (i = 0; i < 2; ++i) |
{ |
if (tz->__tzrule[i].ch == 'J') { |
/* The Julian day n (1 <= n <= 365). */ |
days = year_days + tz->__tzrule[i].d + |
(isleap(year) && tz->__tzrule[i].d >= 60); |
/* Convert to yday */ |
--days; |
} else if (tz->__tzrule[i].ch == 'D') |
days = year_days + tz->__tzrule[i].d; |
else |
{ |
int yleap = isleap(year); |
int m_day, m_wday, wday_diff; |
_CONST int *ip = mon_lengths[yleap]; |
days = year_days; |
for (j = 1; j < tz->__tzrule[i].m; ++j) |
days += ip[j-1]; |
m_wday = (EPOCH_WDAY + days) % DAYSPERWEEK; |
wday_diff = tz->__tzrule[i].d - m_wday; |
if (wday_diff < 0) |
wday_diff += DAYSPERWEEK; |
m_day = (tz->__tzrule[i].n - 1) * DAYSPERWEEK + wday_diff; |
while (m_day >= ip[j-1]) |
m_day -= DAYSPERWEEK; |
days += m_day; |
} |
/* store the change-over time in GMT form by adding offset */ |
tz->__tzrule[i].change = days * SECSPERDAY + |
tz->__tzrule[i].s + tz->__tzrule[i].offset; |
} |
tz->__tznorth = (tz->__tzrule[0].change < tz->__tzrule[1].change); |
return 1; |
} |
/contrib/sdk/sources/libc/time/strftime.c |
---|
0,0 → 1,333 |
/* NOTE: This file defines both strftime() and wcsftime(). Take care when |
* making changes. See also wcsftime.c, and note the (small) overlap in the |
* manual description, taking care to edit both as needed. */ |
/* |
* strftime.c |
* Original Author: G. Haley |
* Additions from: Eric Blake |
* Changes to allow dual use as wcstime, also: Craig Howland |
* |
* Places characters into the array pointed to by s as controlled by the string |
* pointed to by format. If the total number of resulting characters including |
* the terminating null character is not more than maxsize, returns the number |
* of characters placed into the array pointed to by s (not including the |
* terminating null character); otherwise zero is returned and the contents of |
* the array indeterminate. |
*/ |
/* |
FUNCTION |
<<strftime>>---convert date and time to a formatted string |
INDEX |
strftime |
ANSI_SYNOPSIS |
#include <time.h> |
size_t strftime(char *<[s]>, size_t <[maxsize]>, |
const char *<[format]>, const struct tm *<[timp]>); |
TRAD_SYNOPSIS |
#include <time.h> |
size_t strftime(<[s]>, <[maxsize]>, <[format]>, <[timp]>) |
char *<[s]>; |
size_t <[maxsize]>; |
char *<[format]>; |
struct tm *<[timp]>; |
DESCRIPTION |
<<strftime>> converts a <<struct tm>> representation of the time (at |
<[timp]>) into a null-terminated string, starting at <[s]> and occupying |
no more than <[maxsize]> characters. |
You control the format of the output using the string at <[format]>. |
<<*<[format]>>> can contain two kinds of specifications: text to be |
copied literally into the formatted string, and time conversion |
specifications. Time conversion specifications are two- and |
three-character sequences beginning with `<<%>>' (use `<<%%>>' to |
include a percent sign in the output). Each defined conversion |
specification selects only the specified field(s) of calendar time |
data from <<*<[timp]>>>, and converts it to a string in one of the |
following ways: |
o+ |
o %a |
The abbreviated weekday name according to the current locale. [tm_wday] |
o %A |
The full weekday name according to the current locale. |
In the default "C" locale, one of `<<Sunday>>', `<<Monday>>', `<<Tuesday>>', |
`<<Wednesday>>', `<<Thursday>>', `<<Friday>>', `<<Saturday>>'. [tm_wday] |
o %b |
The abbreviated month name according to the current locale. [tm_mon] |
o %B |
The full month name according to the current locale. |
In the default "C" locale, one of `<<January>>', `<<February>>', |
`<<March>>', `<<April>>', `<<May>>', `<<June>>', `<<July>>', |
`<<August>>', `<<September>>', `<<October>>', `<<November>>', |
`<<December>>'. [tm_mon] |
o %c |
The preferred date and time representation for the current locale. |
[tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, tm_wday] |
o %C |
The century, that is, the year divided by 100 then truncated. For |
4-digit years, the result is zero-padded and exactly two characters; |
but for other years, there may a negative sign or more digits. In |
this way, `<<%C%y>>' is equivalent to `<<%Y>>'. [tm_year] |
o %d |
The day of the month, formatted with two digits (from `<<01>>' to |
`<<31>>'). [tm_mday] |
o %D |
A string representing the date, in the form `<<"%m/%d/%y">>'. |
[tm_mday, tm_mon, tm_year] |
o %e |
The day of the month, formatted with leading space if single digit |
(from `<<1>>' to `<<31>>'). [tm_mday] |
o %E<<x>> |
In some locales, the E modifier selects alternative representations of |
certain modifiers <<x>>. In newlib, it is ignored, and treated as %<<x>>. |
o %F |
A string representing the ISO 8601:2000 date format, in the form |
`<<"%Y-%m-%d">>'. [tm_mday, tm_mon, tm_year] |
o %g |
The last two digits of the week-based year, see specifier %G (from |
`<<00>>' to `<<99>>'). [tm_year, tm_wday, tm_yday] |
o %G |
The week-based year. In the ISO 8601:2000 calendar, week 1 of the year |
includes January 4th, and begin on Mondays. Therefore, if January 1st, |
2nd, or 3rd falls on a Sunday, that day and earlier belong to the last |
week of the previous year; and if December 29th, 30th, or 31st falls |
on Monday, that day and later belong to week 1 of the next year. For |
consistency with %Y, it always has at least four characters. |
Example: "%G" for Saturday 2nd January 1999 gives "1998", and for |
Tuesday 30th December 1997 gives "1998". [tm_year, tm_wday, tm_yday] |
o %h |
Synonym for "%b". [tm_mon] |
o %H |
The hour (on a 24-hour clock), formatted with two digits (from |
`<<00>>' to `<<23>>'). [tm_hour] |
o %I |
The hour (on a 12-hour clock), formatted with two digits (from |
`<<01>>' to `<<12>>'). [tm_hour] |
o %j |
The count of days in the year, formatted with three digits |
(from `<<001>>' to `<<366>>'). [tm_yday] |
o %k |
The hour (on a 24-hour clock), formatted with leading space if single |
digit (from `<<0>>' to `<<23>>'). Non-POSIX extension (c.p. %I). [tm_hour] |
o %l |
The hour (on a 12-hour clock), formatted with leading space if single |
digit (from `<<1>>' to `<<12>>'). Non-POSIX extension (c.p. %H). [tm_hour] |
o %m |
The month number, formatted with two digits (from `<<01>>' to `<<12>>'). |
[tm_mon] |
o %M |
The minute, formatted with two digits (from `<<00>>' to `<<59>>'). [tm_min] |
o %n |
A newline character (`<<\n>>'). |
o %O<<x>> |
In some locales, the O modifier selects alternative digit characters |
for certain modifiers <<x>>. In newlib, it is ignored, and treated as %<<x>>. |
o %p |
Either `<<AM>>' or `<<PM>>' as appropriate, or the corresponding strings for |
the current locale. [tm_hour] |
o %P |
Same as '<<%p>>', but in lowercase. This is a GNU extension. [tm_hour] |
o %r |
Replaced by the time in a.m. and p.m. notation. In the "C" locale this |
is equivalent to "%I:%M:%S %p". In locales which don't define a.m./p.m. |
notations, the result is an empty string. [tm_sec, tm_min, tm_hour] |
o %R |
The 24-hour time, to the minute. Equivalent to "%H:%M". [tm_min, tm_hour] |
o %S |
The second, formatted with two digits (from `<<00>>' to `<<60>>'). The |
value 60 accounts for the occasional leap second. [tm_sec] |
o %t |
A tab character (`<<\t>>'). |
o %T |
The 24-hour time, to the second. Equivalent to "%H:%M:%S". [tm_sec, |
tm_min, tm_hour] |
o %u |
The weekday as a number, 1-based from Monday (from `<<1>>' to |
`<<7>>'). [tm_wday] |
o %U |
The week number, where weeks start on Sunday, week 1 contains the first |
Sunday in a year, and earlier days are in week 0. Formatted with two |
digits (from `<<00>>' to `<<53>>'). See also <<%W>>. [tm_wday, tm_yday] |
o %V |
The week number, where weeks start on Monday, week 1 contains January 4th, |
and earlier days are in the previous year. Formatted with two digits |
(from `<<01>>' to `<<53>>'). See also <<%G>>. [tm_year, tm_wday, tm_yday] |
o %w |
The weekday as a number, 0-based from Sunday (from `<<0>>' to `<<6>>'). |
[tm_wday] |
o %W |
The week number, where weeks start on Monday, week 1 contains the first |
Monday in a year, and earlier days are in week 0. Formatted with two |
digits (from `<<00>>' to `<<53>>'). [tm_wday, tm_yday] |
o %x |
Replaced by the preferred date representation in the current locale. |
In the "C" locale this is equivalent to "%m/%d/%y". |
[tm_mon, tm_mday, tm_year] |
o %X |
Replaced by the preferred time representation in the current locale. |
In the "C" locale this is equivalent to "%H:%M:%S". [tm_sec, tm_min, tm_hour] |
o %y |
The last two digits of the year (from `<<00>>' to `<<99>>'). [tm_year] |
(Implementation interpretation: always positive, even for negative years.) |
o %Y |
The full year, equivalent to <<%C%y>>. It will always have at least four |
characters, but may have more. The year is accurate even when tm_year |
added to the offset of 1900 overflows an int. [tm_year] |
o %z |
The offset from UTC. The format consists of a sign (negative is west of |
Greewich), two characters for hour, then two characters for minutes |
(-hhmm or +hhmm). If tm_isdst is negative, the offset is unknown and no |
output is generated; if it is zero, the offset is the standard offset for |
the current time zone; and if it is positive, the offset is the daylight |
savings offset for the current timezone. The offset is determined from |
the TZ environment variable, as if by calling tzset(). [tm_isdst] |
o %Z |
The time zone name. If tm_isdst is negative, no output is generated. |
Otherwise, the time zone name is based on the TZ environment variable, |
as if by calling tzset(). [tm_isdst] |
o %% |
A single character, `<<%>>'. |
o- |
RETURNS |
When the formatted time takes up no more than <[maxsize]> characters, |
the result is the length of the formatted string. Otherwise, if the |
formatting operation was abandoned due to lack of room, the result is |
<<0>>, and the string starting at <[s]> corresponds to just those |
parts of <<*<[format]>>> that could be completely filled in within the |
<[maxsize]> limit. |
PORTABILITY |
ANSI C requires <<strftime>>, but does not specify the contents of |
<<*<[s]>>> when the formatted string would require more than |
<[maxsize]> characters. Unrecognized specifiers and fields of |
<<timp>> that are out of range cause undefined results. Since some |
formats expand to 0 bytes, it is wise to set <<*<[s]>>> to a nonzero |
value beforehand to distinguish between failure and an empty string. |
This implementation does not support <<s>> being NULL, nor overlapping |
<<s>> and <<format>>. |
<<strftime>> requires no supporting OS subroutines. |
BUGS |
<<strftime>> ignores the LC_TIME category of the current locale, hard-coding |
the "C" locale settings. |
*/ |
#include <newlib.h> |
#include <sys/config.h> |
#include <stddef.h> |
#include <stdio.h> |
#include <time.h> |
#include <string.h> |
#include <stdlib.h> |
#include <limits.h> |
#include <ctype.h> |
#include <wctype.h> |
/* Defines to make the file dual use for either strftime() or wcsftime(). |
* To get wcsftime, define MAKE_WCSFTIME. |
* To get strftime, do not define MAKE_WCSFTIME. |
* Names are kept friendly to strftime() usage. The biggest ugliness is the |
* use of the CQ() macro to make either regular character constants and |
* string literals or wide-character constants and wide-character-string |
* literals, as appropriate. */ |
#if !defined(MAKE_WCSFTIME) |
# define CHAR char /* string type basis */ |
# define CQ(a) a /* character constant qualifier */ |
# define SFLG /* %s flag (null for normal char) */ |
# define _ctloc(x) (ctloclen = strlen (ctloc = _CurrentTimeLocale->x), ctloc) |
# define TOLOWER(c) tolower((int)(unsigned char)(c)) |
# define STRTOUL(c,p,b) strtoul((c),(p),(b)) |
# define STRCPY(a,b) strcpy((a),(b)) |
# define STRCHR(a,b) strchr((a),(b)) |
# define STRLEN(a) strlen(a) |
# else |
# define strftime wcsftime /* Alternate function name */ |
# define CHAR wchar_t /* string type basis */ |
# define CQ(a) L##a /* character constant qualifier */ |
# define snprintf swprintf /* wide-char equivalent function name */ |
# define strncmp wcsncmp /* wide-char equivalent function name */ |
# define TOLOWER(c) towlower((wint_t)(c)) |
# define STRTOUL(c,p,b) wcstoul((c),(p),(b)) |
# define STRCPY(a,b) wcscpy((a),(b)) |
# define STRCHR(a,b) wcschr((a),(b)) |
# define STRLEN(a) wcslen(a) |
# define SFLG "l" /* %s flag (l for wide char) */ |
# ifdef __HAVE_LOCALE_INFO_EXTENDED__ |
# define _ctloc(x) (ctloclen = wcslen (ctloc = _CurrentTimeLocale->w##x), \ |
ctloc) |
# else |
# define CTLOCBUFLEN 256 /* Arbitrary big buffer size */ |
const wchar_t * |
__ctloc (wchar_t *buf, const char *elem, size_t *len_ret) |
{ |
buf[CTLOCBUFLEN - 1] = L'\0'; |
*len_ret = mbstowcs (buf, elem, CTLOCBUFLEN - 1); |
if (*len_ret == (size_t) -1 ) |
*len_ret = 0; |
return buf; |
} |
# define _ctloc(x) (ctloc = __ctloc (ctlocbuf, _CurrentTimeLocale->x, \ |
&ctloclen)) |
# endif |
#endif /* MAKE_WCSFTIME */ |
size_t _DEFUN (strftime, (s, maxsize, format, tim_p), |
CHAR *s _AND |
size_t maxsize _AND |
_CONST CHAR *format _AND |
_CONST struct tm *tim_p) |
{ |
return 0; |
} |
/contrib/sdk/sources/libc/time/time.c |
---|
0,0 → 1,61 |
/* |
FUNCTION |
<<time>>---get current calendar time (as single number) |
INDEX |
time |
ANSI_SYNOPSIS |
#include <time.h> |
time_t time(time_t *<[t]>); |
TRAD_SYNOPSIS |
#include <time.h> |
time_t time(<[t]>) |
time_t *<[t]>; |
DESCRIPTION |
<<time>> looks up the best available representation of the current |
time and returns it, encoded as a <<time_t>>. It stores the same |
value at <[t]> unless the argument is <<NULL>>. |
RETURNS |
A <<-1>> result means the current time is not available; otherwise the |
result represents the current time. |
PORTABILITY |
ANSI C requires <<time>>. |
Supporting OS subroutine required: Some implementations require |
<<gettimeofday>>. |
*/ |
/* Most times we have a system call in newlib/libc/sys/.. to do this job */ |
#include <_ansi.h> |
#include <reent.h> |
#include <sys/types.h> |
#include <sys/time.h> |
time_t |
_DEFUN (time, (t), |
time_t * t) |
{ |
struct timeval now; |
if (_gettimeofday_r (_REENT, &now, NULL) >= 0) |
{ |
if (t) |
*t = now.tv_sec; |
return now.tv_sec; |
} |
return -1; |
} |
int |
_DEFUN (gettimeofday, (ptimeval, ptimezone), |
struct timeval *ptimeval _AND |
void *ptimezone) |
{ |
return _gettimeofday_r (_REENT, ptimeval, ptimezone); |
} |
/contrib/sdk/sources/libc/time/tzlock.c |
---|
0,0 → 1,56 |
/* |
FUNCTION |
<<__tz_lock>>, <<__tz_unlock>>---lock time zone global variables |
INDEX |
__tz_lock |
INDEX |
__tz_unlock |
ANSI_SYNOPSIS |
#include "local.h" |
void __tz_lock (void); |
void __tz_unlock (void); |
TRAD_SYNOPSIS |
void __tz_lock(); |
void __tz_unlock(); |
DESCRIPTION |
The <<tzset>> facility functions call these functions when they need to |
ensure the values of global variables. The version of these routines |
supplied in the library use the lock API defined in sys/lock.h. If multiple |
threads of execution can call the time functions and give up scheduling in |
the middle, then you you need to define your own versions of these functions |
in order to safely lock the time zone variables during a call. If you do |
not, the results of <<localtime>>, <<mktime>>, <<ctime>>, and <<strftime>> |
are undefined. |
The lock <<__tz_lock>> may not be called recursively; that is, |
a call <<__tz_lock>> will always lock all subsequent <<__tz_lock>> calls |
until the corresponding <<__tz_unlock>> call on the same thread is made. |
*/ |
#include <_ansi.h> |
#include "local.h" |
#include <sys/lock.h> |
#ifndef __SINGLE_THREAD__ |
__LOCK_INIT(static, __tz_lock_object); |
#endif |
_VOID |
_DEFUN_VOID (__tz_lock) |
{ |
#ifndef __SINGLE_THREAD__ |
__lock_acquire(__tz_lock_object); |
#endif |
} |
_VOID |
_DEFUN_VOID (__tz_unlock) |
{ |
#ifndef __SINGLE_THREAD__ |
__lock_release(__tz_lock_object); |
#endif |
} |
/contrib/sdk/sources/libc/time/tzvars.c |
---|
0,0 → 1,10 |
#include <time.h> |
/* Global timezone variables. */ |
/* Default timezone to GMT */ |
char *_tzname[2] = {"GMT", "GMT"}; |
int _daylight = 0; |
long _timezone = 0; |
/contrib/sdk/sources/libc/unpack/unpacker.asm |
---|
0,0 → 1,532 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
format MS COFF |
section '.text' code readable align 16 |
public _unpack@8 |
; void __stdcall unpack(void* packed_data, void* unpacked_data); |
_unpack@8: |
unpack: |
pushad |
mov esi, [esp+32+4] |
mov edi, [esp+32+8] |
mov eax, [esi+8] |
and al, 0xC0 |
cmp al, 0xC0 |
jz .failed |
mov eax, [esi+8] |
push eax |
add esi, 12 |
and al, not 0xC0 |
dec eax |
jz .lzma |
.failed: |
pop eax |
popad |
ret 8 |
.lzma: |
call .lzma_unpack |
.common: |
pop eax |
test al, 0x80 |
jnz .ctr1 |
test al, 0x40 |
jz .ok |
lodsd |
mov ecx, eax |
jecxz .ok |
mov dl, [esi] |
mov esi, [esp+32+8] |
.c1: |
lodsb |
sub al, 0E8h |
cmp al, 1 |
ja .c1 |
cmp byte [esi], dl |
jnz .c1 |
lodsd |
; "bswap eax" is not supported on i386 |
shr ax, 8 |
ror eax, 16 |
xchg al, ah |
sub eax, esi |
add eax, [esp+32+8] |
mov [esi-4], eax |
loop .c1 |
.ok: |
popad |
ret 8 |
.ctr1: |
lodsd |
mov ecx, eax |
jecxz .ok |
mov dl, [esi] |
mov esi, [esp+32+8] |
.c2: |
lodsb |
@@: |
cmp al, 0xF |
jnz .f |
lodsb |
cmp al, 80h |
jb @b |
cmp al, 90h |
jb @f |
.f: |
sub al, 0E8h |
cmp al, 1 |
ja .c2 |
@@: |
cmp byte [esi], dl |
jnz .c2 |
lodsd |
shr ax, 8 |
ror eax, 16 |
xchg al, ah |
sub eax, esi |
add eax, [esp+32+8] |
mov [esi-4], eax |
loop .c2 |
jmp .ok |
.lzma_unpack: |
.pb = 2 ; pos state bits |
.lp = 0 ; literal pos state bits |
.lc = 3 ; literal context bits |
.posStateMask = ((1 shl .pb)-1) |
.literalPosMask = ((1 shl .lp)-1) |
.kNumPosBitsMax = 4 |
.kNumPosStatesMax = (1 shl .kNumPosBitsMax) |
.kLenNumLowBits = 3 |
.kLenNumLowSymbols = (1 shl .kLenNumLowBits) |
.kLenNumMidBits = 3 |
.kLenNumMidSymbols = (1 shl .kLenNumMidBits) |
.kLenNumHighBits = 8 |
.kLenNumHighSymbols = (1 shl .kLenNumHighBits) |
.LenChoice = 0 |
.LenChoice2 = 1 |
.LenLow = 2 |
.LenMid = (.LenLow + (.kNumPosStatesMax shl .kLenNumLowBits)) |
.LenHigh = (.LenMid + (.kNumPosStatesMax shl .kLenNumMidBits)) |
.kNumLenProbs = (.LenHigh + .kLenNumHighSymbols) |
.kNumStates = 12 |
.kNumLitStates = 7 |
.kStartPosModelIndex = 4 |
.kEndPosModelIndex = 14 |
.kNumFullDistances = (1 shl (.kEndPosModelIndex/2)) |
.kNumPosSlotBits = 6 |
.kNumLenToPosStates = 4 |
.kNumAlignBits = 4 |
.kAlignTableSize = (1 shl .kNumAlignBits) |
.kMatchMinLen = 2 |
.IsMatch = 0 |
.IsRep = (.IsMatch + (.kNumStates shl .kNumPosBitsMax)) |
.IsRepG0 = (.IsRep + .kNumStates) |
.IsRepG1 = (.IsRepG0 + .kNumStates) |
.IsRepG2 = (.IsRepG1 + .kNumStates) |
.IsRep0Long = (.IsRepG2 + .kNumStates) |
.PosSlot = (.IsRep0Long + (.kNumStates shl .kNumPosBitsMax)) |
.SpecPos = (.PosSlot + (.kNumLenToPosStates shl .kNumPosSlotBits)) |
.Align_ = (.SpecPos + .kNumFullDistances - .kEndPosModelIndex) |
.Lencoder = (.Align_ + .kAlignTableSize) |
.RepLencoder = (.Lencoder + .kNumLenProbs) |
.Literal = (.RepLencoder + .kNumLenProbs) |
.LZMA_BASE_SIZE = 1846 ; must be ==Literal |
.LZMA_LIT_SIZE = 768 |
.kNumTopBits = 24 |
.kTopValue = (1 shl .kNumTopBits) |
.kNumBitModelTotalBits = 11 |
.kBitModelTotal = (1 shl .kNumBitModelTotalBits) |
.kNumMoveBits = 5 |
push edi |
; int state=0; |
xor ebx, ebx |
mov [.previousByte], bl |
; unsigned rep0=1,rep1=1,rep2=1,rep3=1; |
mov eax, 1 |
mov edi, .rep0 |
stosd |
stosd |
stosd |
stosd |
; int len=0; |
; result=0; |
mov ecx, .Literal + (.LZMA_LIT_SIZE shl (.lc+.lp)) |
mov eax, .kBitModelTotal/2 |
lea edi, [.p] |
rep stosd |
; RangeDecoderInit |
; rd->ExtraBytes = 0 |
; rd->Buffer = stream |
; rd->BufferLim = stream+bufferSize |
; rd->Range = 0xFFFFFFFF |
pop edi |
mov ebp, [esi-8] ; dest_length |
add ebp, edi ; ebp = destination limit |
lodsd |
; rd->code_ = eax |
mov [.code_], eax |
or [.range], -1 |
.main_loop: |
cmp edi, ebp |
jae .main_loop_done |
mov edx, edi |
and edx, .posStateMask |
mov eax, ebx |
shl eax, .kNumPosBitsMax+2 |
lea eax, [.p+.IsMatch*4 + eax + edx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
jc .1 |
movzx eax, [.previousByte] |
if .literalPosMask |
mov ah, dl |
and ah, .literalPosMask |
end if |
shr eax, 8-.lc |
imul eax, .LZMA_LIT_SIZE*4 |
add eax, (.p+.Literal*4) |
; add eax, [.p] |
cmp ebx, .kNumLitStates |
jb .literal |
xor edx, edx |
sub edx, [.rep0] |
mov dl, [edi + edx] |
call .LzmaLiteralDecodeMatch |
jmp @f |
.literal: |
call .LzmaLiteralDecode |
@@: |
mov [.previousByte], al |
stosb |
mov al, bl |
cmp bl, 4 |
jb @f |
mov al, 3 |
cmp bl, 10 |
jb @f |
mov al, 6 |
@@: sub bl, al |
jmp .main_loop |
.1: |
lea eax, [.p+.IsRep*4 + ebx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
jnc .10 |
lea eax, [.p+.IsRepG0*4 + ebx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
jc .111 |
mov eax, ebx |
shl eax, .kNumPosBitsMax+2 |
lea eax, [.p+.IsRep0Long*4 + eax + edx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
jc .1101 |
cmp bl, 7 |
setae bl |
lea ebx, [9 + ebx + ebx] |
xor edx, edx |
sub edx, [.rep0] |
mov al, [edi + edx] |
stosb |
mov [.previousByte], al |
jmp .main_loop |
.111: |
lea eax, [.p+.IsRepG1*4 + ebx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
mov eax, [.rep1] |
jnc .l3 |
.l1: |
lea eax, [.p+.IsRepG2*4 + ebx*4] |
; add eax, [.p] |
call .RangeDecoderBitDecode |
mov eax, [.rep2] |
jnc .l2 |
xchg [.rep3], eax |
.l2: |
push [.rep1] |
pop [.rep2] |
.l3: |
xchg eax, [.rep0] |
mov [.rep1], eax |
.1101: |
mov eax, (.p+.RepLencoder*4) |
; add eax, [.p] |
call .LzmaLenDecode |
cmp bl, 7 |
setc bl |
adc bl, bl |
xor bl, 3 |
add bl, 8 |
jmp .repmovsb |
.10: |
mov eax, [.rep0] |
xchg eax, [.rep1] |
xchg eax, [.rep2] |
xchg eax, [.rep3] |
cmp bl, 7 |
setc bl |
adc bl, bl |
xor bl, 3 |
add bl, 7 |
mov eax, (.p+.Lencoder*4) |
; add eax, [.p] |
call .LzmaLenDecode |
mov eax, .kNumLenToPosStates-1 |
cmp eax, ecx |
jb @f |
mov eax, ecx |
@@: |
push ecx |
mov ecx, .kNumPosSlotBits |
shl eax, cl |
shl eax, 2 |
add eax, (.p+.PosSlot*4) |
; add eax, [.p] |
call .RangeDecoderBitTreeDecode |
mov [.rep0], ecx |
cmp ecx, .kStartPosModelIndex |
jb .l6 |
push ecx |
mov eax, ecx |
and eax, 1 |
shr ecx, 1 |
or eax, 2 |
dec ecx |
shl eax, cl |
mov [.rep0], eax |
pop edx |
cmp edx, .kEndPosModelIndex |
jae .l5 |
sub eax, edx |
shl eax, 2 |
add eax, (.p+(.SpecPos - 1)*4) |
; add eax, [.p] |
call .RangeDecoderReverseBitTreeDecode |
add [.rep0], ecx |
jmp .l6 |
.l5: |
sub ecx, .kNumAlignBits |
call .RangeDecoderDecodeDirectBits |
mov ecx, .kNumAlignBits |
shl eax, cl |
add [.rep0], eax |
mov eax, (.p+.Align_*4) |
; add eax, [.p] |
call .RangeDecoderReverseBitTreeDecode |
add [.rep0], ecx |
.l6: |
pop ecx |
inc [.rep0] |
jz .main_loop_done |
.repmovsb: |
add ecx, .kMatchMinLen |
push esi |
mov esi, edi |
sub esi, [.rep0] |
rep movsb |
pop esi |
mov al, [edi-1] |
mov [.previousByte], al |
jmp .main_loop |
.main_loop_done: |
ret |
.RangeDecoderBitDecode: |
; in: eax->prob |
; out: CF=bit; destroys eax |
push edx |
mov edx, [.range] |
shr edx, .kNumBitModelTotalBits |
imul edx, [eax] |
cmp [.code_], edx |
jae .ae |
mov [.range], edx |
mov edx, .kBitModelTotal |
sub edx, [eax] |
shr edx, .kNumMoveBits |
add [eax], edx |
clc |
.n: |
lahf |
cmp [.range], .kTopValue |
jae @f |
shl [.range], 8 |
shl [.code_], 8 |
lodsb |
mov byte [.code_], al |
@@: |
sahf |
pop edx |
ret |
.ae: |
sub [.range], edx |
sub [.code_], edx |
mov edx, [eax] |
shr edx, .kNumMoveBits |
sub [eax], edx |
stc |
jmp .n |
.RangeDecoderDecodeDirectBits: |
; in: ecx=numTotalBits |
; out: eax=result; destroys edx |
xor eax, eax |
.l: |
shr [.range], 1 |
shl eax, 1 |
mov edx, [.code_] |
sub edx, [.range] |
jb @f |
mov [.code_], edx |
or eax, 1 |
@@: |
cmp [.range], .kTopValue |
jae @f |
shl [.range], 8 |
shl [.code_], 8 |
push eax |
lodsb |
mov byte [.code_], al |
pop eax |
@@: |
loop .l |
ret |
.LzmaLiteralDecode: |
; in: eax->probs |
; out: al=byte; destroys edx |
push ecx |
mov ecx, 1 |
@@: |
push eax |
lea eax, [eax+ecx*4] |
call .RangeDecoderBitDecode |
pop eax |
adc cl, cl |
jnc @b |
.LzmaLiteralDecode.ret: |
mov al, cl |
pop ecx |
ret |
.LzmaLiteralDecodeMatch: |
; in: eax->probs, dl=matchByte |
; out: al=byte; destroys edx |
push ecx |
mov ecx, 1 |
.LzmaLiteralDecodeMatch.1: |
add dl, dl |
setc ch |
push eax |
lea eax, [eax+ecx*4+0x100*4] |
call .RangeDecoderBitDecode |
pop eax |
adc cl, cl |
jc .LzmaLiteralDecode.ret |
xor ch, cl |
test ch, 1 |
mov ch, 0 |
jnz @b |
jmp .LzmaLiteralDecodeMatch.1 |
.LzmaLenDecode: |
; in: eax->prob, edx=posState |
; out: ecx=len |
push eax |
add eax, .LenChoice*4 |
call .RangeDecoderBitDecode |
pop eax |
jnc .0 |
push eax |
add eax, .LenChoice2*4 |
call .RangeDecoderBitDecode |
pop eax |
jc @f |
mov ecx, .kLenNumMidBits |
shl edx, cl |
lea eax, [eax + .LenMid*4 + edx*4] |
call .RangeDecoderBitTreeDecode |
add ecx, .kLenNumLowSymbols |
ret |
@@: |
add eax, .LenHigh*4 |
mov ecx, .kLenNumHighBits |
call .RangeDecoderBitTreeDecode |
add ecx, .kLenNumLowSymbols + .kLenNumMidSymbols |
ret |
.0: |
mov ecx, .kLenNumLowBits |
shl edx, cl |
lea eax, [eax + .LenLow*4 + edx*4] |
.RangeDecoderBitTreeDecode: |
; in: eax->probs,ecx=numLevels |
; out: ecx=length; destroys edx |
push ebx |
mov edx, 1 |
mov ebx, edx |
@@: |
push eax |
lea eax, [eax+edx*4] |
call .RangeDecoderBitDecode |
pop eax |
adc dl, dl |
add bl, bl |
loop @b |
sub dl, bl |
pop ebx |
mov ecx, edx |
ret |
.RangeDecoderReverseBitTreeDecode: |
; in: eax->probs,ecx=numLevels |
; out: ecx=length; destroys edx |
push ebx ecx |
mov edx, 1 |
xor ebx, ebx |
@@: |
push eax |
lea eax, [eax+edx*4] |
call .RangeDecoderBitDecode |
lahf |
adc edx, edx |
sahf |
rcr ebx, 1 |
pop eax |
loop @b |
pop ecx |
rol ebx, cl |
mov ecx, ebx |
pop ebx |
ret |
section ".bss" data readable writeable align 16 |
unpack.p rd (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl (unpack.lc+unpack.lp)))*2 |
align 4 |
unpack.code_ dd ? |
unpack.range dd ? |
unpack.rep0 dd ? |
unpack.rep1 dd ? |
unpack.rep2 dd ? |
unpack.rep3 dd ? |
unpack.previousByte db ? |