/shark/trunk/oslib/config.mk |
---|
File deleted |
/shark/trunk/oslib/makefile |
---|
File deleted |
/shark/trunk/oslib/examples/cpudemo.c |
---|
File deleted |
/shark/trunk/oslib/examples/makefile |
---|
File deleted |
/shark/trunk/oslib/examples/scheddem.c |
---|
File deleted |
/shark/trunk/oslib/examples/syscalls.c |
---|
File deleted |
/shark/trunk/oslib/examples/bugs.txt |
---|
File deleted |
/shark/trunk/oslib/examples/timetest.c |
---|
File deleted |
/shark/trunk/oslib/examples/ctxswdem.c |
---|
File deleted |
/shark/trunk/oslib/examples/biosdemo.c |
---|
File deleted |
/shark/trunk/oslib/examples/mbdemo.c |
---|
File deleted |
/shark/trunk/oslib/examples/pitsdemo.c |
---|
File deleted |
/shark/trunk/oslib/examples/pushdem.c |
---|
File deleted |
/shark/trunk/oslib/examples/vmdemo.c |
---|
File deleted |
/shark/trunk/oslib/examples/eventdem.c |
---|
File deleted |
/shark/trunk/oslib/examples/asdemo.c |
---|
File deleted |
/shark/trunk/oslib/xlib/ctx.s |
---|
File deleted |
/shark/trunk/oslib/xlib/xinfo.c |
---|
File deleted |
/shark/trunk/oslib/xlib/xdosf.c |
---|
File deleted |
/shark/trunk/oslib/xlib/xbios.c |
---|
File deleted |
/shark/trunk/oslib/xlib/x1.c |
---|
File deleted |
/shark/trunk/oslib/xlib/cpu2.s |
---|
File deleted |
/shark/trunk/oslib/xlib/xdosm.c |
---|
File deleted |
/shark/trunk/oslib/xlib/ccpu.c |
---|
File deleted |
/shark/trunk/oslib/xlib/fpu.c |
---|
File deleted |
/shark/trunk/oslib/xlib/xinit.c |
---|
File deleted |
/shark/trunk/oslib/xlib/irq.c |
---|
File deleted |
/shark/trunk/oslib/xlib/makefile |
---|
File deleted |
/shark/trunk/oslib/xlib/xconv.c |
---|
File deleted |
/shark/trunk/oslib/xlib/xsystab.c |
---|
File deleted |
/shark/trunk/oslib/xlib/mem.s |
---|
File deleted |
/shark/trunk/oslib/xlib/exc.s |
---|
File deleted |
/shark/trunk/oslib/xlib/vm86.c |
---|
File deleted |
/shark/trunk/oslib/xlib/idtinit.c |
---|
File deleted |
/shark/trunk/oslib/xlib/xsys0.s |
---|
File deleted |
/shark/trunk/oslib/xlib/x0.s |
---|
File deleted |
/shark/trunk/oslib/xlib/ctxsw.c |
---|
File deleted |
/shark/trunk/oslib/GPL.txt |
---|
File deleted |
/shark/trunk/oslib/tools/binfin.c |
---|
File deleted |
/shark/trunk/oslib/tools/checksymbols.c |
---|
File deleted |
/shark/trunk/oslib/todo.txt |
---|
File deleted |
/shark/trunk/oslib/libm/makefile |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_signga.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_sqrt.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_j1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_signif.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_asinf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_ceilf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/k_cosf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_acoshf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_log10.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_acos.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_cosf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_modff.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_ilogb.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_atan2f.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_jnf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_cosh.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_scalbn.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_gamma_.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_asinf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_rint.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_atanh.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_sqrtf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_logb.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_j0f.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_lgam2.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/k_sinf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_jn.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_drem.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_gammaf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_atanh.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_sinf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_sqrtf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_sinh.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_lgam2.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/math_private.h |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_expf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_copysi.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_acos.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_rem1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_log10f.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_scalbf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_ldexp.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_fmodf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_hypotf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_cosh.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_powf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/k_sin.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_log1p.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_nextaf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_log.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_log1pf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_logbf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_sin.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_tanh.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_copy1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_fmodf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_tanhf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_dremf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/k_standa.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_ilogbf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_scal1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_acoshf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_pow.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_cabs.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_finite.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_acosh.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_atan2f.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_mather.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_rintf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_sinh.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_expf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_gamma_.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_lgam3.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_rem1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_atan2.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_fmod.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_j0.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_powf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_next1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_exp.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_acosh.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_lgam3.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_atan2.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_jn.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/math.h |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_isnanf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_lgamma.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_ldexpf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_atanhf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_atan.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_frexp.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_j1f.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_hypot.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/math_pri.h |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_sinhf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_log10f.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_remain.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_asin.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_scalbf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_j0f.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_asinh.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_gamma.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_hypot.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_fmod.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_asinhf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_sinhf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_erf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_jnf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_cabsf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_modf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_gamma.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_rem2.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_atanf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_cbrt.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_logf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/k_rem1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_j1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_cbrtf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_log.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/k_rem_pi.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_fini1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_scalb.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_isnan.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/k_tan.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_fabs.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_asin.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/k_cos.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_ceil.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_gamf1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_j0.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/k_tanf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_tan.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_coshf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_cos.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_pow.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_floorf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_tanf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_scalb.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_frexpf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_sqrt.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_gamf1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_lib_ve.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_lgamma.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_atanhf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_coshf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_logf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_gammaf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_acosf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_exp.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_remain.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_fabsf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_floor.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_sign1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_erff.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_lgam1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_expm1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_hypotf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_rem_pi.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_acosf.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/s_expm1f.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_j1f.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/e_log10.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/src/w_lgam1.c |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_logb.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_atan.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_cos.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/e_atan2.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_sin.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_ilogb.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/e_remain.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_scalbn.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/e_log.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/e_log10.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_copysi.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/e_scalb.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/e_acos.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/e_fmod.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/e_sqrt.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/e_asin.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_rint.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_ceil.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_finite.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/e_exp.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_signif.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_floor.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_log1p.s |
---|
File deleted |
/shark/trunk/oslib/libm/msun/i387/s_tan.s |
---|
File deleted |
/shark/trunk/oslib/libm/machine/endian.h |
---|
File deleted |
/shark/trunk/oslib/libm/machine/defs.h |
---|
File deleted |
/shark/trunk/oslib/libm/machine/infinity.c |
---|
File deleted |
/shark/trunk/oslib/libm/machine/asmacros.h |
---|
File deleted |
/shark/trunk/oslib/libm/machine/stub.c |
---|
File deleted |
/shark/trunk/oslib/kl/abort.s |
---|
File deleted |
/shark/trunk/oslib/kl/intevt.c |
---|
File deleted |
/shark/trunk/oslib/kl/timeint.s |
---|
File deleted |
/shark/trunk/oslib/kl/advtimer.c |
---|
File deleted |
/shark/trunk/oslib/kl/oq.txt |
---|
File deleted |
/shark/trunk/oslib/kl/aspace.c |
---|
File deleted |
/shark/trunk/oslib/kl/makefile |
---|
File deleted |
/shark/trunk/oslib/kl/mem.c |
---|
File deleted |
/shark/trunk/oslib/kl/time.c |
---|
File deleted |
/shark/trunk/oslib/kl/event.c |
---|
File deleted |
/shark/trunk/oslib/kl/todo.txt |
---|
File deleted |
/shark/trunk/oslib/kl/estub.c |
---|
File deleted |
/shark/trunk/oslib/kl/event1.c |
---|
File deleted |
/shark/trunk/oslib/kl/cxsw-2.c |
---|
File deleted |
/shark/trunk/oslib/kl/init.c |
---|
File deleted |
/shark/trunk/oslib/lib/readme |
---|
File deleted |
/shark/trunk/oslib/lib/makefile |
---|
File deleted |
/shark/trunk/oslib/ll/time.h |
---|
File deleted |
/shark/trunk/oslib/ll/assert.h |
---|
File deleted |
/shark/trunk/oslib/ll/stdlib.h |
---|
File deleted |
/shark/trunk/oslib/ll/limits.h |
---|
File deleted |
/shark/trunk/oslib/ll/stdio.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/hw-func.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/mb-hdr.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/linkage.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/advtimer.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/pic.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/hw-instr.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/apic.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/mem.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/defs.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/stdlib.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/stdio.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/hw-io.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/sel.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/hw-data.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/mb-info.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/64bit.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/hw-arch.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/error.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/x-dosmem.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/int.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/x-dos.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/pit.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/farptr.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/limits.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/x-bios.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/cons.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/float.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/tss-ctx.h |
---|
File deleted |
/shark/trunk/oslib/ll/i386/string.h |
---|
File deleted |
/shark/trunk/oslib/ll/ctype.h |
---|
File deleted |
/shark/trunk/oslib/ll/stdarg.h |
---|
File deleted |
/shark/trunk/oslib/ll/errno.h |
---|
File deleted |
/shark/trunk/oslib/ll/float.h |
---|
File deleted |
/shark/trunk/oslib/ll/string.h |
---|
File deleted |
/shark/trunk/oslib/ll/unistd.h |
---|
File deleted |
/shark/trunk/oslib/ll/ll.h |
---|
File deleted |
/shark/trunk/oslib/ll/sys/ll/aspace.h |
---|
File deleted |
/shark/trunk/oslib/ll/sys/ll/time.h |
---|
File deleted |
/shark/trunk/oslib/ll/sys/ll/ll-data.h |
---|
File deleted |
/shark/trunk/oslib/ll/sys/ll/exc.h |
---|
File deleted |
/shark/trunk/oslib/ll/sys/ll/ll-func.h |
---|
File deleted |
/shark/trunk/oslib/ll/sys/ll/event.h |
---|
File deleted |
/shark/trunk/oslib/ll/sys/ll/ll-mem.h |
---|
File deleted |
/shark/trunk/oslib/ll/sys/ll/ll-instr.h |
---|
File deleted |
/shark/trunk/oslib/ll/sys/types.h |
---|
File deleted |
/shark/trunk/oslib/ll/sys/cdefs.h |
---|
File deleted |
/shark/trunk/oslib/ll/math.h |
---|
File deleted |
/shark/trunk/oslib/mk/oldgnu.mk |
---|
File deleted |
/shark/trunk/oslib/mk/gnu.mk |
---|
File deleted |
/shark/trunk/oslib/mk/linux.mk |
---|
File deleted |
/shark/trunk/oslib/mk/os.x |
---|
File deleted |
/shark/trunk/oslib/docs/todo.txt |
---|
File deleted |
/shark/trunk/oslib/docs/oslib.tex |
---|
File deleted |
/shark/trunk/oslib/docs/ref.txt |
---|
File deleted |
/shark/trunk/oslib/docs/makefile |
---|
File deleted |
/shark/trunk/oslib/libc/reboot.c |
---|
File deleted |
/shark/trunk/oslib/libc/makefile |
---|
File deleted |
/shark/trunk/oslib/libc/ioformat/fcvt.c |
---|
File deleted |
/shark/trunk/oslib/libc/ioformat/gcvt.c |
---|
File deleted |
/shark/trunk/oslib/libc/ioformat/sprintf.c |
---|
File deleted |
/shark/trunk/oslib/libc/ioformat/sprintf.h |
---|
File deleted |
/shark/trunk/oslib/libc/ioformat/sscanf.c |
---|
File deleted |
/shark/trunk/oslib/libc/ioformat/ksprintf.c |
---|
File deleted |
/shark/trunk/oslib/libc/ioformat/ecvt.c |
---|
File deleted |
/shark/trunk/oslib/libc/ioformat/ucvt.c |
---|
File deleted |
/shark/trunk/oslib/libc/stdlib/strtod.c |
---|
File deleted |
/shark/trunk/oslib/libc/stdlib/strtou.c |
---|
File deleted |
/shark/trunk/oslib/libc/stdlib/random.c |
---|
File deleted |
/shark/trunk/oslib/libc/stdlib/stdlib.c |
---|
File deleted |
/shark/trunk/oslib/libc/stdlib/strtoi.c |
---|
File deleted |
/shark/trunk/oslib/libc/stdlib/strtol.c |
---|
File deleted |
/shark/trunk/oslib/libc/stdlib/strtoul.c |
---|
File deleted |
/shark/trunk/oslib/libc/modf.s |
---|
File deleted |
/shark/trunk/oslib/libc/string/strncat.c |
---|
File deleted |
/shark/trunk/oslib/libc/string/special.c |
---|
File deleted |
/shark/trunk/oslib/libc/string/strstr.c |
---|
File deleted |
/shark/trunk/oslib/libc/string/strbase.c |
---|
File deleted |
/shark/trunk/oslib/libc/string/string.c |
---|
File deleted |
/shark/trunk/oslib/libc/string/strrchr.c |
---|
File deleted |
/shark/trunk/oslib/libc/string/strnum.c |
---|
File deleted |
/shark/trunk/oslib/libcons/cons1.c |
---|
File deleted |
/shark/trunk/oslib/libcons/message.c |
---|
File deleted |
/shark/trunk/oslib/libcons/cons2.c |
---|
File deleted |
/shark/trunk/oslib/libcons/cprintf.c |
---|
File deleted |
/shark/trunk/oslib/libcons/makefile |
---|
File deleted |
/shark/trunk/makefile |
---|
File deleted |
/shark/trunk/mkf/makefile.kl |
---|
File deleted |
/shark/trunk/mkf/makefile.libm |
---|
File deleted |
/shark/trunk/kernel/makefile |
---|
File deleted |
/shark/trunk/kernel/join.c |
---|
50,9 → 50,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/kern.c |
---|
59,9 → 59,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/tpreempt.c |
---|
50,9 → 50,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/activate.c |
---|
50,9 → 50,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/blkact.c |
---|
53,9 → 53,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/mqueue.c |
---|
49,7 → 49,7 |
*/ |
#include <mqueue.h> |
#include <ll/string.h> |
#include <arch/string.h> |
#include <kernel/types.h> |
#include <kernel/var.h> |
#include <kernel/func.h> |
/shark/trunk/kernel/assert.c |
---|
44,9 → 44,9 |
*/ |
#include <ll/i386/cons.h> |
#include <ll/stdarg.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/stdarg.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <kernel/func.h> |
#include <kernel/var.h> |
#include <kernel/assert.h> |
/shark/trunk/kernel/init.c |
---|
51,9 → 51,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/printk.c |
---|
44,9 → 44,9 |
*/ |
#include <ll/i386/cons.h> |
#include <ll/stdarg.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/stdarg.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <kernel/log.h> |
#include <kernel/func.h> |
/shark/trunk/kernel/grpcreat.c |
---|
52,9 → 52,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/tskmsg.c |
---|
48,9 → 48,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/perror.c |
---|
19,8 → 19,8 |
#include <errno.h> |
#include <kernel/const.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <kernel/func.h> |
/* This is a list of all known `errno' codes. */ |
/shark/trunk/kernel/nanoslp.c |
---|
51,9 → 51,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/keys.c |
---|
51,9 → 51,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/signal.c |
---|
75,8 → 75,8 |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <ll/i386/pic.h> |
#include <signal.h> |
#include <errno.h> |
/shark/trunk/kernel/event.c |
---|
54,9 → 54,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/jet.c |
---|
58,9 → 58,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/cancel.c |
---|
53,9 → 53,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/panic.c |
---|
44,9 → 44,9 |
*/ |
#include <ll/i386/cons.h> |
#include <ll/stdarg.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/stdarg.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <stdlib.h> |
#include <kernel/func.h> |
/shark/trunk/kernel/kill.c |
---|
54,9 → 54,9 |
#include <stdarg.h> |
#include <ll/ll.h> |
#include <ll/stdlib.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/kernel/Makefile |
---|
0,0 → 1,31 |
targets:= \ |
activate.o \ |
assert.o \ |
blkact.o \ |
cancel.o \ |
conditio.o \ |
event.o \ |
exchand.o \ |
grpcreat.o \ |
jet.o \ |
join.o \ |
kern.o \ |
keys.o \ |
kill.o \ |
init.o \ |
int_sem.o \ |
mem/ \ |
mem.o \ |
mqueue.o \ |
mutex.o \ |
nanoslp.o \ |
panic.o \ |
printk.o \ |
perror.o \ |
pthread.o \ |
iqueue.o \ |
signal.o \ |
time.o \ |
tpreempt.o \ |
tskmsg.o |
/shark/trunk/kernel/mem/makefile |
---|
File deleted |
/shark/trunk/kernel/mem/stats.c |
---|
73,7 → 73,7 |
#define DEBUG |
#endif |
#include <ll/stdio.h> |
#include <arch/stdio.h> |
#include <kernel/func.h> |
#include <kernel/lmm.h> |
/shark/trunk/kernel/mem/dump.c |
---|
74,7 → 74,7 |
#define DEBUG |
#endif |
#include <ll/stdio.h> |
#include <arch/stdio.h> |
#include <kernel/func.h> |
#include <kernel/lmm.h> |
#define assert(test) assertk(test) |
/shark/trunk/kernel/mem/Makefile |
---|
0,0 → 1,17 |
targets:= \ |
addfree.o \ |
addregio.o \ |
alloc.o \ |
alloc_al.o \ |
alloc_ge.o \ |
alloc_pa.o \ |
avail.o \ |
avail_in.o \ |
dump.o \ |
findfree.o \ |
free.o \ |
freepage.o \ |
init.o \ |
removefr.o \ |
stats.o |
/shark/trunk/tracer/makefile |
---|
File deleted |
/shark/trunk/tracer/include/qudp.h |
---|
40,7 → 40,7 |
#include <kernel/model.h> |
#include <drivers/udpip.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/tracer/include/qdummy.h |
---|
38,7 → 38,7 |
#ifndef __TRACE_QDUMMY_H |
#define __TRACE_QDUMMY_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/tracer/include/trace.h |
---|
48,7 → 48,7 |
#ifndef __TRACE_TRACE_H |
#define __TRACE_TRACE_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/tracer/include/qfixed.h |
---|
38,7 → 38,7 |
#ifndef __TRACE_QFIXED_H |
#define __TRACE_QFIXED_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/tracer/include/qcirc.h |
---|
38,7 → 38,7 |
#ifndef __TRACE_QCIRC_H |
#define __TRACE_QCIRC_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/tracer/include/queues.h |
---|
50,7 → 50,7 |
#include <ll/sys/types.h> |
#include "types.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/tracer/include/FTrace_types.h |
---|
23,7 → 23,7 |
#include <ll/sys/types.h> |
#include <ll/i386/mem.h> |
#include <ll/math.h> |
#include <arch/math.h> |
#include "FTrace.h" |
/shark/trunk/tracer/newtrace/Makefile |
---|
0,0 → 1,7 |
targets:= \ |
FTrace.o \ |
FTrace_OSD.o \ |
FTrace_OSD_ll.o \ |
FTrace_udp.o \ |
FTrace_disk.o |
/shark/trunk/tracer/oldtrace/trcudp.c |
---|
39,7 → 39,7 |
*/ |
#include <ll/sys/types.h> |
#include <ll/stdlib.h> |
#include <arch/stdlib.h> |
#include <kernel/func.h> |
#include <kernel/mem.h> |
/shark/trunk/tracer/oldtrace/trcdfix.c |
---|
34,7 → 34,7 |
*/ |
#include <ll/sys/types.h> |
#include <ll/stdlib.h> |
#include <arch/stdlib.h> |
#include <kernel/func.h> |
#include <kernel/mem.h> |
/shark/trunk/tracer/oldtrace/trcdummy.c |
---|
34,7 → 34,7 |
*/ |
#include <ll/sys/types.h> |
#include <ll/stdlib.h> |
#include <arch/stdlib.h> |
#include <kernel/log.h> |
/shark/trunk/tracer/oldtrace/trcfixed.c |
---|
34,7 → 34,7 |
*/ |
#include <ll/sys/types.h> |
#include <ll/stdlib.h> |
#include <arch/stdlib.h> |
#include <kernel/func.h> |
#include <kernel/mem.h> |
/shark/trunk/tracer/oldtrace/trccirc.c |
---|
46,7 → 46,7 |
*/ |
#include <ll/sys/types.h> |
#include <ll/stdlib.h> |
#include <arch/stdlib.h> |
#include <kernel/func.h> |
#include <kernel/mem.h> |
/shark/trunk/tracer/oldtrace/Makefile |
---|
0,0 → 1,9 |
targets:= \ |
oldtrace.o \ |
trccirc.o \ |
trcdfix.o \ |
trcudp.o \ |
trcfixed.o \ |
trcdummy.o \ |
ctable.o |
/shark/trunk/tracer/oldtrace/oldtrace.c |
---|
40,8 → 40,8 |
#include <kernel/types.h> |
#include <kernel/var.h> |
#include <ll/stdlib.h> |
#include <ll/string.h> |
#include <arch/stdlib.h> |
#include <arch/string.h> |
#include <kernel/func.h> |
/shark/trunk/tracer/Makefile |
---|
0,0 → 1,11 |
targets-NEW:= libtracer.a |
targets-OLD:= libtracer.a |
objs-NEW:= newtrace/ |
objs-OLD:= oldtrace/ |
targets:= $(targets-$(TRACER)) |
libtracer.a-objs:= $(objs-$(TRACER)) |
exported-cppflags:= -I$(curdir)/include -I$(srctree)/drivers/net/include |
/shark/trunk/include/math.h |
---|
52,7 → 52,7 |
#ifndef __MATH_H__ |
#define __MATH_H__ |
#include <ll/math.h> |
#include <arch/math.h> |
/* not POSIX but required by some programs */ |
/shark/trunk/include/kernel/func.h |
---|
73,7 → 73,7 |
#define __KERNEL_FUNC_H__ |
#include <ll/ll.h> |
#include <ll/stdio.h> |
#include <arch/stdio.h> |
#include <kernel/types.h> |
#include <kernel/model.h> |
#include <kernel/mem.h> |
89,7 → 89,7 |
/* if a source use printk() it should include log.h not func.h */ |
#include <kernel/log.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/kernel/iqueue.h |
---|
75,7 → 75,7 |
#ifndef __KERNEL_IQUEUE_H__ |
#define __KERNEL_IQUEUE_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/kernel/int_sem.h |
---|
64,7 → 64,7 |
#include <kernel/types.h> |
#include <kernel/iqueue.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/kernel/kernmem.h |
---|
49,7 → 49,7 |
#ifndef __KERNEL_KERNMEM_H_ |
#define __KERNEL_KERNMEM_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/* These function are used to manage memory at VM layer */ |
/shark/trunk/include/kernel/mem.h |
---|
59,7 → 59,7 |
#define __KERNEL_MEM_H__ |
#include <kernel/lmm.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/kernel/kern.h |
---|
56,8 → 56,8 |
*/ |
#include <ll/ll.h> |
#include <ll/stdio.h> |
#include <ll/stdlib.h> |
#include <arch/stdio.h> |
#include <arch/stdlib.h> |
#include <kernel/config.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
/shark/trunk/include/kernel/descr.h |
---|
72,7 → 72,7 |
#include <kernel/types.h> |
#include <kernel/iqueue.h> |
#include <limits.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/kernel/model.h |
---|
56,7 → 56,7 |
#include "ll/ll.h" |
#include "kernel/types.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/kernel/assert.h |
---|
49,7 → 49,7 |
#ifndef _KERNEL_ASSERT_H |
#define _KERNEL_ASSERT_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/kernel/log.h |
---|
49,7 → 49,7 |
#ifndef __KERNEL_LOG_H |
#define __KERNEL_LOG_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/kernel/types.h |
---|
51,7 → 51,7 |
#ifndef __KERNEL_TYPES_H__ |
#define __KERNEL_TYPES_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/kernel/lmm.h |
---|
80,7 → 80,7 |
// this part was oskit/lmm.h |
#include <sys/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
typedef DWORD lmm_flags_t; |
/shark/trunk/include/kernel/var.h |
---|
57,7 → 57,7 |
#include <ll/ll.h> |
#include <sys/types.h> |
#include <kernel/descr.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/time.h |
---|
61,7 → 61,7 |
#endif |
/* timespec defined in ll/sys/ll/time.h */ |
#include <ll/time.h> |
#include <arch/time.h> |
#include <signal.h> |
/shark/trunk/include/assert.h |
---|
47,7 → 47,7 |
#ifndef __ASSERT_H |
#define __ASSERT_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/mqueue.h |
---|
61,7 → 61,7 |
#include <fcntl.h> |
#include <time.h> |
#include <signal.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/float.h |
---|
39,8 → 39,8 |
#ifndef _MACHINE_FLOAT_H_ |
#define _MACHINE_FLOAT_H_ 1 |
#include <ll/limits.h> |
#include <ll/float.h> |
#include <arch/limits.h> |
#include <arch/float.h> |
#define LDBL_MANT_DIG DBL_MANT_DIG |
#define LDBL_EPSILON DBL_EPSILON |
/shark/trunk/include/unistd.h |
---|
90,7 → 90,7 |
#define __UNISTD_H__ |
#include <features.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/string.h |
---|
50,8 → 50,8 |
#ifndef __STRING_H__ |
#define __STRING_H__ |
#include <ll/string.h> |
#include "ll/sys/cdefs.h" |
#include <arch/string.h> |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/trace/qudp.h |
---|
40,7 → 40,7 |
#include <kernel/model.h> |
#include <drivers/udpip.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/trace/qdummy.h |
---|
38,7 → 38,7 |
#ifndef __TRACE_QDUMMY_H |
#define __TRACE_QDUMMY_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/trace/trace.h |
---|
48,7 → 48,7 |
#ifndef __TRACE_TRACE_H |
#define __TRACE_TRACE_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/trace/qfixed.h |
---|
38,7 → 38,7 |
#ifndef __TRACE_QFIXED_H |
#define __TRACE_QFIXED_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/trace/qcirc.h |
---|
38,7 → 38,7 |
#ifndef __TRACE_QCIRC_H |
#define __TRACE_QCIRC_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/trace/queues.h |
---|
50,7 → 50,7 |
#include <ll/sys/types.h> |
#include <trace/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/bits/endian.h |
---|
53,5 → 53,5 |
#define _QUAD_LOWWORD 0 |
#endif |
#include "../../oslib/libm/machine/endian.h" |
#include <arch/endian.h> |
/shark/trunk/include/bits/limits.h |
---|
48,7 → 48,7 |
#ifndef _BITS_LIMITS_H |
#define _BITS_LIMITS_H |
#include <ll/limits.h> |
#include <arch/limits.h> |
#define FILENAME_MAX 1024 |
#define FOPEN_MAX 20 |
/shark/trunk/include/bits/errno.h |
---|
83,7 → 83,7 |
#ifndef __BITS_ERRNO_H__ |
#define __BITS_ERRNO_H__ |
#include <ll/errno.h> |
#include <arch/errno.h> |
/*---------------------------------------------------------------------*/ |
/* Abort values */ |
/shark/trunk/include/signal.h |
---|
95,7 → 95,7 |
#include <kernel/types.h> |
#include <sys/types.h> |
//#include <time.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/stdlib.h |
---|
53,10 → 53,10 |
#ifndef __STDLIB_H__ |
#define __STDLIB_H__ |
#include <ll/stdlib.h> |
#include <arch/stdlib.h> |
#include <sys/types.h> |
#include <stddef.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/irq.h |
---|
47,7 → 47,7 |
#ifndef __HARTIK_IRQ_H |
#define __HARTIK_IRQ_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/fsinit.h |
---|
47,7 → 47,7 |
#include <fs/major.h> |
#include <fs/fsind.h> |
#include <fs/mount.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/libio.h |
---|
55,7 → 55,7 |
#ifndef __FS_LIBIO_H |
#define __FS_LIBIO_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/limits.h |
---|
50,7 → 50,7 |
#define __FS_LIMITS_H |
#include <bits/limits.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/assert.h |
---|
50,7 → 50,7 |
#define __FS_ASSERT_H |
#include <kernel/assert.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/mutex.h |
---|
59,7 → 59,7 |
*/ |
#include <kernel/int_sem.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/mount.h |
---|
58,7 → 58,7 |
#include <fs/types.h> |
#include <fs/fsconf.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/bdevinit.h |
---|
54,7 → 54,7 |
#include <fs/types.h> |
#include <fs/const.h> |
#include <fs/bdevconf.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/fs.h |
---|
50,7 → 50,7 |
#include <fs/types.h> |
#include <fs/mount.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/syscall.h |
---|
40,7 → 40,7 |
#define __FS_SYSCALL_H |
#include <fs/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/semaph.h |
---|
55,7 → 55,7 |
#define _FS_SEMAPH_H |
#include <kernel/int_sem.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/util.h |
---|
57,13 → 57,13 |
#include <fs/types.h> |
#include <fs/stdarg.h> |
#include <ll/i386/stdio.h> |
//#include <ll/string.h> strcasecmp moved!!! |
#include <arch/i386/stdio.h> |
//#include <arch/string.h> strcasecmp moved!!! |
#include <string.h> |
#include <ll/stdlib.h> |
#include <arch/stdlib.h> |
#include <kernel/log.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/maccess.h |
---|
54,7 → 54,7 |
* verify read/write access to user space |
* |
*/ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/fs/bdev.h |
---|
49,7 → 49,7 |
#define __FS_BDEV_H__ |
#include <fs/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/stdio.h |
---|
97,7 → 97,7 |
#define _STDIO_H_ |
/* MG */ |
#include <ll/stdio.h> |
#include <arch/stdio.h> |
#include <kernel/descr.h> |
#include <limits.h> |
/shark/trunk/include/ctype.h |
---|
75,7 → 75,7 |
#include <features.h> |
#include <bits/types.h> |
#include <ll/ctype.h> |
#include <arch/ctype.h> |
__BEGIN_DECLS |
/shark/trunk/include/stdarg.h |
---|
53,6 → 53,6 |
#ifndef __STDARG_H__ |
#define __STDARG_H__ |
#include <ll/stdarg.h> |
#include <arch/stdarg.h> |
#endif |
/shark/trunk/include/sched.h |
---|
55,7 → 55,7 |
#define __SCHED_H__ |
#include <kernel/model.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/pthread.h |
---|
60,7 → 60,7 |
#include <signal.h> |
#include <errno.h> |
#include <kernel/func.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/sys/stat.h |
---|
33,7 → 33,7 |
# include <time.h> /* For time_t. */ |
#endif |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
/* The Single Unix specification says that some more types are |
available here. */ |
/shark/trunk/include/sys/utsname.h |
---|
53,7 → 53,7 |
#ifndef __SYS_UTSNAME_H__ |
#define __SYS_UTSNAME_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/sys/sysmacro.h |
---|
19,7 → 19,7 |
#ifndef _SYS_SYSMACROS_H |
#define _SYS_SYSMACROS_H 1 |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
_ |
/shark/trunk/include/sys/mount.h |
---|
44,7 → 44,7 |
#include <sys/types.h> |
#include <fs/mount.h> |
#include <fs/fsind.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/include/sys/cdefs.h |
---|
19,7 → 19,7 |
#ifndef _SYS_CDEFS_H |
#define _SYS_CDEFS_H 1 |
#include <ll/sys/cdefs.h> |
#include <arch/sys/cdefs.h> |
/* MODIFIED by this add */ |
/*#define __warn_references(func,str)*/ |
/shark/trunk/include/sys/types.h |
---|
61,7 → 61,7 |
#include <bits/types.h> |
#include <sys/htypes.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/Rules.mk |
---|
0,0 → 1,197 |
# Shark-specific bits of the build system. |
# Include the configuration file. |
topdir=$(if $(S),$(S),$(srctree)) |
include $(topdir)/shark.cfg |
# Those are the targets used to build all the libraries that compose |
# the system. This is the only point (except local Makefiles, of course, |
# that need to be added as needed) that has to be modified to add new files |
# or directories to the main system. |
# $(TARGETS) is the list of the main targets used to build the system, |
# it contains all the directories recursed by the main Makefile, and the |
# special target libgkern.a, that contains the base system. To add a |
# directory that specifies its own libraries simply put it in $(TARGETS). |
TARGETS= libgkern.a drivers/ libc/ ports/ tracer/ $(fs-$(SHARK_FS)) |
# $(LIBGKERN-OBJS) is the list of targets that compose libgkern.a. To |
# add a directory to it, simply put it here. The generic kernel used to |
# be separed from the oslib and from the modules, but that hardly made |
# sense for a Shark application, as all those three components are needed |
# for it to run. |
LIBGKERN-OBJS= arch/$(ARCH)/ kernel/ modules/ |
# Handle Shark configuration. Really insane, indeed, btw there should |
# not be the need to modify anything below this point in the file to |
# handle common maintainance tasks. |
options:=TSC APIC BIOS TRACER FG FB COMPILER |
define strip-in-place |
$(1):=$(strip $($(1))) |
endef |
$(foreach cfgopt,$(options),$(eval $(call strip-in-place,$(cfgopt)))) |
cpp-tsc-TRUE:= -D__TSC__ |
cpp-apic-TRUE:= -D__APIC__ |
cpp-bios-VM86:= -DVM86 |
cpp-tracer-NEW:= -D__NEW_TRACER__ |
cpp-tracer-OLD:= -D__OLD_TRACER__ |
cpp-fg-FORCE_PXC:= -D__FORCE_PXC__ |
cpp-fb-VESA:= -DCONFIG_FB_VESA -DCONFIG_LOGO |
cpp-fb-FINDPCI:= -DCONFIG_FB_RIVA -DCONFIG_FB_RADEON -DCONFIG_FB_MATROX \ |
-DCONFIG_LOGO -DCONFIG_FB_MATROX_G100 \ |
-DCONFIG_FB_MATROX_MILLENIUM -DCONFIG_FB_MATROX_MYSTIQUE |
cpp-fb-VGA16:= -DCONFIG_FB_VGA16 |
include-dirs:= \ |
-I$(topdir)/include -I$(topdir)/modules \ |
-I$(topdir)/arch/$(ARCH)/include/arch \ |
-I$(topdir)/libc/arch/$(ARCH)/include \ |
-I$(topdir)/tracer/include |
config:= -D__LINUX__ \ |
$(cpp-tsc-$(TSC)) $(cpp-apic-$(APIC)) $(cpp-bios-$(BIOS)) \ |
$(cpp-tracer-$(TRACER)) $(cpp-fg-$(FG)) $(cpp-fb-$(FB)) |
exported-cppflags:= $(include-dirs) $(config) |
exported-aflags:= -x assembler-with-cpp $(include-dirs) $(config) |
cc-compiler-GCC4:= -Wimplicit-function-declaration -Wno-attributes \ |
-Wno-pointer-sign -Wall -O -fno-builtin -nostdinc \ |
-minline-all-stringops -fno-stack-protector |
cc-compiler-GCC3:= -Wimplicit-function-declaration -Wall -O \ |
-fno-builtin -nostdinc -minline-all-stringops |
cc-compiler-DJGPP:= -Wimplicit-function-declaration -Wall -O \ |
-fno-builtin -nostdinc -minline-all-stringops |
exported-cflags:= $(cc-compiler-$(COMPILER)) |
fs-YES:= fs/ |
ifndef APP |
# If we are not building an application, just build the system libraries. |
targets:= $(TARGETS) |
libgkern.a-objs:= $(LIBGKERN-OBJS) |
all: install |
else |
# Rules to build a Shark application. The following variables are used: |
# APP: the application to build. |
# INIT: the initialization object file. |
# OTHEROBJS: other objects to be linked to the application. |
# OTHERLIBS: other libraries to be linked to the application. |
# OTHERINCL: additional preprocessor flags for the app and its |
# additional objects. |
# SHARKOPT: options to specify which Shark components are to be |
# linked to the application. |
# Directory where we search for the compiled Shark libraries. |
libs-dir:= $(if $(B),$(B)/.lib,$(if $(S),$(S)/.lib,\ |
$(if $(BASE),$(BASE)/.lib,../../.lib))) |
ifeq ($(wildcard $(libs-dir)),) |
$(error Cannod find Shark build directory) |
endif |
# Handle $(SHARKOPT). Always link the generic kernel and the architecture |
# support code, as they're needed for the application to run. Link the |
# libc too, as we still don't have proper interface separation. |
# XXX Bring back tracer and filesystem. |
# XXX The old build system included also the ports and other libs... |
app-libs:= -lgkern -lc -lcons -lserial |
app-cppflags:= -I$(topdir)/drivers/linuxc26/include\ |
-I$(topdir)/drivers/cons/include |
wants-option=$(if $(filter $(1),$(uselib)),y) |
use-zlib-y:= __ZLIB__ |
uselib:= $(SHARKOPT) |
# PCI |
libs-__PCI__-y:= -lpci |
cppflags-__PCI__-y:= -I$(topdir)/drivers/pci/include |
# Network |
libs-__NET__-y:= -lnet |
cppflags-__NET__-y:= -I$(topdir)/drivers/net/include |
# grx |
libs-__GRX__-y:= -lgrx |
cppflags-__GRX__-y:= -I$(topdir)/drivers/grx/include |
# Framebuffer |
libs-__FB__-y:= -lfb |
cppflags-__FB__-y:= -I$(topdir)/drivers/fb/include |
# Oldchar |
libs-__OLDCHAR__-y:= -loldch |
cppflags-__OLDCHAR__-y:= -I$(topdir)/drivers/oldchar/include |
# Linux compatibility layer |
libs-__LINUXC26__-y:= -lcomp26 |
# PCL833 |
libs-__PCL833__-y:= -lpcl833 |
cppflags-__PCL833__-y:= -I$(topdir)/drivers/pcl833/include |
# Parport |
libs-__PPORT__-y:= -lpport |
cppflags-__PPORT__-y:= -I$(topdir)/drivers/parport/include |
# PCLAB |
libs-__PCLAB__-y:= -lpclab |
cppflags-__PCLAB__-y:= -I$(topdir)/drivers/pcl812/include |
# BTTV |
libs-__BTTV__-y:= -lbttv |
cppflags-__BTTV__-y:= -I$(topdir)/drivers/bttv/include |
# Input |
libs-__INPUT__-y:= -linput |
cppflags-__INPUT__-y:= -I$(topdir)/drivers/input/include |
# CPU |
libs-__CPU__-y:= -lcpu |
cppflags-__CPU__-y:= -I$(topdir)/drivers/cpu/include |
# USB |
libs-__USB__-y:= -lusb |
cppflags-__USB__-y:= -I$(topdir)/drivers/usb/include |
# I2C |
libs-__I2C__-y:= -li2c |
cppflags-__I2C__-y:= -I$(topdir)/drivers/i2c/include |
# 6025e |
libs-__6025E__-y:= -l6025e |
cppflags-__6025E__-y:= -I$(topdir)/drivers/pci6025e/include |
# Mesa |
libs-__OSMESA__-y:= -losmesa -lglut -lglu |
cppflags-__OSMESA__-y:= -I$(topdir)/ports/mesa/include |
# Servo |
libs-__SERVO__-y:= -lservo |
cppflags-__SERVO__-y:= -I$(topdir)/ports/servo/include |
# TFTP |
libs-__TFTP__-y:= -ltftp |
cppflags-__TFTP__-y:= -I$(topdir)/ports/tftp/include |
libs-tracer-OLD:= -ltracer -lnet -lpci -lcomp26 |
libs-tracer-NEW:= $(libs-tracer-OLD) |
options= __PCI__ __NET__ __GRX__ __FB__ __OLDCHAR__ __LINUXC26__ __PCL833__\ |
__PPORT__ __PCLAB__ __BTTV__ __INPUT__ __CPU__ __USB__ __I2C__ \ |
__6025E__ __OSMESA__ __SERVO__ __TFTP__ |
app-libs+= $(foreach opt,$(options),$(libs-$(opt)-$(call wants-option,$(opt)))) |
app-cppflags+= $(foreach opt,$(options),$(cppflags-$(opt)-$(call\ |
wants-option,$(opt)))) |
app-libs+= $(libs-tracer-$(TRACER)) |
targets:= $(APP) |
$(APP)-objs:= $(APP).o $(OTHEROBJS) |
$(APP)-startup:= $(libs-dir)/x0.o |
$(APP)-cppflags+= $(OTHERINCL) $(app-cppflags) |
$(APP)-ldflags+= -Bstatic -Ttext $(MEM_START) -s -nostartfiles -nostdlib\ |
-L$(libs-dir) --start-group $(sort $(app-libs)) $(OTHERLIBS) --end-group |
endif |
/shark/trunk/config/config.mk |
---|
6,7 → 6,7 |
LD = ld |
AR = ar |
INCL = -I$(BASE)/include -I$(BASE)/modules |
INCL = -I$(BASE)/include -I$(BASE)/modules -I$(BASE)/libc/arch/$(ARCH)/include |
LIB_PATH = $(BASE)/lib |
OSLIB = $(BASE)/oslib |
OSLIB_PATH = $(OSLIB)/lib |
/shark/trunk/lib/makefile |
---|
File deleted |
/shark/trunk/lib/Makefile |
---|
0,0 → 1,15 |
# |
# |
# |
ifndef BASE |
BASE=../.. |
endif |
.PHONY: all install depend clean cleanall |
all install clean depend: |
cleanall: |
$(RM) lib*.a |
/shark/trunk/shark.cfg |
---|
7,6 → 7,11 |
# COMPILER = GCC3, GCC4, DJGPP |
COMPILER = GCC4 |
# Architecture selection |
# The architecture we're building the system for. The only supported |
# value (at the time being) is x86. |
ARCH = x86 |
# Kernel Image Start Point |
# MEM_START = 0x220000 |
# The kernel image file will be loaded starting from this |
32,7 → 37,7 |
# Select the events tracer |
# TRACER = NO,OLD,NEW |
TRACER = NO |
TRACER = NEW |
# Select the BIOS INTERRUPT access mode |
# BIOS = X,VM86 |
64,4 → 69,4 |
# Select the S.Ha.R.K. file system support |
# YES = build the FS library |
# NO = do not build the FS library |
SHARK_FS = NO |
SHARK_FS = YES |
/shark/trunk/mk/App.mk |
---|
0,0 → 1,69 |
# Copyright (c) 2008 Fabio Checconi <fabio@gandalf.sssup.it> |
# |
# Helper file defining standard targets for Shark applications. It should |
# be included from the application makefiles in this way (preserving much |
# of the old behavior): |
# |
# # Example of Shark application makefile. |
# S?=<source tree> |
# B?=<build tree, if different from $(S)> |
# |
# SUBDIRS:= <list of subdirectories> |
# APPS:= <list of applications> |
# |
# include $(S)/mk/App.mk |
# |
# # For each <application>: |
# <application>: |
# make -f $(S)/Makefile APP=<application> \ |
# OTHEROBJS="<list of objects>" \ |
# OTHERINCL="<list of extra include dirs>" \ |
# SHARKOPT="<list of options>" |
# |
# # End of Shark application makefile example. |
# |
ifndef S |
$(error Missing Shark source tree specification) |
endif |
define subdir-templ |
.PHONY: $(1)-$(2) |
$(1)-$(2): |
make -C $(1) $(2) |
endef |
define export-if-defined |
ifdef $(1) |
export $(1) |
endif |
endef |
to-be-exported:= S B O CROSS_COMPILE AR CC LD RM INSTALL V |
$(foreach v, $(to-be-exported),$(eval $(call export-if-defined,$(v)))) |
foreach-subdir=$(foreach d, $(SUBDIRS),$(eval $(call subdir-templ,$d,$1))) |
# The default target: build all subdirs and all the applications in the |
# current directory. |
.PHONY: all |
all: subdirs $(APPS) |
# Build subdirs before applications. |
$(APPS): subdirs |
.PHONY: subdirs |
# Build all the subdirs |
$(call foreach-subdir,all) |
subdirs: $(addsuffix -all,$(SUBDIRS)) |
.PHONY: clean |
$(call foreach-subdir,clean) |
clean: $(addsuffix -clean,$(SUBDIRS)) |
rm -f *.o $(APPS) |
.PHONY: distclean |
$(call foreach-subdir,distclean) |
distclean: clean $(addsuffix -distclean,$(SUBDIRS)) |
rm -f .*.deps |
/shark/trunk/ports/makefile |
---|
File deleted |
/shark/trunk/ports/snapshot/makefile |
---|
File deleted |
/shark/trunk/ports/snapshot/Makefile |
---|
0,0 → 1,20 |
# Snapshot Library |
ifndef BASE |
BASE=../.. |
endif |
include $(BASE)/config/config.mk |
LIBRARY = snapshot |
OBJS_PATH = $(BASE)/ports/snapshot |
SNAPSHOT = snapshot.o |
OBJS = $(SNAPSHOT) |
C_OPT += -I./include -I. -I.. -I../../drivers/fb/include |
include $(BASE)/config/lib.mk |
/shark/trunk/ports/zlib/makefile |
---|
File deleted |
/shark/trunk/ports/zlib/Makefile |
---|
0,0 → 1,22 |
# The Frame Buffer Device |
ifndef BASE |
BASE=../.. |
endif |
include $(BASE)/config/config.mk |
LIBRARY = zlib |
OBJS_PATH = $(BASE)/ports/zlib |
ZLIB = adler32.o compress.o crc32.o deflate.o gzio.o\ |
infblock.o infcodes.o inffast.o inflate.o inftrees.o\ |
infutil.o trees.o uncompr.o zutil.o |
OBJS = $(ZLIB) |
C_OPT += -I../../../drivers/linuxc26/include -I./include -I. -I.. |
include $(BASE)/config/lib.mk |
/shark/trunk/ports/mesa/makefile |
---|
File deleted |
/shark/trunk/ports/mesa/src-glut.dos/makefile |
---|
File deleted |
/shark/trunk/ports/mesa/src-glut.dos/Makefile |
---|
0,0 → 1,18 |
targets:= libglut.a |
libglut.a-objs:= \ |
bitmap.o \ |
color.o \ |
globals.o \ |
models.o \ |
teapot.o \ |
window.o \ |
callback.o \ |
init.o \ |
menu.o \ |
overlay.o \ |
state.o |
cppflags+= -I$(srctree)/drivers/linuxc26/include -I$(curdir)/../include \ |
-I$(curdir) -I$(curdir)/../ |
/shark/trunk/ports/mesa/src/makefile |
---|
File deleted |
/shark/trunk/ports/mesa/src/tnl/Makefile |
---|
0,0 → 1,24 |
targets:= \ |
t_array_api.o \ |
t_import_array.o \ |
t_context.o \ |
t_eval_api.o \ |
t_imm_alloc.o \ |
t_imm_api.o \ |
t_imm_debug.o \ |
t_imm_dlist.o \ |
t_imm_elt.o \ |
t_imm_eval.o \ |
t_imm_exec.o \ |
t_imm_fixup.o \ |
t_pipeline.o \ |
t_vb_fog.o \ |
t_vb_light.o \ |
t_vb_normals.o \ |
t_vb_points.o \ |
t_vb_program.o \ |
t_vb_render.o \ |
t_vb_gentex.o \ |
t_vb_texmat.o \ |
t_vb_vertex.o |
/shark/trunk/ports/mesa/src/math/Makefile |
---|
0,0 → 1,10 |
targets:= \ |
m_clip_debug.o \ |
m_norm_debug.o \ |
m_xform_debug.o \ |
m_eval.o \ |
m_matrix.o \ |
m_translate.o \ |
m_vector.o \ |
m_xform.o |
/shark/trunk/ports/mesa/src/swrast/Makefile |
---|
0,0 → 1,30 |
targets:= \ |
s_aaline.o \ |
s_aatriangle.o \ |
s_accum.o \ |
s_alphabuf.o \ |
s_alpha.o \ |
s_bitmap.o \ |
s_blend.o \ |
s_buffers.o \ |
s_context.o \ |
s_copypix.o \ |
s_depth.o \ |
s_drawpix.o \ |
s_feedback.o \ |
s_fog.o \ |
s_histogram.o \ |
s_imaging.o \ |
s_lines.o \ |
s_logic.o \ |
s_masking.o \ |
s_pixeltex.o \ |
s_points.o \ |
s_readpix.o \ |
s_span.o \ |
s_stencil.o \ |
s_texstore.o \ |
s_texture.o \ |
s_triangle.o \ |
s_zoom.o |
/shark/trunk/ports/mesa/src/array_cache/Makefile |
---|
0,0 → 1,2 |
targets:= ac_context.o ac_import.o |
/shark/trunk/ports/mesa/src/Makefile |
---|
0,0 → 1,71 |
targets:= libosmesa.a |
libosmesa.a-objs:= \ |
accum.o \ |
api_arrayelt.o \ |
api_eval.o \ |
api_loopback.o \ |
api_noop.o \ |
api_validate.o \ |
attrib.o \ |
blend.o \ |
buffers.o \ |
clip.o \ |
colortab.o \ |
context.o \ |
convolve.o \ |
debug.o \ |
depth.o \ |
dispatch.o \ |
dlist.o \ |
drawpix.o \ |
enable.o \ |
enums.o \ |
eval.o \ |
extensions.o \ |
feedback.o \ |
fog.o \ |
get.o \ |
glapi.o \ |
glthread.o \ |
hash.o \ |
hint.o \ |
histogram.o \ |
image.o \ |
light.o \ |
lines.o \ |
matrix.o \ |
mmath.o \ |
pixel.o \ |
points.o \ |
polygon.o \ |
rastpos.o \ |
state.o \ |
stencil.o \ |
texcompress.o \ |
texformat.o \ |
teximage.o \ |
texobj.o \ |
texstate.o \ |
texstore.o \ |
texutil.o \ |
varray.o \ |
vpexec.o \ |
vpparse.o \ |
vpstate.o \ |
vtxfmt.o \ |
array_cache/ \ |
swrast/ \ |
swrastst/ \ |
tnl/ \ |
math/ \ |
x86/ \ |
osmesa/ \ |
imports.o |
exported-aflags:= -I$(srctree)/drivers/linuxc26/include/asm \ |
-I$(srctree)/ports/mesa/include |
exported-cppflags:= -I$(srctree)/drivers/linuxc26/include \ |
-I$(srctree)/ports/mesa/include -I$(srctree)/ports/mesa/src |
/shark/trunk/ports/mesa/src/swrastst/Makefile |
---|
0,0 → 1,2 |
targets:= ss_context.o ss_triangle.o ss_vb.o |
/shark/trunk/ports/mesa/src/x86/Makefile |
---|
0,0 → 1,11 |
targets:= \ |
asm_common_x86.o \ |
common_x86.o \ |
glapi_x86.o \ |
mmx_blend.o \ |
x86.o \ |
x86_cliptest.o \ |
xform2_x86.o \ |
xform3_x86.o \ |
xform4_x86.o |
/shark/trunk/ports/mesa/src/osmesa/Makefile |
---|
0,0 → 1,2 |
targets:= osmesa.o |
/shark/trunk/ports/mesa/src-glu/makefile |
---|
File deleted |
/shark/trunk/ports/mesa/src-glu/Makefile |
---|
0,0 → 1,18 |
targets:= libglu.a |
libglu.a-objs:= \ |
glu.o \ |
mipmap.o \ |
nurbs.o \ |
nurbsutl.o \ |
project.o \ |
tess.o \ |
nurbscrv.o \ |
nurbssrf.o \ |
polytest.o \ |
quadric.o \ |
tesselat.o |
cppflags+= -I$(srctree)/drivers/linuxc26/include -I$(curdir)/../include \ |
-I$(curdir) -I$(curdir)/../ |
/shark/trunk/ports/mesa/Makefile |
---|
0,0 → 1,5 |
targets:= \ |
src/ \ |
src-glu/ \ |
src-glut.dos/ |
/shark/trunk/ports/fftw/makefile |
---|
File deleted |
/shark/trunk/ports/fftw/rfftw/makefile |
---|
File deleted |
/shark/trunk/ports/fftw/rfftw/Makefile |
---|
0,0 → 1,27 |
# The real FFTW library |
ifndef BASE |
BASE=../../.. |
endif |
include $(BASE)/config/config.mk |
LIBRARY = fftr |
OBJS_PATH = $(BASE)/ports/fftw/rfftw |
OTHERINCL += -I$(BASE)/ports/fftw/include |
OBJS = frc_1.o frc_2.o frc_3.o frc_4.o frc_5.o frc_6.o frc_7.o frc_8.o \ |
frc_9.o frc_10.o frc_11.o frc_12.o frc_13.o frc_14.o frc_15.o \ |
frc_16.o frc_32.o frc_64.o frc_128.o fhf_2.o fhf_3.o fhf_4.o \ |
fhf_5.o fhf_6.o fhf_7.o fhf_8.o fhf_9.o fhf_10.o fhf_16.o \ |
fhf_32.o fcr_1.o fcr_2.o fcr_3.o fcr_4.o fcr_5.o fcr_6.o \ |
fcr_7.o fcr_8.o fcr_9.o fcr_10.o fcr_11.o fcr_12.o fcr_13.o \ |
fcr_14.o fcr_15.o fcr_16.o fcr_32.o fcr_64.o fcr_128.o fhb_2.o \ |
fhb_3.o fhb_4.o fhb_5.o fhb_6.o fhb_7.o fhb_8.o fhb_9.o fhb_10.o \ |
fhb_16.o fhb_32.o rconfig.o rplanner.o rexec.o rexec2.o rfftwnd.o \ |
rgeneric.o |
# rfftwf77.o |
include $(BASE)/config/lib.mk |
/shark/trunk/ports/fftw/fftw/makefile |
---|
File deleted |
/shark/trunk/ports/fftw/fftw/Makefile |
---|
0,0 → 1,29 |
# The complex FFTW library |
ifndef BASE |
BASE=../../.. |
endif |
include $(BASE)/config/config.mk |
LIBRARY = fftc |
OBJS_PATH = $(BASE)/ports/fftw/fftw |
OTHERINCL += -I$(BASE)/ports/fftw/include |
OBJS = fn_1.o fn_2.o fn_3.o fn_4.o fn_5.o fn_6.o fn_7.o fn_8.o fn_9.o \ |
fn_10.o fn_11.o fn_12.o fn_13.o fn_14.o fn_15.o fn_16.o fn_32.o \ |
fn_64.o ftw_2.o ftw_3.o ftw_4.o ftw_5.o ftw_6.o ftw_7.o ftw_8.o \ |
ftw_9.o ftw_10.o ftw_16.o ftw_32.o ftw_64.o fni_1.o fni_2.o \ |
fni_3.o fni_4.o fni_5.o fni_6.o fni_7.o fni_8.o fni_9.o fni_10.o \ |
fni_11.o fni_12.o fni_13.o fni_14.o fni_15.o fni_16.o fni_32.o \ |
fni_64.o ftwi_2.o ftwi_3.o ftwi_4.o ftwi_5.o ftwi_6.o ftwi_7.o \ |
ftwi_8.o ftwi_9.o ftwi_10.o ftwi_16.o ftwi_32.o ftwi_64.o \ |
config.o planner.o twiddle.o executor.o generic.o fftwnd.o malloc.o \ |
rader.o putils.o \ |
wisdom.o wisdomio.o |
#fftwf77.o timer.o |
include $(BASE)/config/lib.mk |
/shark/trunk/ports/fftw/faq/makefile |
---|
File deleted |
/shark/trunk/ports/fftw/faq/Makefile |
---|
0,0 → 1,12 |
all: |
@echo converting 1 ... |
perl bfnnconv.pl fftw-faq.bfnn |
@echo converting 2 ... |
perl bfnnconv.pl fftw-faq.bfnn |
install-html: all |
cp fftw-faq.html/* $(HOME)/WWW/faq/ |
clean: |
rm -f *~ core a.out *.lout *.ps *.info *.ascii *.xrefdb *.post |
rm -rf *.html |
/shark/trunk/ports/fftw/Makefile |
---|
0,0 → 1,7 |
.PHONY: all install clean cleanall depend |
all install clean cleanall depend:: |
make -C rfftw $@ |
make -C fftw $@ |
/shark/trunk/ports/first/makefile |
---|
File deleted |
/shark/trunk/ports/first/fsf_include/tests/makefile |
---|
File deleted |
/shark/trunk/ports/first/fsf_include/tests/shark_glue/makefile |
---|
File deleted |
/shark/trunk/ports/first/fsf_include/tests/shark_glue/Makefile |
---|
0,0 → 1,20 |
# |
# util_linux -> compiles the tracer utilities under Linux |
# |
ifndef BASE |
BASE=../../.. |
endif |
.PHONY: util_dos util_linux clean |
all: udpdump |
udpdump: udpdump.c |
gcc -Wimplicit-function-declaration -Wall -ggdb\ |
-I$(BASE)/tracer/include -I$(BASE)/oslib udpdump.c -o udpdump |
clean: |
rm -rf *.o udpdump |
/shark/trunk/ports/first/fsf_include/tests/fsf_negotiation_test/makefile |
---|
File deleted |
/shark/trunk/ports/first/fsf_include/tests/fsf_negotiation_test/Makefile |
---|
0,0 → 1,29 |
# |
# |
ifeq ($(OS), S) |
BASE=../../../../.. |
OSNAME = shark_glue |
export BASE |
include $(BASE)/config/config.mk |
endif |
PROGS= $(OS)_$(WL)_negotiation_test |
ifeq ($(OS), S) |
include $(BASE)/config/example.mk |
endif |
$(OS)_$(WL)_negotiation_test: |
make -f $(SUBMAKE) APPNAME=$(PROGS) APP=fsf_negotiation_test INIT= OTHEROBJS="../$(OSNAME)/initfile.o ../$(OSNAME)/shark.o ../$(OSNAME)/net_print.o" OTHERINCL="-I../common" SHARKOPT="__INPUT__ __FIRST__ __NEW_TRACER__ __LINUXC26__ __PCI__ __NET__ __GRX__" |
ifeq ($(OS), M) |
HERE=$(shell /bin/pwd) |
export HERE |
$(PROGS): |
cd /home/marte/fsf ; make $(PROGS) |
endif |
/shark/trunk/ports/first/fsf_include/tests/synch_obj_test/makefile |
---|
File deleted |
/shark/trunk/ports/first/fsf_include/tests/synch_obj_test/Makefile |
---|
0,0 → 1,19 |
# |
# |
ifeq ($(OS), S) |
BASE=../../../../.. |
OSNAME = shark_glue |
export BASE |
include $(BASE)/config/config.mk |
endif |
PROGS= $(OS)_$(WL)_synch_test |
ifeq ($(OS), S) |
include $(BASE)/config/example.mk |
endif |
$(OS)_$(WL)_synch_test: |
make -f $(SUBMAKE) APPNAME=$(PROGS) APP=fsf_synch_obj_test INIT= OTHEROBJS="../$(OSNAME)/initfile.o ../$(OSNAME)/shark.o ../$(OSNAME)/net_print.o" OTHERINCL="-I../common" SHARKOPT="__INPUT__ __FIRST__ __NEW_TRACER__ __LINUXC26__ __PCI__ __NET__ __GRX__" |
/shark/trunk/ports/first/fsf_include/tests/Makefile |
---|
0,0 → 1,44 |
ifndef OS |
OS=S |
endif |
ifndef WL |
WL=0 |
endif |
ifeq ($(OS), S) |
include ../../../../shark.cfg |
endif |
ifeq ($(OS), M) |
endif |
export OS |
export WL |
ifeq ($(findstring NEW,$(TRACER)) , NEW) |
TRC = newtrace |
endif |
dirs := $(filter-out CVS cvs tefses shark_glue marte_glue common tabledriven makefile readme.txt newtrace README.TXT, $(wildcard *)) |
dirs += $(TRC) |
p_all := $(addprefix prefixall_, $(dirs)) |
p_install := $(addprefix prefixinstall_, $(dirs)) |
p_clean := $(addprefix prefixclean_, $(dirs)) |
pcleanall := $(addprefix prefixcleanall_, $(dirs)) |
pdepend := $(addprefix prefixdepend_, $(dirs)) |
.PHONY: all clean |
all: $(p_all) |
clean: $(p_clean) |
prefixall_%: |
make -C $* |
prefixclean_%: |
make -C $* clean |
/shark/trunk/ports/first/fsf_include/tests/fsf_jitter_test/makefile |
---|
File deleted |
/shark/trunk/ports/first/fsf_include/tests/fsf_jitter_test/Makefile |
---|
0,0 → 1,19 |
# |
# |
ifeq ($(OS), S) |
BASE=../../../../.. |
OSNAME = shark_glue |
export BASE |
include $(BASE)/config/config.mk |
endif |
PROGS= $(OS)_$(WL)_jitter_test |
ifeq ($(OS), S) |
include $(BASE)/config/example.mk |
endif |
$(OS)_$(WL)_jitter_test: |
make -f $(SUBMAKE) APPNAME=$(PROGS) APP=jitter_test INIT= OTHEROBJS="../$(OSNAME)/initfile.o ../$(OSNAME)/shark.o ../$(OSNAME)/net_print.o" OTHERINCL="-I../common" SHARKOPT="__INPUT__ __FIRST__ __NEW_TRACER__ __LINUXC26__ __PCI__ __NET__ __GRX__" |
/shark/trunk/ports/first/first-contract.c |
---|
34,7 → 34,7 |
#include <kernel/descr.h> |
#include <kernel/func.h> |
#include <pistar.h> |
#include <ll/i386/string.h> |
#include <arch/i386/string.h> |
#define MAX_SHARED_NAME 15 |
/shark/trunk/ports/first/include/pistar.h |
---|
90,7 → 90,7 |
#define __PISTAR_H__ |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/ports/first/modules/fedfstar.c |
---|
37,8 → 37,8 |
#include "ll/i386/64bit.h" |
#include "fedfstar.h" |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/ports/first/modules/tdstar.c |
---|
36,8 → 36,8 |
*/ |
#include "fsf.h" |
#include "tdstar.h" |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/ports/first/modules/mpegstar.c |
---|
36,8 → 36,8 |
*/ |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/ports/first/modules/pistar.c |
---|
54,8 → 54,8 |
#include <ll/ll.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <kernel/descr.h> |
/shark/trunk/ports/first/modules/edfstar.c |
---|
36,8 → 36,8 |
*/ |
#include "edfstar.h" |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/ports/first/modules/rmstar.c |
---|
36,8 → 36,8 |
*/ |
#include "rmstar.h" |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/ports/first/modules/nonestar.c |
---|
36,8 → 36,8 |
*/ |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/ports/first/modules/posixstar.c |
---|
36,8 → 36,8 |
*/ |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/ports/first/Makefile |
---|
0,0 → 1,21 |
# The Frame Buffer Device |
ifndef BASE |
BASE=../.. |
endif |
include $(BASE)/config/config.mk |
LIBRARY = first |
OBJS_PATH = $(BASE)/ports/first |
FIRST = first-contract.o first-server.o first-sync.o server-task.o first-error.o \ |
./modules/grubstar.o ./modules/posixstar.o ./modules/fedfstar.o ./modules/cbsnhstar.o \ |
./modules/edfstar.o ./modules/cbsstar.o ./modules/rmstar.o \ |
./modules/nonestar.o ./modules/pistar.o ./modules/tdstar.o |
OBJS = $(FIRST) |
C_OPT += -I./fsf_include -I./include -I. -I.. |
include $(BASE)/config/lib.mk |
/shark/trunk/ports/dynalink/makefile |
---|
File deleted |
/shark/trunk/ports/dynalink/elf.c |
---|
22,7 → 22,7 |
#include <ll/i386/cons.h> |
#include <ll/i386/error.h> |
#include <ll/i386/mem.h> |
#include <ll/ctype.h> |
#include <arch/ctype.h> |
#include <ll/i386/x-bios.h> |
#include "format.h" |
/shark/trunk/ports/dynalink/dynalink.c |
---|
23,7 → 23,7 |
#include <ll/i386/cons.h> |
#include <ll/i386/error.h> |
#include <ll/i386/mem.h> |
#include <ll/ctype.h> |
#include <arch/ctype.h> |
#include <ll/i386/x-bios.h> |
#include "format.h" |
/shark/trunk/ports/dynalink/Makefile |
---|
0,0 → 1,29 |
# Dynalink |
ifndef BASE |
BASE=../.. |
endif |
include $(BASE)/config/config.mk |
LIBRARY = dynalink |
OBJS_PATH = $(BASE)/dynalink |
OBJS = dynalink.o elf.o |
OTHERINCL += -I$(BASE)/drivers/linuxc26/include -I./include -I. |
OTHERINCL += -I$(BASE)/drivers/pci/include |
OTHERINCL += -I$(BASE)/drivers/input/include |
C_OPT += -D__KERNEL__ -D__i386__ $(CFG_VIDEO_OPT) |
include $(BASE)/config/lib.mk |
clean:: |
rm -f $(OBJS) |
rm -f deps |
/shark/trunk/ports/tftp/makefile |
---|
File deleted |
/shark/trunk/ports/tftp/Makefile |
---|
0,0 → 1,6 |
targets:= libtftp.a |
libtftp.a-objs:= tftp.o endn.o |
cppflags+= -I$(srctree)/ports/tftp/include -I$(srctree)/drivers/net/include/ |
/shark/trunk/ports/Makefile |
---|
0,0 → 1,2 |
targets:= mesa/ servo/ tftp/ |
/shark/trunk/ports/didma/makefile |
---|
File deleted |
/shark/trunk/ports/didma/Makefile |
---|
0,0 → 1,18 |
# The DIDMA library |
ifndef BASE |
BASE=../.. |
endif |
include $(BASE)/config/config.mk |
LIBRARY = didma |
OBJS_PATH = $(BASE)/ports/didma |
# Object files |
OTHERINCL=-I ./include |
OBJS = didma.o |
include $(BASE)/config/lib.mk |
/shark/trunk/ports/servo/makefile |
---|
File deleted |
/shark/trunk/ports/servo/Makefile |
---|
0,0 → 1,6 |
targets:= libservo.a |
libservo.a-objs:= servo.o |
cppflags+= -I$(curdir)/include -I$(curdir) -I$(srctree)/drivers/serial/include |
/shark/trunk/fs/makefile |
---|
File deleted |
/shark/trunk/fs/rtcfunc.h |
---|
57,7 → 57,7 |
#include <time.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/fs/Makefile |
---|
0,0 → 1,37 |
targets:= libfs.a |
libfs.a-objs:= \ |
access.o \ |
chdir.o \ |
close.o \ |
closedir.o \ |
dcache.o \ |
dentry.o \ |
fcntl.o \ |
fdevice.o \ |
file.o \ |
fs.o \ |
fstat.o \ |
getcwd.o \ |
getumask.o \ |
inode.o \ |
lseek.o \ |
mount.o \ |
open.o \ |
opendir.o \ |
read.o \ |
readdir.o \ |
rwlock.o \ |
rtc.o \ |
stat.o \ |
super.o \ |
truncate.o \ |
umask.o \ |
umount.o \ |
unlink.o \ |
utime.o \ |
write.o |
exported-cppflags:= -D_PARANOIA -DNDEBUG -I$(curdir) \ |
-imacros $(srctree)/include/fs/fsconf.h |
/shark/trunk/fs/msdos/makefile |
---|
File deleted |
/shark/trunk/fs/msdos/Makefile |
---|
0,0 → 1,26 |
# |
# The MSDOS (FAT16) sub-library |
# |
ifndef BASE |
BASE=../.. |
endif |
include $(BASE)/config/config.mk |
LIBRARY = fs |
OBJS_PATH = $(BASE)/fs/msdos |
OBJS= msdos_i.o \ |
msdos_f.o \ |
msdos_s.o \ |
msdos_d.o |
#C_DEF += -D_PARANOIA |
C_DEF += -D_PARANOIA -DNDEBUG |
C_MAC += -imacros $(BASE)/include/fs/fsconf.h |
C_INC += -I.. |
include $(BASE)/config/sublib.mk |
/shark/trunk/modules/makefile |
---|
File deleted |
/shark/trunk/modules/rrsoft/subdir.mk |
---|
File deleted |
/shark/trunk/modules/rrsoft/rrsoft/rrsoft.h |
---|
103,7 → 103,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/rrsoft/rrsoft.c |
---|
54,8 → 54,8 |
#include <rrsoft/rrsoft/rrsoft.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/rrsoft/Makefile |
---|
0,0 → 1,0 |
targets:= rrsoft.o |
/shark/trunk/modules/ps/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/ps/ps/ps.h |
---|
93,7 → 93,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/ps/ps.c |
---|
97,8 → 97,8 |
#include <ps/ps/ps.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/ps/Makefile |
---|
0,0 → 1,0 |
targets:= ps.o |
/shark/trunk/modules/rr/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/rr/rr/rr.h |
---|
95,7 → 95,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/rr/rr.c |
---|
54,8 → 54,8 |
#include <rr/rr/rr.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/rr/Makefile |
---|
0,0 → 1,0 |
targets:= rr.o |
/shark/trunk/modules/sem/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/sem/sem/sem.h |
---|
73,7 → 73,7 |
#define __MODULES_SEM_H__ |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/sem/sem.c |
---|
63,7 → 63,7 |
#include <sem/sem/sem.h> |
#include <kernel/config.h> |
#include <ll/ll.h> |
#include <ll/string.h> |
#include <arch/string.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <kernel/descr.h> |
/shark/trunk/modules/sem/Makefile |
---|
0,0 → 1,0 |
targets:= sem.o |
/shark/trunk/modules/elastic/subdir.mk |
---|
File deleted |
/shark/trunk/modules/elastic/Makefile |
---|
0,0 → 1,0 |
targets:= elastic.o |
/shark/trunk/modules/intdrive/subdir.mk |
---|
File deleted |
/shark/trunk/modules/intdrive/intdrive/intdrive.h |
---|
43,7 → 43,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/intdrive/Makefile |
---|
0,0 → 1,0 |
targets:= intdrive.o inttask.o |
/shark/trunk/modules/ss/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/ss/ss/ss.h |
---|
103,7 → 103,7 |
#include <kernel/config.h> |
#include <kernel/types.h> |
#include <sys/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/ss/ss/ssutils.h |
---|
62,7 → 62,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/ss/ss.c |
---|
114,8 → 114,8 |
#include <stdlib.h> |
#include <ss/ss/ss.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <ll/sys/ll/event.h> |
/shark/trunk/modules/ss/Makefile |
---|
0,0 → 1,0 |
targets:= ss.o |
/shark/trunk/modules/tbs/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/tbs/tbs/tbs.h |
---|
126,7 → 126,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/tbs/tbs.c |
---|
54,8 → 54,8 |
#include <tbs/tbs/tbs.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/tbs/Makefile |
---|
0,0 → 1,0 |
targets:= tbs.o |
/shark/trunk/modules/dummy/subdir.mk |
---|
File deleted |
/shark/trunk/modules/dummy/dummy/dummy.h |
---|
79,7 → 79,7 |
#define __DUMMY_H__ |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/dummy/dummy.c |
---|
54,8 → 54,8 |
#include <dummy/dummy/dummy.h> |
#include <ll/ll.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/model.h> |
/shark/trunk/modules/dummy/Makefile |
---|
0,0 → 1,0 |
targets:= dummy.o |
/shark/trunk/modules/nop/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/nop/nop/nop.h |
---|
80,7 → 80,7 |
#define __NOP_H__ |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/nop/nop.c |
---|
54,8 → 54,8 |
#include <nop/nop/nop.h> |
#include <ll/ll.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <kernel/descr.h> |
/shark/trunk/modules/nop/Makefile |
---|
0,0 → 1,0 |
targets:= nop.o |
/shark/trunk/modules/npp/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/npp/npp/npp.h |
---|
88,7 → 88,7 |
#ifndef __NPP_H__ |
#define __NPP_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/npp/Makefile |
---|
0,0 → 1,0 |
targets:= npp.o |
/shark/trunk/modules/npp/npp.c |
---|
54,8 → 54,8 |
#include <npp/npp/npp.h> |
#include <ll/ll.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <kernel/descr.h> |
/shark/trunk/modules/edf/subdir.mk |
---|
File deleted |
/shark/trunk/modules/edf/edf.c |
---|
55,8 → 55,8 |
#include <edf/edf/edf.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/edf/Makefile |
---|
0,0 → 1,0 |
targets:= edf.o |
/shark/trunk/modules/edf/edf/edf.h |
---|
144,7 → 144,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/posix/subdir.mk |
---|
File deleted |
/shark/trunk/modules/posix/posix/posix.h |
---|
96,7 → 96,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/posix/posix.c |
---|
57,8 → 57,8 |
#include <posix/posix/posix.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/posix/Makefile |
---|
0,0 → 1,0 |
targets:= posix.o |
/shark/trunk/modules/pc/subdir.mk |
---|
File deleted |
/shark/trunk/modules/pc/pc/pc.h |
---|
92,7 → 92,7 |
#include <kernel/types.h> |
#include <kernel/descr.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/pc/pc.c |
---|
54,8 → 54,8 |
#include <pc/pc/pc.h> |
#include <ll/ll.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <kernel/var.h> |
/shark/trunk/modules/pc/Makefile |
---|
0,0 → 1,0 |
targets:= pc.o |
/shark/trunk/modules/bd_edf/subdir.mk |
---|
File deleted |
/shark/trunk/modules/bd_edf/bd_edf/bd_edf.h |
---|
50,7 → 50,7 |
#include <kernel/types.h> |
#include <kernel/descr.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/bd_edf/bd_edf.c |
---|
48,8 → 48,8 |
#include <bd_edf/bd_edf/bd_edf.h> |
#include <ll/ll.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <kernel/var.h> |
/shark/trunk/modules/bd_edf/Makefile |
---|
0,0 → 1,0 |
targets:= bd_edf.o |
/shark/trunk/modules/hartport/subdir.mk |
---|
File deleted |
/shark/trunk/modules/hartport/hartport/hartport.h |
---|
77,7 → 77,7 |
#include <sem/sem/sem.h> |
#include <ll/ll.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/hartport/hartport.c |
---|
60,8 → 60,8 |
#include <hartport/hartport/hartport.h> |
#include <kernel/config.h> |
#include <ll/ll.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
/shark/trunk/modules/hartport/Makefile |
---|
0,0 → 1,0 |
targets:= hartport.o |
/shark/trunk/modules/srp/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/srp/srp/srp.h |
---|
107,7 → 107,7 |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/srp/srp.c |
---|
138,8 → 138,8 |
#include <srp/srp/srp.h> |
#include <ll/ll.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <kernel/descr.h> |
/shark/trunk/modules/srp/Makefile |
---|
0,0 → 1,0 |
targets:= srp.o |
/shark/trunk/modules/rr2/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/rr2/rr2/rr2.h |
---|
94,7 → 94,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/rr2/rr2.c |
---|
54,8 → 54,8 |
#include <rr2/rr2/rr2.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/rr2/Makefile |
---|
0,0 → 1,0 |
targets:= rr2.o |
/shark/trunk/modules/hardcbs/subdir.mk |
---|
File deleted |
/shark/trunk/modules/hardcbs/hardcbs/hardcbs.h |
---|
96,7 → 96,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/hardcbs/hardcbs.c |
---|
39,8 → 39,8 |
*/ |
#include <hardcbs/hardcbs/hardcbs.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/hardcbs/Makefile |
---|
0,0 → 1,0 |
targets:= hardcbs.o |
/shark/trunk/modules/ds/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/ds/ds/ds.h |
---|
92,7 → 92,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/ds/ds.c |
---|
58,8 → 58,8 |
#include <ds/ds/ds.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/ds/Makefile |
---|
0,0 → 1,0 |
targets:= ds.o |
/shark/trunk/modules/cbs/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/cbs/cbs/cbs.h |
---|
103,7 → 103,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/cbs/cbs.c |
---|
54,8 → 54,8 |
#include <cbs/cbs/cbs.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/cbs/Makefile |
---|
0,0 → 1,0 |
targets:= cbs.o |
/shark/trunk/modules/cabs/subdir.mk |
---|
File deleted |
/shark/trunk/modules/cabs/cabs/cabs.h |
---|
66,7 → 66,7 |
#define __CAB_H__ |
#include <ll/sys/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/cabs/cabs.c |
---|
59,7 → 59,7 |
#include <kernel/config.h> |
#include <ll/ll.h> |
#include <ll/string.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
/shark/trunk/modules/cabs/Makefile |
---|
0,0 → 1,0 |
targets:= cabs.o |
/shark/trunk/modules/pi/subdir.mk |
---|
File deleted |
/shark/trunk/modules/pi/pi/pi.h |
---|
90,7 → 90,7 |
#define __PI_H__ |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/pi/pi.c |
---|
54,8 → 54,8 |
#include <pi/pi/pi.h> |
#include <ll/ll.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <kernel/descr.h> |
/shark/trunk/modules/pi/Makefile |
---|
0,0 → 1,0 |
targets:= pi.o |
/shark/trunk/modules/nopm/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/nopm/nopm/nopm.h |
---|
59,7 → 59,7 |
#define __NOPM_H__ |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/nopm/nopm.c |
---|
54,8 → 54,8 |
#include <nopm/nopm/nopm.h> |
#include <ll/ll.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <kernel/descr.h> |
/shark/trunk/modules/nopm/Makefile |
---|
0,0 → 1,0 |
targets:= nopm.o |
/shark/trunk/modules/bd_pscan/subdir.mk |
---|
File deleted |
/shark/trunk/modules/bd_pscan/bd_pscan/bd_pscan.h |
---|
51,7 → 51,7 |
#include <kernel/types.h> |
#include <kernel/descr.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/modules/bd_pscan/bd_pscan.c |
---|
48,8 → 48,8 |
#include <bd_pscan/bd_pscan/bd_pscan.h> |
#include <ll/ll.h> |
#include <ll/string.h> |
#include <ll/stdio.h> |
#include <arch/string.h> |
#include <arch/stdio.h> |
#include <kernel/const.h> |
#include <sys/types.h> |
#include <kernel/var.h> |
/shark/trunk/modules/bd_pscan/Makefile |
---|
0,0 → 1,0 |
targets:= bd_pscan.o |
/shark/trunk/modules/Makefile |
---|
0,0 → 1,27 |
targets:= \ |
bd_edf/ \ |
bd_pscan/ \ |
cabs/ \ |
cbs/ \ |
ds/ \ |
dummy/ \ |
edf/ \ |
elastic/ \ |
hardcbs/ \ |
hartport/ \ |
intdrive/ \ |
nop/ \ |
nopm/ \ |
npp/ \ |
pc/ \ |
pi/ \ |
posix/ \ |
ps/ \ |
rm/ \ |
rr/ \ |
rr2/ \ |
rrsoft/ \ |
sem/ \ |
srp/ \ |
ss/ \ |
tbs/ |
/shark/trunk/modules/rm/subdir.mk |
---|
File deleted |
\ No newline at end of file |
/shark/trunk/modules/rm/rm.c |
---|
54,8 → 54,8 |
#include <rm/rm/rm.h> |
#include <ll/stdio.h> |
#include <ll/string.h> |
#include <arch/stdio.h> |
#include <arch/string.h> |
#include <kernel/model.h> |
#include <kernel/descr.h> |
#include <kernel/var.h> |
/shark/trunk/modules/rm/Makefile |
---|
0,0 → 1,0 |
targets:= rm.o |
/shark/trunk/modules/rm/rm/rm.h |
---|
144,7 → 144,7 |
#include <kernel/config.h> |
#include <sys/types.h> |
#include <kernel/types.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/libc/makefile |
---|
File deleted |
/shark/trunk/libc/assert/makefile |
---|
File deleted |
/shark/trunk/libc/assert/Makefile |
---|
0,0 → 1,2 |
targets:= assert.o |
/shark/trunk/libc/stdlib/makefile |
---|
File deleted |
/shark/trunk/libc/stdlib/Makefile |
---|
0,0 → 1,13 |
targets:= \ |
abort.o \ |
atexit.o \ |
calloc.o \ |
free.o \ |
malloc.o \ |
realloc.o \ |
strtod.o \ |
strtol.o \ |
strtoul.o \ |
qsort.o \ |
bsearch.o |
/shark/trunk/libc/getopt/makefile |
---|
File deleted |
/shark/trunk/libc/getopt/Makefile |
---|
0,0 → 1,2 |
targets:= getopt.o getopt1.o |
/shark/trunk/libc/stdio/makefile |
---|
File deleted |
/shark/trunk/libc/stdio/Makefile |
---|
0,0 → 1,63 |
targets:= \ |
asprintf.o \ |
clrerr.o \ |
fclose.o \ |
fdopen.o \ |
feof.o \ |
ferror.o \ |
fflush.o \ |
fgetc.o \ |
fgetln.o \ |
fgetpos.o \ |
fgets.o \ |
fileno.o \ |
findfp.o \ |
flags.o \ |
fopen.o \ |
fprintf.o \ |
fpurge.o \ |
fputc.o \ |
fputs.o \ |
fread.o \ |
freopen.o \ |
fscanf.o \ |
fseek.o \ |
fsetpos.o \ |
ftell.o \ |
funopen.o \ |
fvwrite.o \ |
fwalk.o \ |
fwrite.o \ |
getc.o \ |
getchar.o \ |
gets.o \ |
getw.o \ |
makebuf.o \ |
mktemp.o \ |
printf.o \ |
putc.o \ |
putchar.o \ |
puts.o \ |
putw.o \ |
refill.o \ |
remove.o \ |
rewind.o \ |
rget.o \ |
scanf.o \ |
setbuf.o \ |
setbuffe.o \ |
setvbuf.o \ |
snprintf.o \ |
stdio.o \ |
tempnam.o \ |
tmpnam.o \ |
ungetc.o \ |
vasprint.o \ |
vfprintf.o \ |
vfscanf.o \ |
vprintf.o \ |
vscanf.o \ |
vsnprint.o \ |
wbuf.o \ |
wsetup.o |
/shark/trunk/libc/stdio/vfprintf.c |
---|
35,7 → 35,7 |
*/ |
/* MODIFIED: |
* --added include <ll/math.h> |
* --added include <arch/math.h> |
* --initialization to prevent warnings |
*/ |
82,18 → 82,18 |
# undef _ANSI_SOURCE |
# if defined(_POSIX_SOURCE) |
# undef _POSIX_SOURCE |
# include <ll/math.h> |
# include <arch/math.h> |
# define _POSIX_SOURCE |
# else |
# include <ll/math.h> |
# include <arch/math.h> |
# endif |
# define _ANSI_SOURCE |
# elif defined(_POSIX_SOURCE) |
# undef _POSIX_SOURCE |
# include <ll/math.h> |
# include <arch/math.h> |
# define _POSIX_SOURCE |
# else |
# include <ll/math.h> |
# include <arch/math.h> |
# endif |
#endif |
/shark/trunk/libc/ctype/makefile |
---|
File deleted |
/shark/trunk/libc/ctype/Makefile |
---|
0,0 → 1,2 |
targets:= ctype.o |
/shark/trunk/libc/string/makefile |
---|
File deleted |
/shark/trunk/libc/string/strcasecmp.c |
---|
50,8 → 50,8 |
#include <ll/i386/string.h> |
#include <ll/ctype.h> |
#include <arch/i386/string.h> |
#include <arch/ctype.h> |
int strcasecmp(const char *s1, const char *s2) |
{ |
/shark/trunk/libc/string/Makefile |
---|
0,0 → 1,2 |
targets:= strcasecmp.o |
/shark/trunk/libc/unistd/makefile |
---|
File deleted |
/shark/trunk/libc/unistd/Makefile |
---|
0,0 → 1,5 |
targets:= \ |
fpathcon.o \ |
pathconf.o \ |
sysconf.o |
/shark/trunk/libc/quad/makefile |
---|
File deleted |
/shark/trunk/libc/quad/Makefile |
---|
0,0 → 1,28 |
targets:= \ |
adddi3.o \ |
anddi3.o \ |
ashldi3.o \ |
ashrdi3.o \ |
cmpdi2.o \ |
divdi3.o \ |
fixdfdi.o \ |
fixsfdi.o \ |
fixunsdf.o \ |
fixunssf.o \ |
floatdid.o \ |
floatdis.o \ |
floatuns.o \ |
iordi3.o \ |
lshldi3.o \ |
lshrdi3.o \ |
moddi3.o \ |
muldi3.o \ |
negdi2.o \ |
notdi2.o \ |
qdivrem.o \ |
subdi3.o \ |
ucmpdi2.o \ |
udivdi3.o \ |
umoddi3.o \ |
xordi3.o |
/shark/trunk/libc/quad/old/makefile |
---|
File deleted |
/shark/trunk/libc/quad/old/Makefile |
---|
0,0 → 1,62 |
# |
# GNU-C 32 bit makefile |
# |
HARTIK=$(BASE) |
include $(HARTIK)/config/config.mak |
# to remove |
CP=cp |
RM=rm -f |
C_DEF += -D_THREAD_SAFE |
#C_INC += -I. |
# |
# Device driver files |
# |
C_SRCS= anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c fixdfdi.c \ |
fixsfdi.c fixunsdf.c fixunssf.c floatdid.c floatdis.c \ |
floatuns.c iordi3.c lshldi3.c lshrdi3.c moddi3.c \ |
muldi3.c negdi2.c notdi2.c subdi3.c adddi3.c qdivrem.c \ |
ucmpdi2.c udivdi3.c umoddi3.c xordi3.c |
S_SRCS= |
SRCS= $(C_SRCS) $(S_SRCS) |
# |
LIBNAME= c |
# |
# Finally the dependency rules! |
# |
.PHONY : all install depend clean allclean |
# |
all install: ../lib$(LIBNAME).a |
depend deps: |
$(CC) $(C_OPT) -M $(C_SRCS) >deps |
clean : |
-del *.o |
-del *.err |
-del *.a |
allclean : clean |
# |
# |
# |
include deps |
../lib$(LIBNAME).a : $(SRCS:.c=.o) |
ar rs ../lib$(LIBNAME).a $(SRCS:.c=.o) |
/shark/trunk/libc/utsname/makefile |
---|
File deleted |
/shark/trunk/libc/utsname/Makefile |
---|
0,0 → 1,2 |
targets:= utsname.o |
/shark/trunk/libc/Makefile |
---|
0,0 → 1,16 |
targets:= libc.a |
libc.a-objs:= \ |
init.o \ |
libio/ \ |
quad/ \ |
stdio/ \ |
stdlib/ \ |
assert/ \ |
unistd/ \ |
utsname/ \ |
ctype/ \ |
string/ \ |
getopt/ \ |
arch/$(ARCH)/ |
/shark/trunk/libc/arch/x86/libm/msun/i387/Makefile |
---|
0,0 → 1,26 |
targets:= \ |
e_acos.o \ |
e_asin.o \ |
e_atan2.o \ |
e_exp.o \ |
e_fmod.o \ |
e_log.o \ |
e_log10.o \ |
e_remain.o \ |
e_scalb.o \ |
e_sqrt.o \ |
s_atan.o \ |
s_ceil.o \ |
s_copysi.o \ |
s_cos.o \ |
s_finite.o \ |
s_floor.o \ |
s_ilogb.o \ |
s_log1p.o \ |
s_logb.o \ |
s_rint.o \ |
s_scalbn.o \ |
s_signif.o \ |
s_sin.o \ |
s_tan.o |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_ilogb.s |
---|
0,0 → 1,53 |
/* |
* Copyright (c) 1994 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_ilogb.S,v 1.2.6.1 1996/02/25 20:34:46 bde Exp $") |
ENTRY(ilogb) |
pushl %ebp |
movl %esp,%ebp |
subl $4,%esp |
fldl 8(%ebp) |
fxtract |
fstpl %st |
fistpl -4(%ebp) |
movl -4(%ebp),%eax |
leave |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/e_remain.s |
---|
0,0 → 1,48 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: e_remainder.S,v 1.2 1994/08/19 11:14:18 jkh Exp $") |
ENTRY(__ieee754_remainder) |
fldl 12(%esp) |
fldl 4(%esp) |
1: fprem1 |
fstsw %ax |
sahf |
jp 1b |
fstpl %st(1) |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_scalbn.s |
---|
0,0 → 1,45 |
/* |
* Copyright (c) 1994 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_scalbn.S,v 1.2.6.1 1996/12/15 15:15:45 bde Exp $") |
ENTRY(scalbn) |
fildl 12(%esp) |
fldl 4(%esp) |
fscale |
fstp %st(1) |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/e_log.s |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: e_log.S,v 1.2 1994/08/19 11:14:15 jkh Exp $") |
ENTRY(__ieee754_log) |
fldln2 |
fldl 4(%esp) |
fyl2x |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/e_log10.s |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: e_log10.S,v 1.2 1994/08/19 11:14:16 jkh Exp $") |
ENTRY(__ieee754_log10) |
fldlg2 |
fldl 4(%esp) |
fyl2x |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_copysi.s |
---|
0,0 → 1,48 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_copysign.S,v 1.2 1994/08/19 11:14:22 jkh Exp $") |
ENTRY(copysign) |
movl 16(%esp),%edx |
andl $0x80000000,%edx |
movl 8(%esp),%eax |
andl $0x7fffffff,%eax |
orl %edx,%eax |
movl %eax,8(%esp) |
fldl 4(%esp) |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/e_scalb.s |
---|
0,0 → 1,45 |
/* |
* Copyright (c) 1994 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: e_scalb.S,v 1.2.6.1 1996/12/15 15:15:43 bde Exp $") |
ENTRY(__ieee754_scalb) |
fldl 12(%esp) |
fldl 4(%esp) |
fscale |
fstp %st(1) |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/e_acos.s |
---|
0,0 → 1,50 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: e_acos.S,v 1.2 1994/08/19 11:12:52 jkh Exp $") |
/* acos = atan (sqrt(1 - x^2) / x) */ |
ENTRY(__ieee754_acos) |
fldl 4(%esp) /* x */ |
fst %st(1) |
fmul %st(0) /* x^2 */ |
fld1 |
fsubp /* 1 - x^2 */ |
fsqrt /* sqrt (1 - x^2) */ |
fxch %st(1) |
fpatan |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/e_fmod.s |
---|
0,0 → 1,48 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: e_fmod.S,v 1.2 1994/08/19 11:14:15 jkh Exp $") |
ENTRY(__ieee754_fmod) |
fldl 12(%esp) |
fldl 4(%esp) |
1: fprem |
fstsw %ax |
sahf |
jp 1b |
fstpl %st(1) |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/e_sqrt.s |
---|
0,0 → 1,43 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: e_sqrt.S,v 1.2 1994/08/19 11:14:20 jkh Exp $") |
ENTRY(__ieee754_sqrt) |
fldl 4(%esp) |
fsqrt |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_ceil.s |
---|
0,0 → 1,58 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_ceil.S,v 1.2.6.1 1996/12/15 15:23:16 bde Exp $") |
ENTRY(ceil) |
pushl %ebp |
movl %esp,%ebp |
subl $8,%esp |
fstcw -4(%ebp) /* store fpu control word */ |
movw -4(%ebp),%dx |
orw $0x0800,%dx /* round towards +oo */ |
andw $0xfbff,%dx |
movw %dx,-8(%ebp) |
fldcw -8(%ebp) /* load modfied control word */ |
fldl 8(%ebp); /* round */ |
frndint |
fldcw -4(%ebp) /* restore original control word */ |
leave |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/e_asin.s |
---|
0,0 → 1,49 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: e_asin.S,v 1.2 1994/08/19 11:14:12 jkh Exp $") |
/* asin = atan (x / sqrt(1 - x^2)) */ |
ENTRY(__ieee754_asin) |
fldl 4(%esp) /* x */ |
fst %st(1) |
fmul %st(0) /* x^2 */ |
fld1 |
fsubp /* 1 - x^2 */ |
fsqrt /* sqrt (1 - x^2) */ |
fpatan |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_rint.s |
---|
0,0 → 1,43 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_rint.S,v 1.2 1994/08/19 11:14:29 jkh Exp $") |
ENTRY(rint) |
fldl 4(%esp) |
frndint |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/e_exp.s |
---|
0,0 → 1,54 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: e_exp.S,v 1.2.6.3 1996/06/08 08:25:28 bde Exp $") |
/* e^x = 2^(x * log2(e)) */ |
ENTRY(__ieee754_exp) |
fldl 4(%esp) |
fldl2e |
fmulp /* x * log2(e) */ |
fstl %st(1) |
frndint /* int(x * log2(e)) */ |
fstl %st(2) |
fsubrp /* fract(x * log2(e)) */ |
f2xm1 /* 2^(fract(x * log2(e))) - 1 */ |
fld1 |
faddp /* 2^(fract(x * log2(e))) */ |
fscale /* e^x */ |
fstpl %st(1) |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_finite.s |
---|
0,0 → 1,46 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_finite.S,v 1.2 1994/08/19 11:14:24 jkh Exp $") |
ENTRY(finite) |
movl 8(%esp),%eax |
andl $0x7ff00000, %eax |
cmpl $0x7ff00000, %eax |
setne %al |
andl $0x000000ff, %eax |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_signif.s |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_significand.S,v 1.2 1994/08/19 11:14:30 jkh Exp $") |
ENTRY(significand) |
fldl 4(%esp) |
fxtract |
fstpl %st(1) |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_floor.s |
---|
0,0 → 1,58 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_floor.S,v 1.2.6.1 1996/12/15 15:23:17 bde Exp $") |
ENTRY(floor) |
pushl %ebp |
movl %esp,%ebp |
subl $8,%esp |
fstcw -4(%ebp) /* store fpu control word */ |
movw -4(%ebp),%dx |
orw $0x0400,%dx /* round towards -oo */ |
andw $0xf7ff,%dx |
movw %dx,-8(%ebp) |
fldcw -8(%ebp) /* load modfied control word */ |
fldl 8(%ebp); /* round */ |
frndint |
fldcw -4(%ebp) /* restore original control word */ |
leave |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_log1p.s |
---|
0,0 → 1,55 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_log1p.S,v 1.3 1994/08/19 23:52:29 jkh Exp $") |
/* |
* The fyl2xp1 instruction has such a limited range: |
* -(1 - (sqrt(2) / 2)) <= x <= sqrt(2) - 1 |
* it's not worth trying to use it. |
* |
* Also, I'm not sure fyl2xp1's extra precision will |
* matter once the result is converted from extended |
* real (80 bits) back to double real (64 bits). |
*/ |
ENTRY(log1p) |
fldln2 |
fldl 4(%esp) |
fld1 |
faddp |
fyl2x |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_tan.s |
---|
0,0 → 1,58 |
/* |
* Copyright (c) 1994 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_tan.S,v 1.2 1994/08/19 11:14:32 jkh Exp $") |
ENTRY(tan) |
fldl 4(%esp) |
fptan |
fnstsw %ax |
andw $0x400,%ax |
jnz 1f |
fstp %st(0) |
ret |
1: fldpi |
fadd %st(0) |
fxch %st(1) |
2: fprem1 |
fstsw %ax |
andw $0x400,%ax |
jnz 2b |
fstp %st(1) |
fptan |
fstp %st(0) |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_atan.s |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_atan.S,v 1.2 1994/08/19 11:14:20 jkh Exp $") |
ENTRY(atan) |
fldl 4(%esp) |
fld1 |
fpatan |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_logb.s |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 1993,94 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_logb.S,v 1.2 1994/08/19 11:14:28 jkh Exp $") |
ENTRY(logb) |
fldl 4(%esp) |
fxtract |
fstpl %st |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_cos.s |
---|
0,0 → 1,56 |
/* |
* Copyright (c) 1994 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_cos.S,v 1.2 1994/08/19 11:14:23 jkh Exp $") |
ENTRY(cos) |
fldl 4(%esp) |
fcos |
fnstsw %ax |
andw $0x400,%ax |
jnz 1f |
ret |
1: fldpi |
fadd %st(0) |
fxch %st(1) |
2: fprem1 |
fnstsw %ax |
andw $0x400,%ax |
jnz 2b |
fstp %st(1) |
fcos |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/e_atan2.s |
---|
0,0 → 1,44 |
/* |
* Copyright (c) 1994 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: e_atan2.S,v 1.2 1994/08/19 11:14:13 jkh Exp $") |
ENTRY(__ieee754_atan2) |
fldl 4(%esp) |
fldl 12(%esp) |
fpatan |
ret |
/shark/trunk/libc/arch/x86/libm/msun/i387/s_sin.s |
---|
0,0 → 1,56 |
/* |
* Copyright (c) 1994 Winning Strategies, 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: |
* 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 Winning Strategies, Inc. |
* 4. The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* 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 AUTHOR 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. |
*/ |
/* |
* Written by: |
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. |
*/ |
#include <machine/asmacros.h> |
RCSID("$\Id: s_sin.S,v 1.2 1994/08/19 11:14:31 jkh Exp $") |
ENTRY(sin) |
fldl 4(%esp) |
fsin |
fnstsw %ax |
andw $0x400,%ax |
jnz 1f |
ret |
1: fldpi |
fadd %st(0) |
fxch %st(1) |
2: fprem1 |
fnstsw %ax |
andw $0x400,%ax |
jnz 2b |
fstp %st(1) |
fsin |
ret |
/shark/trunk/libc/arch/x86/libm/msun/src/Makefile |
---|
0,0 → 1,139 |
targets:= \ |
e_acosf.o \ |
e_acosh.o \ |
e_acoshf.o \ |
e_asinf.o \ |
e_atan2f.o \ |
e_atanh.o \ |
e_atanhf.o \ |
e_cosh.o \ |
e_coshf.o \ |
e_expf.o \ |
e_fmod.o \ |
e_fmodf.o \ |
e_gamf1.o \ |
e_gamma.o \ |
e_gamma_.o \ |
e_gammaf.o \ |
e_hypot.o \ |
e_hypotf.o \ |
e_j0.o \ |
e_j0f.o \ |
e_j1.o \ |
e_j1f.o \ |
e_jn.o \ |
e_jnf.o \ |
e_lgam1.o \ |
e_lgam2.o \ |
e_lgam3.o \ |
e_lgamma.o \ |
e_log10f.o \ |
e_logf.o \ |
e_pow.o \ |
e_powf.o \ |
e_rem1.o \ |
e_rem2.o \ |
e_rem_pi.o \ |
e_scalbf.o \ |
e_sinh.o \ |
e_sinhf.o \ |
e_sqrtf.o \ |
k_cos.o \ |
k_cosf.o \ |
k_rem1.o \ |
k_rem_pi.o \ |
k_sin.o \ |
k_sinf.o \ |
k_standa.o \ |
k_tan.o \ |
k_tanf.o \ |
s_asinh.o \ |
s_asinhf.o \ |
s_atanf.o \ |
s_cbrt.o \ |
s_cbrtf.o \ |
s_ceilf.o \ |
s_copy1.o \ |
s_cosf.o \ |
s_erf.o \ |
s_erff.o \ |
s_expm1.o \ |
s_expm1f.o \ |
s_fabs.o \ |
s_fabsf.o \ |
s_fini1.o \ |
s_floorf.o \ |
s_frexp.o \ |
s_frexpf.o \ |
s_ilogbf.o \ |
s_isnan.o \ |
s_isnanf.o \ |
s_ldexp.o \ |
s_ldexpf.o \ |
s_lib_ve.o \ |
s_log1pf.o \ |
s_logbf.o \ |
s_mather.o \ |
s_modf.o \ |
s_modff.o \ |
s_next1.o \ |
s_nextaf.o \ |
s_rintf.o \ |
s_scal1.o \ |
s_sign1.o \ |
s_signga.o \ |
s_sinf.o \ |
s_tanf.o \ |
s_tanh.o \ |
s_tanhf.o \ |
w_acos.o \ |
w_acosf.o \ |
w_acosh.o \ |
w_acoshf.o \ |
w_asin.o \ |
w_asinf.o \ |
w_atan2.o \ |
w_atan2f.o \ |
w_atanh.o \ |
w_atanhf.o \ |
w_cabs.o \ |
w_cabsf.o \ |
w_cosh.o \ |
w_coshf.o \ |
w_drem.o \ |
w_dremf.o \ |
w_exp.o \ |
w_expf.o \ |
w_fmod.o \ |
w_fmodf.o \ |
w_gamf1.o \ |
w_gamma.o \ |
w_gamma_.o \ |
w_gammaf.o \ |
w_hypot.o \ |
w_hypotf.o \ |
w_j0.o \ |
w_j0f.o \ |
w_j1.o \ |
w_j1f.o \ |
w_jn.o \ |
w_jnf.o \ |
w_lgam1.o \ |
w_lgam2.o \ |
w_lgam3.o \ |
w_lgamma.o \ |
w_log.o \ |
w_log10.o \ |
w_log10f.o \ |
w_logf.o \ |
w_pow.o \ |
w_powf.o \ |
w_rem1.o \ |
w_remain.o \ |
w_scalb.o \ |
w_scalbf.o \ |
w_sinh.o \ |
w_sinhf.o \ |
w_sqrt.o \ |
w_sqrtf.o |
/shark/trunk/libc/arch/x86/libm/msun/src/w_cabs.c |
---|
0,0 → 1,27 |
/* |
* cabs() wrapper for hypot(). |
* |
* Written by J.T. Conklin, <jtc@wimsey.com> |
* Placed into the Public Domain, 1994. |
*/ |
#include "math.h" |
struct complex { |
double x; |
double y; |
}; |
double |
cabs(z) |
struct complex z; |
{ |
return hypot(z.x, z.y); |
} |
double |
z_abs(z) |
struct complex *z; |
{ |
return hypot(z->x, z->y); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/math.h |
---|
0,0 → 1,273 |
/* |
* ==================================================== |
* 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. |
* ==================================================== |
*/ |
/* |
* from: @(#)fdlibm.h 5.1 93/09/24 |
* $\Id: math.h,v 1.2 1995/05/30 05:49:16 rgrimes Exp $ |
*/ |
#ifndef _MATH_H_ |
#define _MATH_H_ |
/* |
* ANSI/POSIX |
*/ |
extern char __infinity[]; |
#define HUGE_VAL (*(double *) __infinity) |
/* |
* XOPEN/SVID |
*/ |
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) |
#define M_E 2.7182818284590452354 /* e */ |
#define M_LOG2E 1.4426950408889634074 /* log 2e */ |
#define M_LOG10E 0.43429448190325182765 /* log 10e */ |
#define M_LN2 0.69314718055994530942 /* log e2 */ |
#define M_LN10 2.30258509299404568402 /* log e10 */ |
#define M_PI 3.14159265358979323846 /* pi */ |
#define M_PI_2 1.57079632679489661923 /* pi/2 */ |
#define M_PI_4 0.78539816339744830962 /* pi/4 */ |
#define M_1_PI 0.31830988618379067154 /* 1/pi */ |
#define M_2_PI 0.63661977236758134308 /* 2/pi */ |
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ |
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ |
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ |
#define MAXFLOAT ((float)3.40282346638528860e+38) |
extern int signgam; |
#if !defined(_XOPEN_SOURCE) |
enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix}; |
#define _LIB_VERSION_TYPE enum fdversion |
#define _LIB_VERSION _fdlib_version |
/* if global variable _LIB_VERSION is not desirable, one may |
* change the following to be a constant by: |
* #define _LIB_VERSION_TYPE const enum version |
* In that case, after one initializes the value _LIB_VERSION (see |
* s_lib_version.c) during compile time, it cannot be modified |
* in the middle of a program |
*/ |
extern _LIB_VERSION_TYPE _LIB_VERSION; |
#define _IEEE_ fdlibm_ieee |
#define _SVID_ fdlibm_svid |
#define _XOPEN_ fdlibm_xopen |
#define _POSIX_ fdlibm_posix |
struct exception { |
int type; |
char *name; |
double arg1; |
double arg2; |
double retval; |
}; |
#define HUGE MAXFLOAT |
/* |
* 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 |
#define DOMAIN 1 |
#define SING 2 |
#define OVERFLOW 3 |
#define UNDERFLOW 4 |
#define TLOSS 5 |
#define PLOSS 6 |
#endif /* !_XOPEN_SOURCE */ |
#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/* |
* ANSI/POSIX |
*/ |
extern double acos __P((double)); |
extern double asin __P((double)); |
extern double atan __P((double)); |
extern double atan2 __P((double, double)); |
extern double cos __P((double)); |
extern double sin __P((double)); |
extern double tan __P((double)); |
extern double cosh __P((double)); |
extern double sinh __P((double)); |
extern double tanh __P((double)); |
extern double exp __P((double)); |
extern double frexp __P((double, int *)); |
extern double ldexp __P((double, int)); |
extern double log __P((double)); |
extern double log10 __P((double)); |
extern double modf __P((double, double *)); |
extern double pow __P((double, double)); |
extern double sqrt __P((double)); |
extern double ceil __P((double)); |
extern double fabs __P((double)); |
extern double floor __P((double)); |
extern double fmod __P((double, double)); |
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) |
extern double erf __P((double)); |
extern double erfc __P((double)); |
extern double gamma __P((double)); |
extern double hypot __P((double, double)); |
extern int isinf __P((double)); |
extern int isnan __P((double)); |
extern int finite __P((double)); |
extern double j0 __P((double)); |
extern double j1 __P((double)); |
extern double jn __P((int, double)); |
extern double lgamma __P((double)); |
extern double y0 __P((double)); |
extern double y1 __P((double)); |
extern double yn __P((int, double)); |
#if !defined(_XOPEN_SOURCE) |
extern double acosh __P((double)); |
extern double asinh __P((double)); |
extern double atanh __P((double)); |
extern double cbrt __P((double)); |
extern double logb __P((double)); |
extern double nextafter __P((double, double)); |
extern double remainder __P((double, double)); |
extern double scalb __P((double, double)); |
extern int matherr __P((struct exception *)); |
/* |
* IEEE Test Vector |
*/ |
extern double significand __P((double)); |
/* |
* Functions callable from C, intended to support IEEE arithmetic. |
*/ |
extern double copysign __P((double, double)); |
extern int ilogb __P((double)); |
extern double rint __P((double)); |
extern double scalbn __P((double, int)); |
/* |
* BSD math library entry points |
*/ |
extern double cabs(); |
extern double drem __P((double, double)); |
extern double expm1 __P((double)); |
extern double log1p __P((double)); |
/* |
* Reentrant version of gamma & lgamma; passes signgam back by reference |
* as the second argument; user must allocate space for signgam. |
*/ |
#ifdef _REENTRANT |
extern double gamma_r __P((double, int *)); |
extern double lgamma_r __P((double, int *)); |
#endif /* _REENTRANT */ |
/* float versions of ANSI/POSIX functions */ |
extern float acosf __P((float)); |
extern float asinf __P((float)); |
extern float atanf __P((float)); |
extern float atan2f __P((float, float)); |
extern float cosf __P((float)); |
extern float sinf __P((float)); |
extern float tanf __P((float)); |
extern float coshf __P((float)); |
extern float sinhf __P((float)); |
extern float tanhf __P((float)); |
extern float expf __P((float)); |
extern float frexpf __P((float, int *)); |
extern float ldexpf __P((float, int)); |
extern float logf __P((float)); |
extern float log10f __P((float)); |
extern float modff __P((float, float *)); |
extern float powf __P((float, float)); |
extern float sqrtf __P((float)); |
extern float ceilf __P((float)); |
extern float fabsf __P((float)); |
extern float floorf __P((float)); |
extern float fmodf __P((float, float)); |
extern float erff __P((float)); |
extern float erfcf __P((float)); |
extern float gammaf __P((float)); |
extern float hypotf __P((float, float)); |
extern int isnanf __P((float)); |
extern int finitef __P((float)); |
extern float j0f __P((float)); |
extern float j1f __P((float)); |
extern float jnf __P((int, float)); |
extern float lgammaf __P((float)); |
extern float y0f __P((float)); |
extern float y1f __P((float)); |
extern float ynf __P((int, float)); |
extern float acoshf __P((float)); |
extern float asinhf __P((float)); |
extern float atanhf __P((float)); |
extern float cbrtf __P((float)); |
extern float logbf __P((float)); |
extern float nextafterf __P((float, float)); |
extern float remainderf __P((float, float)); |
extern float scalbf __P((float, float)); |
/* |
* float version of IEEE Test Vector |
*/ |
extern float significandf __P((float)); |
/* |
* Float versions of functions callable from C, intended to support |
* IEEE arithmetic. |
*/ |
extern float copysignf __P((float, float)); |
extern int ilogbf __P((float)); |
extern float rintf __P((float)); |
extern float scalbnf __P((float, int)); |
/* |
* float versions of BSD math library entry points |
*/ |
extern float cabsf (); |
extern float dremf __P((float, float)); |
extern float expm1f __P((float)); |
extern float log1pf __P((float)); |
/* |
* Float versions of reentrant version of gamma & lgamma; passes |
* signgam back by reference as the second argument; user must |
* allocate space for signgam. |
*/ |
#ifdef _REENTRANT |
extern float gammaf_r __P((float, int *)); |
extern float lgammaf_r __P((float, int *)); |
#endif /* _REENTRANT */ |
#endif /* !_XOPEN_SOURCE */ |
#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ |
__END_DECLS |
#endif /* _MATH_H_ */ |
/shark/trunk/libc/arch/x86/libm/msun/src/s_ldexpf.c |
---|
0,0 → 1,35 |
/* s_ldexpf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_ldexpf.c,v 1.2 1995/05/30 05:49:53 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#include <arch/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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/math_pri.h |
---|
0,0 → 1,223 |
/* |
* ==================================================== |
* 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. |
* ==================================================== |
*/ |
/* |
* from: @(#)fdlibm.h 5.1 93/09/24 |
* $\Id: math_private.h,v 1.2 1995/05/30 05:49:17 rgrimes Exp $ |
*/ |
#ifndef _MATH_PRIVATE_H_ |
#define _MATH_PRIVATE_H_ |
#include <arch/endian.h> |
#include <ll/sys/types.h> |
/* The original fdlibm 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. */ |
/* A union which permits us to convert between a double and two 32 bit |
ints. */ |
#if BYTE_ORDER == BIG_ENDIAN |
typedef union |
{ |
double value; |
struct |
{ |
u_int32_t msw; |
u_int32_t lsw; |
} parts; |
} ieee_double_shape_type; |
#endif |
#if BYTE_ORDER == LITTLE_ENDIAN |
typedef union |
{ |
double value; |
struct |
{ |
u_int32_t lsw; |
u_int32_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; |
/* FIXME: Assumes 32 bit int. */ |
unsigned int 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) |
/* 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_lgamma __P((double)); |
extern double __ieee754_gamma __P((double)); |
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 int __ieee754_rem_pio2 __P((double,double*)); |
extern double __ieee754_scalb __P((double,double)); |
/* 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 int*)); |
/* 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_lgammaf __P((float)); |
extern float __ieee754_gammaf __P((float)); |
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 int __ieee754_rem_pio2f __P((float,float*)); |
extern float __ieee754_scalbf __P((float,float)); |
/* 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 int*)); |
#endif /* _MATH_PRIVATE_H_ */ |
/shark/trunk/libc/arch/x86/libm/msun/src/w_scalbf.c |
---|
0,0 → 1,65 |
/* w_scalbf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_scalbf.c,v 1.2 1995/05/30 05:51:42 rgrimes Exp $"; |
#endif |
/* |
* wrapper scalbf(float x, float fn) is provide for |
* passing various standard test suite. One |
* should use scalbn() instead. |
*/ |
#include "math.h" |
#include "math_private.h" |
#include <arch/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; |
z = __ieee754_scalbf(x,fn); |
if(_LIB_VERSION == _IEEE_) return z; |
if(!(finitef(z)||isnanf(z))&&finitef(x)) { |
/* scalbf overflow */ |
return (float)__kernel_standard((double)x,(double)fn,132); |
} |
if(z==(float)0.0&&z!=x) { |
/* scalbf underflow */ |
return (float)__kernel_standard((double)x,(double)fn,133); |
} |
#ifndef _SCALB_INT |
if(!finitef(fn)) errno = ERANGE; |
#endif |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_ldexp.c |
---|
0,0 → 1,32 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_ldexp.c,v 1.2 1995/05/30 05:49:51 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#include <arch/errno.h> |
#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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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 "math.h" |
double |
drem(x, y) |
double x, y; |
{ |
return remainder(x, y); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/math_private.h |
---|
0,0 → 1,223 |
/* |
* ==================================================== |
* 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. |
* ==================================================== |
*/ |
/* |
* from: @(#)fdlibm.h 5.1 93/09/24 |
* $\Id: math_private.h,v 1.2 1995/05/30 05:49:17 rgrimes Exp $ |
*/ |
#ifndef _MATH_PRIVATE_H_ |
#define _MATH_PRIVATE_H_ |
#include <arch/endian.h> |
#include <ll/sys/types.h> |
/* The original fdlibm 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. */ |
/* A union which permits us to convert between a double and two 32 bit |
ints. */ |
#if BYTE_ORDER == BIG_ENDIAN |
typedef union |
{ |
double value; |
struct |
{ |
u_int32_t msw; |
u_int32_t lsw; |
} parts; |
} ieee_double_shape_type; |
#endif |
#if BYTE_ORDER == LITTLE_ENDIAN |
typedef union |
{ |
double value; |
struct |
{ |
u_int32_t lsw; |
u_int32_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; |
/* FIXME: Assumes 32 bit int. */ |
unsigned int 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) |
/* 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_lgamma __P((double)); |
extern double __ieee754_gamma __P((double)); |
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 int __ieee754_rem_pio2 __P((double,double*)); |
extern double __ieee754_scalb __P((double,double)); |
/* 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 int*)); |
/* 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_lgammaf __P((float)); |
extern float __ieee754_gammaf __P((float)); |
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 int __ieee754_rem_pio2f __P((float,float*)); |
extern float __ieee754_scalbf __P((float,float)); |
/* 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 int*)); |
#endif /* _MATH_PRIVATE_H_ */ |
/shark/trunk/libc/arch/x86/libm/msun/src/w_scalb.c |
---|
0,0 → 1,60 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_scalb.c,v 1.2 1995/05/30 05:51:41 rgrimes Exp $"; |
#endif |
/* |
* wrapper scalb(double x, double fn) is provide for |
* passing various standard test suite. One |
* should use scalbn() instead. |
*/ |
#include "math.h" |
#include "math_private.h" |
#include <arch/errno.h> |
#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; |
z = __ieee754_scalb(x,fn); |
if(_LIB_VERSION == _IEEE_) return z; |
if(!(finite(z)||isnan(z))&&finite(x)) { |
return __kernel_standard(x,(double)fn,32); /* scalb overflow */ |
} |
if(z==0.0&&z!=x) { |
return __kernel_standard(x,(double)fn,33); /* scalb underflow */ |
} |
#ifndef _SCALB_INT |
if(!finite(fn)) errno = ERANGE; |
#endif |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/k_standa.c |
---|
0,0 → 1,786 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: k_standard.c,v 1.2 1995/05/30 05:49:13 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#include <arch/errno.h> |
/* Undefine these if you're actually going to use the FreeBSD libc. */ |
#define _USE_WRITE |
#define _NO_FFLUSH |
#ifndef _USE_WRITE |
#include <stdio.h> /* fputs(), stderr */ |
#define WRITE2(u,v) fputs(u, stderr) |
#else /* !defined(_USE_WRITE) */ |
#include <arch/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 |
#if defined(_USE_WRITE) && !defined(_NO_FFLUSH) |
(void) fflush(stdout); |
#endif |
exc.arg1 = x; |
exc.arg2 = y; |
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; |
} |
return exc.retval; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_acosf.c |
---|
0,0 → 1,89 |
/* e_acosf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_acosf.c,v 1.2 1995/05/30 05:47:52 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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 = 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 = 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); |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_exp.c |
---|
0,0 → 1,167 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_exp.c,v 1.3.2.1 1997/02/23 11:03:02 joerg Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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 __generic___ieee754_exp(double x) /* default IEEE double exp */ |
#else |
double __generic___ieee754_exp(x) /* default IEEE double exp */ |
double x; |
#endif |
{ |
double y,hi=0.0,lo=0.0,c,t; |
int32_t k=0,xsb; |
u_int32_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) { |
u_int32_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 */ |
} |
else k = 0; |
/* 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) { |
u_int32_t hy; |
GET_HIGH_WORD(hy,y); |
SET_HIGH_WORD(y,hy+(k<<20)); /* add k to y's exponent */ |
return y; |
} else { |
u_int32_t hy; |
GET_HIGH_WORD(hy,y); |
SET_HIGH_WORD(y,hy+((k+1000)<<20)); /* add k to y's exponent */ |
return y*twom1000; |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_finite.c,v 1.2.6.1 1997/02/23 11:03:17 joerg Exp $"; |
#endif |
/* |
* finite(x) returns 1 is x is finite, else 0; |
* no branching! |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
int __generic_finite(double x) |
#else |
int __generic_finite(x) |
double x; |
#endif |
{ |
int32_t hx; |
GET_HIGH_WORD(hx,x); |
return (int)((u_int32_t)((hx&0x7fffffff)-0x7ff00000)>>31); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_atan2f.c |
---|
0,0 → 1,47 |
/* w_atan2f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_atan2f.c,v 1.2 1995/05/30 05:50:44 rgrimes Exp $"; |
#endif |
/* |
* wrapper atan2f(y,x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
float atan2f(float y, float x) /* wrapper atan2f */ |
#else |
float atan2f(y,x) /* wrapper atan2 */ |
float y,x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_atan2f(y,x); |
#else |
float z; |
z = __ieee754_atan2f(y,x); |
if(_LIB_VERSION == _IEEE_||isnanf(x)||isnanf(y)) return z; |
if(x==(float)0.0&&y==(float)0.0) { |
/* atan2f(+-0,+-0) */ |
return (float)__kernel_standard((double)y,(double)x,103); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_mather.c |
---|
0,0 → 1,30 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_matherr.c,v 1.2 1995/05/30 05:50:02 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_fabsf.c |
---|
0,0 → 1,38 |
/* s_fabsf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_fabsf.c,v 1.2 1995/05/30 05:49:36 rgrimes Exp $"; |
#endif |
/* |
* fabsf(x) returns the absolute value of x. |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
float fabsf(float x) |
#else |
float fabsf(x) |
float x; |
#endif |
{ |
u_int32_t ix; |
GET_FLOAT_WORD(ix,x); |
SET_FLOAT_WORD(x,ix&0x7fffffff); |
return x; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_sign1.c |
---|
0,0 → 1,31 |
/* s_significandf.c -- float version of s_significand.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_significandf.c,v 1.2 1995/05/30 05:50:28 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
float significandf(float x) |
#else |
float significandf(x) |
float x; |
#endif |
{ |
return __ieee754_scalbf(x,(float) -ilogbf(x)); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_floor.c |
---|
0,0 → 1,81 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_floor.c,v 1.2.6.1 1997/02/23 11:03:18 joerg Exp $"; |
#endif |
/* |
* 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 "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
static const double huge = 1.0e300; |
#else |
static double huge = 1.0e300; |
#endif |
#ifdef __STDC__ |
double __generic_floor(double x) |
#else |
double __generic_floor(x) |
double x; |
#endif |
{ |
int32_t i0,i1,j0; |
u_int32_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 = ((u_int32_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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_sinh.c,v 1.3 1996/07/12 18:57:58 jkh Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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; |
u_int32_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<=(u_int32_t)0x8fb9f87d))) { |
w = __ieee754_exp(0.5*fabs(x)); |
t = h*w; |
return t*w; |
} |
/* |x| > overflowthresold, sinh(x) overflow */ |
return x*shuge; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_lgam1.c |
---|
0,0 → 1,312 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_lgamma_r.c,v 1.2 1995/05/30 05:48:27 rgrimes Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.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; |
int 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 = (int) (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,p,p1,p2,p3,q,r,w; |
int 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 = (int)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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_expf.c |
---|
0,0 → 1,103 |
/* e_expf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_expf.c,v 1.3 1996/07/12 18:57:56 jkh Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#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 */ |
o_threshold= 8.8721679688e+01, /* 0x42b17180 */ |
u_threshold= -1.0397208405e+02, /* 0xc2cff1b5 */ |
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=0.0,lo=0.0,c,t; |
int32_t k=0,xsb; |
u_int32_t hx; |
GET_FLOAT_WORD(hx,x); |
xsb = (hx>>31)&1; /* sign bit of x */ |
hx &= 0x7fffffff; /* high word of |x| */ |
/* filter out non-finite argument */ |
if(hx >= 0x42b17218) { /* if |x|>=88.721... */ |
if(hx>0x7f800000) |
return x+x; /* NaN */ |
if(hx==0x7f800000) |
return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */ |
if(x > o_threshold) return huge*huge; /* overflow */ |
if(x < u_threshold) 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 */ |
} |
else k = 0; |
/* 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) { |
u_int32_t hy; |
GET_FLOAT_WORD(hy,y); |
SET_FLOAT_WORD(y,hy+(k<<23)); /* add k to y's exponent */ |
return y; |
} else { |
u_int32_t hy; |
GET_FLOAT_WORD(hy,y); |
SET_FLOAT_WORD(y,hy+((k+100)<<23)); /* add k to y's exponent */ |
return y*twom100; |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_gamma_.c |
---|
0,0 → 1,46 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_gamma_r.c,v 1.2 1995/05/30 05:51:06 rgrimes Exp $"; |
#endif |
/* |
* wrapper double gamma_r(double x, int *signgamp) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
y = __ieee754_gamma_r(x,signgamp); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finite(y)&&finite(x)) { |
if(floor(x)==x&&x<=0.0) |
return __kernel_standard(x,x,41); /* gamma pole */ |
else |
return __kernel_standard(x,x,40); /* gamma overflow */ |
} else |
return y; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_rem1.c |
---|
0,0 → 1,196 |
/* e_rem_pio2f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_rem_pio2f.c,v 1.3 1995/05/30 05:48:38 rgrimes Exp $"; |
#endif |
/* __ieee754_rem_pio2f(x,y) |
* |
* return the remainder of x rem pi/2 in y[0]+y[1] |
* use __kernel_rem_pio2f() |
*/ |
#include "math.h" |
#include "math_private.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 e0,i,j,nx,n,ix,hx; |
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 { |
u_int32_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(ix>=0x7f800000) { /* x is inf or NaN */ |
y[0]=y[1]=x-x; return 0; |
} |
/* set z = scalbn(|x|,ilogb(x)-7) */ |
e0 = (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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_fmod.c |
---|
0,0 → 1,43 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_fmod.c,v 1.2 1995/05/30 05:51:02 rgrimes Exp $"; |
#endif |
/* |
* wrapper fmod(x,y) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_fmod(x,y); |
if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z; |
if(y==0.0) { |
return __kernel_standard(x,y,27); /* fmod(x,0) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_expm1.c |
---|
0,0 → 1,228 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_expm1.c,v 1.2 1995/05/30 05:49:33 rgrimes Exp $"; |
#endif |
/* 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 "math.h" |
#include "math_private.h" |
#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; |
u_int32_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) { |
u_int32_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 */ |
u_int32_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) { |
u_int32_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 { |
u_int32_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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_j0.c,v 1.2 1995/05/30 05:48:18 rgrimes Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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)/sqrt(x); |
else { |
u = pzero(x); v = qzero(x); |
z = invsqrtpi*(u*cc-v*ss)/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)/sqrt(x); |
else { |
u = pzero(x); v = qzero(x); |
z = invsqrtpi*(u*ss+v*cc)/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 if(ix>=0x40000000){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 pzero 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 if(ix>=0x40000000){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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_powf.c |
---|
0,0 → 1,253 |
/* e_powf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_powf.c,v 1.2 1995/05/30 05:48:36 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#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(iy==0) return one; |
/* +-NaN return x+y */ |
if(ix > 0x7f800000 || |
iy > 0x7f800000) |
return x+y; |
/* 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 (iy==0x7f800000) { /* y is +-inf */ |
if (ix==0x3f800000) |
return y - y; /* inf**+-1 is NaN */ |
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 sqrtf(x); |
} |
ax = fabsf(x); |
/* special value of x */ |
if(ix==0x7f800000||ix==0||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(((((u_int32_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 = x-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(ix<0x00800000) |
{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(((((u_int32_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); |
if (j>0x43000000) /* if z > 128 */ |
return s*huge*huge; /* overflow */ |
else if (j==0x43000000) { /* if z == 128 */ |
if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */ |
} |
else if ((j&0x7fffffff)>0x43160000) /* z <= -150 */ |
return s*tiny*tiny; /* underflow */ |
else if (j==0xc3160000){ /* z == -150 */ |
if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */ |
} |
/* |
* compute 2**(p_h+p_l) |
*/ |
i = j&0x7fffffff; |
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,n); /* subnormal output */ |
else SET_FLOAT_WORD(z,j); |
return s*z; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_acosf.c |
---|
0,0 → 1,47 |
/* w_acosf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_acosf.c,v 1.2 1995/05/30 05:50:38 rgrimes Exp $"; |
#endif |
/* |
* wrap_acosf(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __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; |
z = __ieee754_acosf(x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; |
if(fabsf(x)>(float)1.0) { |
/* acosf(|x|>1) */ |
return (float)__kernel_standard((double)x,(double)x,101); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_j1f.c |
---|
0,0 → 1,444 |
/* e_j1f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_j1f.c,v 1.2 1995/05/30 05:48:23 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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(ix>=0x7f800000) 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<0x7f000000) { /* 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)/sqrtf(y); |
else { |
u = ponef(y); v = qonef(y); |
z = invsqrtpi*(u*cc-v*ss)/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(ix>=0x7f800000) return one/(x+x*x); |
if(ix==0) 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<0x7f000000) { /* 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)/sqrtf(x); |
else { |
u = ponef(x); v = qonef(x); |
z = invsqrtpi*(u*ss+v*cc)/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 if(ix>=0x40000000){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 pone 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 if(ix>=0x40000000){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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_log10.c,v 1.3.6.1 1997/02/23 11:03:06 joerg Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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 __generic___ieee754_log10(double x) |
#else |
double __generic___ieee754_log10(x) |
double x; |
#endif |
{ |
double y,z; |
int32_t i,k,hx; |
u_int32_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 = ((u_int32_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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_lgam1.c |
---|
0,0 → 1,46 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_lgamma_r.c,v 1.2 1995/05/30 05:51:29 rgrimes Exp $"; |
#endif |
/* |
* wrapper double lgamma_r(double x, int *signgamp) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
y = __ieee754_lgamma_r(x,signgamp); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finite(y)&&finite(x)) { |
if(floor(x)==x&&x<=0.0) |
return __kernel_standard(x,x,15); /* lgamma pole */ |
else |
return __kernel_standard(x,x,14); /* lgamma overflow */ |
} else |
return y; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_jn.c |
---|
0,0 → 1,42 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_jn.c,v 1.2.6.1 1997/03/03 14:21:06 bde Exp $"; |
#endif |
/* |
* wrapper jn(int n, double x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_jn(n,x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(fabs(x)>X_TLOSS) { |
return __kernel_standard((double)n,x,38); /* jn(|x|>X_TLOSS,n) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_isnanf.c |
---|
0,0 → 1,40 |
/* s_isnanf.c -- float version of s_isnan.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_isnanf.c,v 1.2 1995/05/30 05:49:48 rgrimes Exp $"; |
#endif |
/* |
* isnanf(x) returns 1 is x is nan, else 0; |
* no branching! |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
int isnanf(float x) |
#else |
int isnanf(x) |
float x; |
#endif |
{ |
int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; |
ix = 0x7f800000 - ix; |
return (int)(((u_int32_t)(ix))>>31); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_lgamma.c |
---|
0,0 → 1,36 |
/* @(#)e_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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_lgamma.c,v 1.2 1995/05/30 05:48:26 rgrimes Exp $"; |
#endif |
/* __ieee754_lgamma(x) |
* Return the logarithm of the Gamma function of x. |
* |
* Method: call __ieee754_lgamma_r |
*/ |
#include "math.h" |
#include "math_private.h" |
extern int signgam; |
#ifdef __STDC__ |
double __ieee754_lgamma(double x) |
#else |
double __ieee754_lgamma(x) |
double x; |
#endif |
{ |
return __ieee754_lgamma_r(x,&signgam); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_ceilf.c |
---|
0,0 → 1,61 |
/* s_ceilf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_ceilf.c,v 1.2 1995/05/30 05:49:26 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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; |
u_int32_t i; |
GET_FLOAT_WORD(i0,x); |
j0 = ((i0>>23)&0xff)-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(i0!=0) { 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(j0==0x80) return x+x; /* inf or NaN */ |
else return x; /* x is integral */ |
} |
SET_FLOAT_WORD(x,i0); |
return x; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_asinf.c |
---|
0,0 → 1,92 |
/* e_asinf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_asinf.c,v 1.3 1996/07/12 18:57:47 jkh Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0000000000e+00, /* 0x3F800000 */ |
huge = 1.000e+30, |
pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */ |
pio2_lo = 7.5497894159e-08, /* 0x33a22168 */ |
pio4_hi = 7.8539818525e-01, /* 0x3f490fdb */ |
/* 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=0.0,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 = 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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_atanhf.c |
---|
0,0 → 1,58 |
/* e_atanhf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_atanhf.c,v 1.2 1995/05/30 05:48:04 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_atan.c |
---|
0,0 → 1,139 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_atan.c,v 1.2.6.1 1997/02/23 11:03:13 joerg Exp $"; |
#endif |
/* 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 "math.h" |
#include "math_private.h" |
#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 __generic_atan(double x) |
#else |
double __generic_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 */ |
u_int32_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; |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_log10.c |
---|
0,0 → 1,46 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_log10.c,v 1.2 1995/05/30 05:51:34 rgrimes Exp $"; |
#endif |
/* |
* wrapper log10(X) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_log10(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(x<=0.0) { |
if(x==0.0) |
return __kernel_standard(x,x,18); /* log10(0) */ |
else |
return __kernel_standard(x,x,19); /* log10(x<0) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_modff.c |
---|
0,0 → 1,64 |
/* s_modff.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_modff.c,v 1.2 1995/05/30 05:50:08 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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; |
u_int32_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 */ |
u_int32_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 */ |
u_int32_t ix; |
*iptr = x*one; |
GET_FLOAT_WORD(ix,x); |
SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ |
return x; |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_log10f.c |
---|
0,0 → 1,51 |
/* w_log10f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_log10f.c,v 1.2 1995/05/30 05:51:35 rgrimes Exp $"; |
#endif |
/* |
* wrapper log10f(X) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_log10f(x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; |
if(x<=(float)0.0) { |
if(x==(float)0.0) |
/* log10(0) */ |
return (float)__kernel_standard((double)x,(double)x,118); |
else |
/* log10(x<0) */ |
return (float)__kernel_standard((double)x,(double)x,119); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_ilogb.c |
---|
0,0 → 1,50 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_ilogb.c,v 1.2.6.1 1997/02/23 11:03:19 joerg Exp $"; |
#endif |
/* ilogb(double x) |
* return the binary exponent of non-zero x |
* ilogb(0) = 0x80000001 |
* ilogb(inf/NaN) = 0x7fffffff (no signal is raised) |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
int __generic_ilogb(double x) |
#else |
int __generic_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 0x80000001; /* ilogb(0) = 0x80000001 */ |
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; |
else return 0x7fffffff; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_remain.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_remainder.c,v 1.2.6.1 1997/02/23 11:03:07 joerg Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
static const double zero = 0.0; |
#else |
static double zero = 0.0; |
#endif |
#ifdef __STDC__ |
double __generic___ieee754_remainder(double x, double p) |
#else |
double __generic___ieee754_remainder(x,p) |
double x,p; |
#endif |
{ |
int32_t hx,hp; |
u_int32_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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_asin.c |
---|
0,0 → 1,44 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_asin.c,v 1.2 1995/05/30 05:50:41 rgrimes Exp $"; |
#endif |
/* |
* wrapper asin(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_asin(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabs(x)>1.0) { |
return __kernel_standard(x,x,2); /* asin(|x|>1) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_jnf.c |
---|
0,0 → 1,212 |
/* e_jnf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_jnf.c,v 1.3 1995/05/30 05:48:25 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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(ix>0x7f800000) 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(ix==0||ix>=0x7f800000) /* if x is 0 or inf */ |
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(ix>0x7f800000) return x+x; |
if(ix==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_y0f(x)); |
if(n==1) return(sign*__ieee754_y1f(x)); |
if(ix==0x7f800000) 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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_asinf.c |
---|
0,0 → 1,48 |
/* w_asinf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_asinf.c,v 1.2 1995/05/30 05:50:42 rgrimes Exp $"; |
#endif |
/* |
* wrapper asinf(x) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_asinf(x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; |
if(fabsf(x)>(float)1.0) { |
/* asinf(|x|>1) */ |
return (float)__kernel_standard((double)x,(double)x,102); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_fmod.c,v 1.2.6.1 1997/02/23 11:03:03 joerg Exp $"; |
#endif |
/* |
* __ieee754_fmod(x,y) |
* Return x mod y in exact arithmetic |
* Method: shift and subtract |
*/ |
#include "math.h" |
#include "math_private.h" |
#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 __generic___ieee754_fmod(double x, double y) |
#else |
double __generic___ieee754_fmod(x,y) |
double x,y ; |
#endif |
{ |
int32_t n,hx,hy,hz,ix,iy,sx,i; |
u_int32_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[(u_int32_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[(u_int32_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[(u_int32_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)|((u_int32_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 */ |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_asinhf.c |
---|
0,0 → 1,57 |
/* s_asinhf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_asinhf.c,v 1.2 1995/05/30 05:49:19 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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(ix>=0x7f800000) 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/(sqrtf(x*x+one)+t)); |
} else { /* 2.0 > |x| > 2**-28 */ |
t = x*x; |
w =log1pf(fabsf(x)+t/(one+sqrtf(one+t))); |
} |
if(hx>0) return w; else return -w; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_atanh.c |
---|
0,0 → 1,74 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_atanh.c,v 1.2 1995/05/30 05:48:01 rgrimes Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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; |
u_int32_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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_sqrtf.c |
---|
0,0 → 1,97 |
/* e_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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_sqrtf.c,v 1.2 1995/05/30 05:48:52 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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; |
int32_t sign = (int)0x80000000; |
int32_t ix,s,q,m,t,i; |
u_int32_t r; |
GET_FLOAT_WORD(ix,x); |
/* take care of Inf and NaN */ |
if((ix&0x7f800000)==0x7f800000) { |
return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf |
sqrt(-inf)=sNaN */ |
} |
/* take care of zero */ |
if(ix<=0) { |
if((ix&(~sign))==0) return x;/* sqrt(+-0) = +-0 */ |
else if(ix<0) |
return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ |
} |
/* normalize x */ |
m = (ix>>23); |
if(m==0) { /* subnormal x */ |
for(i=0;(ix&0x00800000)==0;i++) ix<<=1; |
m -= i-1; |
} |
m -= 127; /* unbias exponent */ |
ix = (ix&0x007fffff)|0x00800000; |
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 = 0x01000000; /* 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)+0x3f000000; |
ix += (m <<23); |
SET_FLOAT_WORD(z,ix); |
return z; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_j0f.c |
---|
0,0 → 1,45 |
/* w_j0f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_j0f.c,v 1.2.6.1 1997/03/03 14:21:05 bde Exp $"; |
#endif |
/* |
* wrapper j0f(float x) |
*/ |
#include "math.h" |
#include "math_private.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 |
float z = __ieee754_j0f(x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; |
if(fabsf(x)>(float)X_TLOSS) { |
/* j0f(|x|>X_TLOSS) */ |
return (float)__kernel_standard((double)x,(double)x,134); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_lgam2.c |
---|
0,0 → 1,39 |
/* e_lgammaf.c -- float version of e_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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_lgammaf.c,v 1.2 1995/05/30 05:48:28 rgrimes Exp $"; |
#endif |
/* __ieee754_lgammaf(x) |
* Return the logarithm of the Gamma function of x. |
* |
* Method: call __ieee754_lgammaf_r |
*/ |
#include "math.h" |
#include "math_private.h" |
extern int signgam; |
#ifdef __STDC__ |
float __ieee754_lgammaf(float x) |
#else |
float __ieee754_lgammaf(x) |
float x; |
#endif |
{ |
return __ieee754_lgammaf_r(x,&signgam); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_modf.c |
---|
0,0 → 1,83 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_modf.c,v 1.2 1995/05/30 05:50:04 rgrimes Exp $"; |
#endif |
/* |
* 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 "math.h" |
#include "math_private.h" |
#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; |
u_int32_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 */ |
u_int32_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 */ |
u_int32_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 = ((u_int32_t)(0xffffffff))>>(j0-20); |
if((i1&i)==0) { /* x is integral */ |
u_int32_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; |
} |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_rem2.c |
---|
0,0 → 1,73 |
/* e_remainderf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_remainderf.c,v 1.2 1995/05/30 05:48:40 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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; |
u_int32_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(hp==0) return (x*p)/(x*p); /* p = 0 */ |
if((hx>=0x7f800000)|| /* x not finite */ |
((hp>0x7f800000))) /* p is NaN */ |
return (x*p)/(x*p); |
if (hp<=0x7effffff) 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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_cbrt.c |
---|
0,0 → 1,93 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_cbrt.c,v 1.2 1995/05/30 05:49:22 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
/* cbrt(x) |
* Return cube root of x |
*/ |
#ifdef __STDC__ |
static const u_int32_t |
#else |
static u_int32_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; |
u_int32_t sign; |
u_int32_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); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_logf.c |
---|
0,0 → 1,48 |
/* w_logf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_logf.c,v 1.2 1995/05/30 05:51:36 rgrimes Exp $"; |
#endif |
/* |
* wrapper logf(x) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_logf(x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x) || x > (float)0.0) return z; |
if(x==(float)0.0) |
/* logf(0) */ |
return (float)__kernel_standard((double)x,(double)x,116); |
else |
/* logf(x<0) */ |
return (float)__kernel_standard((double)x,(double)x,117); |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_j1.c,v 1.2 1995/05/30 05:48:20 rgrimes Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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/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>0x48000000) z = (invsqrtpi*cc)/sqrt(y); |
else { |
u = pone(y); v = qone(y); |
z = invsqrtpi*(u*cc-v*ss)/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)/sqrt(x); |
else { |
u = pone(x); v = qone(x); |
z = invsqrtpi*(u*ss+v*cc)/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 if(ix>=0x40000000){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 pone 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 if(ix>=0x40000000){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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/k_rem1.c |
---|
0,0 → 1,213 |
/* k_rem_pio2f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: k_rem_pio2f.c,v 1.2 1995/05/30 05:49:00 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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,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,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,-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,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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_atanh.c |
---|
0,0 → 1,47 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_atanh.c,v 1.2 1995/05/30 05:50:45 rgrimes Exp $"; |
#endif |
/* |
* wrapper atanh(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_atanh(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
y = fabs(x); |
if(y>=1.0) { |
if(y>1.0) |
return __kernel_standard(x,x,30); /* atanh(|x|>1) */ |
else |
return __kernel_standard(x,x,31); /* atanh(|x|==1) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/k_rem_pi.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: k_rem_pio2.c,v 1.2 1995/05/30 05:48:57 rgrimes Exp $"; |
#endif |
/* |
* __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 "math.h" |
#include "math_private.h" |
#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,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,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,-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,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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_sqrtf.c |
---|
0,0 → 1,46 |
/* w_sqrtf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_sqrtf.c,v 1.2 1995/05/30 05:51:47 rgrimes Exp $"; |
#endif |
/* |
* wrapper sqrtf(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
float sqrtf(float x) /* wrapper sqrtf */ |
#else |
float sqrt(x) /* wrapper sqrtf */ |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_sqrtf(x); |
#else |
float z; |
z = __ieee754_sqrtf(x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; |
if(x<(float)0.0) { |
/* sqrtf(negative) */ |
return (float)__kernel_standard((double)x,(double)x,126); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_lgam2.c |
---|
0,0 → 1,48 |
/* w_lgammaf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_lgammaf.c,v 1.2 1995/05/30 05:51:31 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
extern int signgam; |
#ifdef __STDC__ |
float lgammaf(float x) |
#else |
float lgammaf(x) |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_lgammaf_r(x,&signgam); |
#else |
float y; |
y = __ieee754_lgammaf_r(x,&signgam); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finitef(y)&&finitef(x)) { |
if(floorf(x)==x&&x<=(float)0.0) |
/* lgamma pole */ |
return (float)__kernel_standard((double)x,(double)x,115); |
else |
/* lgamma overflow */ |
return (float)__kernel_standard((double)x,(double)x,114); |
} else |
return y; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_fabs.c |
---|
0,0 → 1,35 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_fabs.c,v 1.2 1995/05/30 05:49:35 rgrimes Exp $"; |
#endif |
/* |
* fabs(x) returns the absolute value of x. |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
double fabs(double x) |
#else |
double fabs(x) |
double x; |
#endif |
{ |
u_int32_t high; |
GET_HIGH_WORD(high,x); |
SET_HIGH_WORD(x,high&0x7fffffff); |
return x; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_asin.c |
---|
0,0 → 1,120 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_asin.c,v 1.3.2.1 1997/02/23 11:03:00 joerg Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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 __generic___ieee754_asin(double x) |
#else |
double __generic___ieee754_asin(x) |
double x; |
#endif |
{ |
double t=0.0,w,p,q,c,r,s; |
int32_t hx,ix; |
GET_HIGH_WORD(hx,x); |
ix = hx&0x7fffffff; |
if(ix>= 0x3ff00000) { /* |x|>= 1 */ |
u_int32_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 = 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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_ceil.c,v 1.2.6.1 1997/02/23 11:03:14 joerg Exp $"; |
#endif |
/* |
* 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 "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
static const double huge = 1.0e300; |
#else |
static double huge = 1.0e300; |
#endif |
#ifdef __STDC__ |
double __generic_ceil(double x) |
#else |
double __generic_ceil(x) |
double x; |
#endif |
{ |
int32_t i0,i1,j0; |
u_int32_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 = ((u_int32_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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_fmodf.c |
---|
0,0 → 1,113 |
/* e_fmodf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_fmodf.c,v 1.2 1995/05/30 05:48:11 rgrimes Exp $"; |
#endif |
/* |
* __ieee754_fmodf(x,y) |
* Return x mod y in exact arithmetic |
* Method: shift and subtract |
*/ |
#include "math.h" |
#include "math_private.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(hy==0||(hx>=0x7f800000)|| /* y=0,or x not finite */ |
(hy>0x7f800000)) /* or y is NaN */ |
return (x*y)/(x*y); |
if(hx<hy) return x; /* |x|<|y| return x */ |
if(hx==hy) |
return Zero[(u_int32_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 = 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[(u_int32_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[(u_int32_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 */ |
n = -126 - iy; |
hx >>= n; |
SET_FLOAT_WORD(x,hx|sx); |
x *= one; /* create necessary signal */ |
} |
return x; /* exact output */ |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_j0.c |
---|
0,0 → 1,41 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_j0.c,v 1.2.6.1 1997/03/03 14:21:04 bde Exp $"; |
#endif |
/* |
* wrapper j0(double x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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 |
double z = __ieee754_j0(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabs(x)>X_TLOSS) { |
return __kernel_standard(x,x,34); /* j0(|x|>X_TLOSS) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/k_tanf.c |
---|
0,0 → 1,101 |
/* k_tanf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: k_tanf.c,v 1.2 1995/05/30 05:49:15 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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); |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: k_sin.c,v 1.2 1995/05/30 05:49:05 rgrimes Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_log1p.c |
---|
0,0 → 1,173 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_log1p.c,v 1.2 1995/05/30 05:49:57 rgrimes Exp $"; |
#endif |
/* 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 "math.h" |
#include "math_private.h" |
#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); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_log.c |
---|
0,0 → 1,43 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_log.c,v 1.2 1995/05/30 05:51:33 rgrimes Exp $"; |
#endif |
/* |
* wrapper log(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_log(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) || x > 0.0) return z; |
if(x==0.0) |
return __kernel_standard(x,x,16); /* log(0) */ |
else |
return __kernel_standard(x,x,17); /* log(x<0) */ |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_floorf.c |
---|
0,0 → 1,70 |
/* s_floorf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_floorf.c,v 1.2 1995/05/30 05:49:40 rgrimes Exp $"; |
#endif |
/* |
* 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 "math.h" |
#include "math_private.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; |
u_int32_t i; |
GET_FLOAT_WORD(i0,x); |
j0 = ((i0>>23)&0xff)-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((i0&0x7fffffff)!=0) |
{ 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(j0==0x80) return x+x; /* inf or NaN */ |
else return x; /* x is integral */ |
} |
SET_FLOAT_WORD(x,i0); |
return x; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_tanf.c |
---|
0,0 → 1,48 |
/* s_tanf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_tanf.c,v 1.2 1995/05/30 05:50:34 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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 (ix>=0x7f800000) 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 */ |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_sin.c |
---|
0,0 → 1,82 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_sin.c,v 1.2.6.1 1997/02/23 11:03:22 joerg Exp $"; |
#endif |
/* 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 "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
double __generic_sin(double x) |
#else |
double __generic_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]); |
} |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_logbf.c |
---|
0,0 → 1,39 |
/* s_logbf.c -- float version of s_logb.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_logbf.c,v 1.2 1995/05/30 05:50:00 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
float logbf(float x) |
#else |
float logbf(x) |
float x; |
#endif |
{ |
int32_t ix; |
GET_FLOAT_WORD(ix,x); |
ix &= 0x7fffffff; /* high |x| */ |
if(ix==0) return (float)-1.0/fabsf(x); |
if(ix>=0x7f800000) return x*x; |
if((ix>>=23)==0) /* IEEE 754 logb */ |
return -126.0; |
else |
return (float) (ix-127); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_frexpf.c |
---|
0,0 → 1,52 |
/* s_frexpf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_frexpf.c,v 1.3 1995/05/30 05:49:44 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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(ix>=0x7f800000||(ix==0)) return x; /* 0,inf,nan */ |
if (ix<0x00800000) { /* subnormal */ |
x *= two25; |
GET_FLOAT_WORD(hx,x); |
ix = hx&0x7fffffff; |
*eptr = -25; |
} |
*eptr += (ix>>23)-126; |
hx = (hx&0x807fffff)|0x3f000000; |
*(int*)&x = hx; |
return x; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_copy1.c |
---|
0,0 → 1,41 |
/* s_copysignf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_copysignf.c,v 1.2 1995/05/30 05:49:28 rgrimes Exp $"; |
#endif |
/* |
* copysignf(float x, float y) |
* copysignf(x,y) returns a value with the magnitude of x and |
* with the sign bit of y. |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
float copysignf(float x, float y) |
#else |
float copysignf(x,y) |
float x,y; |
#endif |
{ |
u_int32_t ix,iy; |
GET_FLOAT_WORD(ix,x); |
GET_FLOAT_WORD(iy,y); |
SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000)); |
return x; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_sqrt.c |
---|
0,0 → 1,42 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_sqrt.c,v 1.2 1995/05/30 05:51:46 rgrimes Exp $"; |
#endif |
/* |
* wrapper sqrt(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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 |
double z; |
z = __ieee754_sqrt(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(x<0.0) { |
return __kernel_standard(x,x,26); /* sqrt(negative) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_fmodf.c |
---|
0,0 → 1,47 |
/* w_fmodf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_fmodf.c,v 1.2 1995/05/30 05:51:03 rgrimes Exp $"; |
#endif |
/* |
* wrapper fmodf(x,y) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_fmodf(x,y); |
if(_LIB_VERSION == _IEEE_ ||isnanf(y)||isnanf(x)) return z; |
if(y==(float)0.0) { |
/* fmodf(x,0) */ |
return (float)__kernel_standard((double)x,(double)y,127); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_tanhf.c |
---|
0,0 → 1,64 |
/* s_tanhf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_tanhf.c,v 1.2 1995/05/30 05:50:36 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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(ix>=0x7f800000) { |
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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_lib_ve.c |
---|
0,0 → 1,39 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_lib_version.c,v 1.2 1995/05/30 05:49:56 rgrimes Exp $"; |
#endif |
/* |
* MACRO for standards |
*/ |
#include "math.h" |
#include "math_private.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 |
/shark/trunk/libc/arch/x86/libm/msun/src/w_dremf.c |
---|
0,0 → 1,16 |
/* |
* dremf() wrapper for remainderf(). |
* |
* Written by J.T. Conklin, <jtc@wimsey.com> |
* Placed into the Public Domain, 1994. |
*/ |
#include "math.h" |
#include "math_private.h" |
float |
dremf(x, y) |
float x, y; |
{ |
return remainderf(x, y); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_lgamma.c |
---|
0,0 → 1,49 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_lgamma.c,v 1.2 1995/05/30 05:51:28 rgrimes Exp $"; |
#endif |
/* double lgamma(double x) |
* Return the logarithm of the Gamma function of x. |
* |
* Method: call __ieee754_lgamma_r |
*/ |
#include "math.h" |
#include "math_private.h" |
extern int signgam; |
#ifdef __STDC__ |
double lgamma(double x) |
#else |
double lgamma(x) |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_lgamma_r(x,&signgam); |
#else |
double y; |
y = __ieee754_lgamma_r(x,&signgam); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finite(y)&&finite(x)) { |
if(floor(x)==x&&x<=0.0) |
return __kernel_standard(x,x,15); /* lgamma pole */ |
else |
return __kernel_standard(x,x,14); /* lgamma overflow */ |
} else |
return y; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_scal1.c |
---|
0,0 → 1,62 |
/* 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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_scalbnf.c,v 1.2 1995/05/30 05:50:24 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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 scalbnf (float x, int n) |
#else |
float scalbn (x,n) |
float x; 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 (n< -50000) return tiny*x; /*underflow*/ |
} |
if (k==0xff) return x+x; /* NaN or Inf */ |
k = k+n; |
if (k > 0xfe) return huge*copysignf(huge,x); /* overflow */ |
if (k > 0) /* normal result */ |
{SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;} |
if (k <= -25) |
if (n > 50000) /* 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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_atanhf.c |
---|
0,0 → 1,52 |
/* w_atanhf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_atanhf.c,v 1.2 1995/05/30 05:50:46 rgrimes Exp $"; |
#endif |
/* |
* wrapper atanhf(x) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_atanhf(x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; |
y = fabsf(x); |
if(y>=(float)1.0) { |
if(y>(float)1.0) |
/* atanhf(|x|>1) */ |
return (float)__kernel_standard((double)x,(double)x,130); |
else |
/* atanhf(|x|==1) */ |
return (float)__kernel_standard((double)x,(double)x,131); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_pow.c |
---|
0,0 → 1,61 |
/* @(#)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. |
* ==================================================== |
*/ |
/* |
* wrapper pow(x,y) return x**y |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z=__ieee754_pow(x,y); |
if(_LIB_VERSION == _IEEE_|| isnan(y)) return z; |
if(isnan(x)) { |
if(y==0.0) |
return __kernel_standard(x,y,42); /* pow(NaN,0.0) */ |
else |
return z; |
} |
if(x==0.0){ |
if(y==0.0) |
return __kernel_standard(x,y,20); /* pow(0.0,0.0) */ |
if(finite(y)&&y<0.0) |
return __kernel_standard(x,y,23); /* pow(0.0,negative) */ |
return z; |
} |
if(!finite(z)) { |
if(finite(x)&&finite(y)) { |
if(isnan(z)) |
return __kernel_standard(x,y,24); /* pow neg**non-int */ |
else |
return __kernel_standard(x,y,21); /* pow overflow */ |
} |
} |
if(z==0.0&&finite(x)&&finite(y)) |
return __kernel_standard(x,y,22); /* pow underflow */ |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_logf.c |
---|
0,0 → 1,97 |
/* e_logf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_logf.c,v 1.2 1995/05/30 05:48:32 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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 (ix < 0x00800000) { /* x < 2**-126 */ |
if ((ix&0x7fffffff)==0) |
return -two25/zero; /* log(+-0)=-inf */ |
if (ix<0) return (x-x)/zero; /* log(-#) = NaN */ |
k -= 25; x *= two25; /* subnormal number, scale up x */ |
GET_FLOAT_WORD(ix,x); |
} |
if (ix >= 0x7f800000) return x+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); |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_gammaf.c |
---|
0,0 → 1,39 |
/* e_gammaf.c -- float version of e_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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_gammaf.c,v 1.2 1995/05/30 05:48:14 rgrimes Exp $"; |
#endif |
/* __ieee754_gammaf(x) |
* Return the logarithm of the Gamma function of x. |
* |
* Method: call __ieee754_gammaf_r |
*/ |
#include "math.h" |
#include "math_private.h" |
extern int signgam; |
#ifdef __STDC__ |
float __ieee754_gammaf(float x) |
#else |
float __ieee754_gammaf(x) |
float x; |
#endif |
{ |
return __ieee754_gammaf_r(x,&signgam); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_acosh.c |
---|
0,0 → 1,69 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_acosh.c,v 1.2 1995/05/30 05:47:53 rgrimes Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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; |
u_int32_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+sqrt(t-one))); |
} else { /* 1<x<2 */ |
t = x-one; |
return log1p(t+sqrt(2.0*t+t*t)); |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_remain.c |
---|
0,0 → 1,42 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_remainder.c,v 1.2 1995/05/30 05:51:39 rgrimes Exp $"; |
#endif |
/* |
* wrapper remainder(x,p) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_remainder(x,y); |
if(_LIB_VERSION == _IEEE_ || isnan(y)) return z; |
if(y==0.0) |
return __kernel_standard(x,y,28); /* remainder(x,0) */ |
else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_rintf.c |
---|
0,0 → 1,77 |
/* s_rintf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_rintf.c,v 1.3 1996/08/28 16:34:36 bde Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
/* |
* TWO23 is double instead of float to avoid a bug in gcc. Without |
* this, gcc thinks that TWO23[sx]+x and w-TWO23[sx] already have float |
* precision and doesn't clip them to float precision when they are |
* assigned and returned. |
*/ |
#ifdef __STDC__ |
static const double |
#else |
static double |
#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; |
u_int32_t i,i1; |
float w,t; |
GET_FLOAT_WORD(i0,x); |
sx = (i0>>31)&1; |
j0 = ((i0>>23)&0xff)-0x7f; |
if(j0<23) { |
if(j0<0) { |
if((i0&0x7fffffff)==0) return x; |
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))|((0x100000)>>j0); |
} |
} else { |
if(j0==0x80) 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]; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_erff.c |
---|
0,0 → 1,223 |
/* s_erff.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_erff.c,v 1.2 1995/05/30 05:49:32 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#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(ix>=0x7f800000) { /* erf(nan)=nan */ |
i = ((u_int32_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(ix>=0x7f800000) { /* erfc(nan)=nan */ |
/* erfc(+-inf)=0,2 */ |
return (float)(((u_int32_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; |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_lgam3.c |
---|
0,0 → 1,248 |
/* e_lgammaf_r.c -- float version of e_lgamma_r.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_lgammaf_r.c,v 1.2 1995/05/30 05:48:29 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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; |
int 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 = (int) (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,p,p1,p2,p3,q,r,w; |
int 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 = (int)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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_atan2.c |
---|
0,0 → 1,130 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_atan2.c,v 1.3.2.1 1997/02/23 11:03:01 joerg Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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 __generic___ieee754_atan2(double y, double x) |
#else |
double __generic___ieee754_atan2(y,x) |
double y,x; |
#endif |
{ |
double z; |
int32_t k,m,hx,hy,ix,iy; |
u_int32_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: { |
u_int32_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(-,-) */ |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_hypotf.c |
---|
0,0 → 1,87 |
/* e_hypotf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_hypotf.c,v 1.2.6.1 1997/03/05 11:54:54 bde Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
float __ieee754_hypotf(float x, float y) |
#else |
float __ieee754_hypot(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 &= 0x7fffffff; |
GET_FLOAT_WORD(hb,y); |
hb &= 0x7fffffff; |
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)>0xf000000) {return a+b;} /* x/y > 2**30 */ |
k=0; |
if(ha > 0x58800000) { /* a>2**50 */ |
if(ha >= 0x7f800000) { /* Inf or NaN */ |
w = a+b; /* for sNaN */ |
if(ha == 0x7f800000) w = a; |
if(hb == 0x7f800000) w = b; |
return w; |
} |
/* scale a and b by 2**-68 */ |
ha -= 0x22000000; hb -= 0x22000000; k += 68; |
SET_FLOAT_WORD(a,ha); |
SET_FLOAT_WORD(b,hb); |
} |
if(hb < 0x26800000) { /* b < 2**-50 */ |
if(hb <= 0x007fffff) { /* subnormal b or 0 */ |
if(hb==0) return a; |
SET_FLOAT_WORD(t1,0x7e800000); /* 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&0xfffff000); |
t2 = a-t1; |
w = sqrtf(t1*t1-(b*(-b)-t2*(a+t1))); |
} else { |
a = a+a; |
SET_FLOAT_WORD(y1,hb&0xfffff000); |
y2 = b - y1; |
SET_FLOAT_WORD(t1,ha+0x00800000); |
t2 = a - t1; |
w = sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b))); |
} |
if(k!=0) { |
SET_FLOAT_WORD(t1,0x3f800000+(k<<23)); |
return t1*w; |
} else return w; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_rem_pi.c |
---|
0,0 → 1,183 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_rem_pio2.c,v 1.3 1995/05/30 05:48:37 rgrimes Exp $"; |
#endif |
/* __ieee754_rem_pio2(x,y) |
* |
* return the remainder of x rem pi/2 in y[0]+y[1] |
* use __kernel_rem_pio2() |
*/ |
#include "math.h" |
#include "math_private.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 |
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,w,t,r,fn; |
double tx[3]; |
int32_t e0,i,j,nx,n,ix,hx; |
u_int32_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 { |
u_int32_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 = (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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_next1.c |
---|
0,0 → 1,70 |
/* s_nextafterf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_nextafterf.c,v 1.2 1995/05/30 05:50:13 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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((ix>0x7f800000) || /* x is nan */ |
(iy>0x7f800000)) /* y is nan */ |
return x+y; |
if(x==y) return x; /* x=y, return x */ |
if(ix==0) { /* x == 0 */ |
SET_FLOAT_WORD(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) { /* 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>=0x7f800000) 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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_expm1f.c |
---|
0,0 → 1,133 |
/* s_expm1f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_expm1f.c,v 1.2 1995/05/30 05:49:34 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
static const float |
#else |
static float |
#endif |
one = 1.0, |
huge = 1.0e+30, |
tiny = 1.0e-30, |
o_threshold = 8.8721679688e+01,/* 0x42b17180 */ |
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; |
u_int32_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(hx >= 0x42b17218) { /* if |x|>=88.721... */ |
if(hx>0x7f800000) |
return x+x; /* NaN */ |
if(hx==0x7f800000) |
return (xsb==0)? x:-1.0;/* exp(+-inf)={inf,-1} */ |
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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_exp.c |
---|
0,0 → 1,53 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_exp.c,v 1.2 1995/05/30 05:50:58 rgrimes Exp $"; |
#endif |
/* |
* wrapper exp(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_exp(x); |
if(_LIB_VERSION == _IEEE_) return z; |
if(finite(x)) { |
if(x>o_threshold) |
return __kernel_standard(x,x,6); /* exp overflow */ |
else if(x<u_threshold) |
return __kernel_standard(x,x,7); /* exp underflow */ |
} |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_acosh.c |
---|
0,0 → 1,42 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_acosh.c,v 1.2 1995/05/30 05:50:39 rgrimes Exp $"; |
#endif |
/* |
* wrapper acosh(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_acosh(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(x<1.0) { |
return __kernel_standard(x,x,29); /* acosh(x<1) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_lgam3.c |
---|
0,0 → 1,51 |
/* w_lgammaf_r.c -- float version of w_lgamma_r.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_lgammaf_r.c,v 1.2 1995/05/30 05:51:32 rgrimes Exp $"; |
#endif |
/* |
* wrapper float lgammaf_r(float x, int *signgamp) |
*/ |
#include "math.h" |
#include "math_private.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; |
y = __ieee754_lgammaf_r(x,signgamp); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finitef(y)&&finitef(x)) { |
if(floorf(x)==x&&x<=(float)0.0) |
/* lgamma pole */ |
return (float)__kernel_standard((double)x,(double)x,115); |
else |
/* lgamma overflow */ |
return (float)__kernel_standard((double)x,(double)x,114); |
} else |
return y; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_signga.c |
---|
0,0 → 1,3 |
#include "math.h" |
#include "math_private.h" |
int signgam = 0; |
/shark/trunk/libc/arch/x86/libm/msun/src/w_atan2.c |
---|
0,0 → 1,43 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_atan2.c,v 1.2 1995/05/30 05:50:43 rgrimes Exp $"; |
#endif |
/* |
* wrapper atan2(y,x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
double atan2(double y, double x) /* wrapper atan2 */ |
#else |
double atan2(y,x) /* wrapper atan2 */ |
double y,x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_atan2(y,x); |
#else |
double z; |
z = __ieee754_atan2(y,x); |
if(_LIB_VERSION == _IEEE_||isnan(x)||isnan(y)) return z; |
if(x==0.0&&y==0.0) { |
return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_sqrt.c |
---|
0,0 → 1,453 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_sqrt.c,v 1.2.6.1 1997/02/23 11:03:09 joerg Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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 __generic___ieee754_sqrt(double x) |
#else |
double __generic___ieee754_sqrt(x) |
double x; |
#endif |
{ |
double z; |
int32_t sign = (int)0x80000000; |
int32_t ix0,s0,q,m,t,i; |
u_int32_t r,t1,s1,ix1,q1; |
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==(u_int32_t)0xffffffff) { q1=0; q += 1;} |
else if (z>one) { |
if (q1==(u_int32_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; |
} |
/* |
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). |
*/ |
/shark/trunk/libc/arch/x86/libm/msun/src/w_j1.c |
---|
0,0 → 1,42 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_j1.c,v 1.2.6.1 1997/03/03 14:21:05 bde Exp $"; |
#endif |
/* |
* wrapper of j1 |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_j1(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; |
if(fabs(x)>X_TLOSS) { |
return __kernel_standard(x,x,36); /* j1(|x|>X_TLOSS) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_significand.c,v 1.2.6.1 1997/02/23 11:03:22 joerg Exp $"; |
#endif |
/* |
* significand(x) computes just |
* scalb(x, (double) -ilogb(x)), |
* for exercising the fraction-part(F) IEEE 754-1985 test vector. |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
double __generic_significand(double x) |
#else |
double __generic_significand(x) |
double x; |
#endif |
{ |
return __ieee754_scalb(x,(double) -ilogb(x)); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/k_cosf.c |
---|
0,0 → 1,64 |
/* k_cosf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: k_cosf.c,v 1.2 1995/05/30 05:48:55 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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)); |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_j1f.c |
---|
0,0 → 1,46 |
/* w_j1f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_j1f.c,v 1.2.6.1 1997/03/03 14:21:06 bde Exp $"; |
#endif |
/* |
* wrapper of j1f |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_j1f(x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; |
if(fabsf(x)>(float)X_TLOSS) { |
/* j1(|x|>X_TLOSS) */ |
return (float)__kernel_standard((double)x,(double)x,136); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_frexp.c |
---|
0,0 → 1,59 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_frexp.c,v 1.3 1995/05/30 05:49:41 rgrimes Exp $"; |
#endif |
/* |
* 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 "math.h" |
#include "math_private.h" |
#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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_hypot.c,v 1.2 1995/05/30 05:48:16 rgrimes Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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 */ |
u_int32_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 */ |
u_int32_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 = 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 = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b))); |
} |
if(k!=0) { |
u_int32_t high; |
t1 = 1.0; |
GET_HIGH_WORD(high,t1); |
SET_HIGH_WORD(t1,high+(k<<20)); |
return t1*w; |
} else return w; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_acoshf.c |
---|
0,0 → 1,57 |
/* e_acoshf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_acoshf.c,v 1.2 1995/05/30 05:47:54 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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(hx >=0x7f800000) { /* 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+sqrtf(t-one))); |
} else { /* 1<x<2 */ |
t = x-one; |
return log1pf(t+sqrtf((float)2.0*t+t*t)); |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_sinhf.c |
---|
0,0 → 1,68 |
/* e_sinhf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_sinhf.c,v 1.2 1995/05/30 05:48:49 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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(ix>=0x7f800000) 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 < 0x42b17180) return h*__ieee754_expf(fabsf(x)); |
/* |x| in [log(maxdouble), overflowthresold] */ |
if (ix<=0x42b2d4fc) { |
w = __ieee754_expf((float)0.5*fabsf(x)); |
t = h*w; |
return t*w; |
} |
/* |x| > overflowthresold, sinh(x) overflow */ |
return x*shuge; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_acos.c |
---|
0,0 → 1,43 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_acos.c,v 1.2 1995/05/30 05:50:37 rgrimes Exp $"; |
#endif |
/* |
* wrap_acos(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_acos(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabs(x)>1.0) { |
return __kernel_standard(x,x,1); /* acos(|x|>1) */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_cosf.c |
---|
0,0 → 1,59 |
/* s_cosf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_cosf.c,v 1.2 1995/05/30 05:49:30 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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 (ix>=0x7f800000) 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); |
} |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_atan2f.c |
---|
0,0 → 1,105 |
/* e_atan2f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_atan2f.c,v 1.2 1995/05/30 05:47:59 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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.1415925026e+00, /* 0x40490fda */ |
pi_lo = 1.5099578832e-07; /* 0x34222168 */ |
#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((ix>0x7f800000)|| |
(iy>0x7f800000)) /* 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(iy==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==0) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; |
/* when x is INF */ |
if(ix==0x7f800000) { |
if(iy==0x7f800000) { |
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(iy==0x7f800000) 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: { |
u_int32_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(-,-) */ |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_cosh.c |
---|
0,0 → 1,42 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_cosh.c,v 1.2 1995/05/30 05:50:49 rgrimes Exp $"; |
#endif |
/* |
* wrapper cosh(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_cosh(x); |
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
if(fabs(x)>7.10475860073943863426e+02) { |
return __kernel_standard(x,x,5); /* cosh overflow */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_j0f.c |
---|
0,0 → 1,444 |
/* e_j0f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_j0f.c,v 1.2 1995/05/30 05:48:19 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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(ix>=0x7f800000) 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<0x7f000000) { /* 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)/sqrtf(x); |
else { |
u = pzerof(x); v = qzerof(x); |
z = invsqrtpi*(u*cc-v*ss)/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(ix>=0x7f800000) return one/(x+x*x); |
if(ix==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 = 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<0x7f000000) { /* 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)/sqrtf(x); |
else { |
u = pzerof(x); v = qzerof(x); |
z = invsqrtpi*(u*ss+v*cc)/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 if(ix>=0x40000000){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 pzero 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 if(ix>=0x40000000){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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_scalbn.c |
---|
0,0 → 1,66 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_scalbn.c,v 1.2.6.1 1997/02/23 11:03:21 joerg Exp $"; |
#endif |
/* |
* 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 "math.h" |
#include "math_private.h" |
#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 __generic_scalbn (double x, int n) |
#else |
double __generic_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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_asinh.c |
---|
0,0 → 1,65 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_asinh.c,v 1.2 1995/05/30 05:49:18 rgrimes Exp $"; |
#endif |
/* 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 "math.h" |
#include "math_private.h" |
#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/(sqrt(x*x+one)+t)); |
} else { /* 2.0 > |x| > 2**-28 */ |
t = x*x; |
w =log1p(fabs(x)+t/(one+sqrt(one+t))); |
} |
if(hx>0) return w; else return -w; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_gamma_.c |
---|
0,0 → 1,35 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_gamma_r.c,v 1.2 1995/05/30 05:48:13 rgrimes Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.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_lgamma_r(x,signgamp); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_gamma.c |
---|
0,0 → 1,37 |
/* @(#)e_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. |
* ==================================================== |
* |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_gamma.c,v 1.2 1995/05/30 05:48:12 rgrimes Exp $"; |
#endif |
/* __ieee754_gamma(x) |
* Return the logarithm of the Gamma function of x. |
* |
* Method: call __ieee754_gamma_r |
*/ |
#include "math.h" |
#include "math_private.h" |
extern int signgam; |
#ifdef __STDC__ |
double __ieee754_gamma(double x) |
#else |
double __ieee754_gamma(x) |
double x; |
#endif |
{ |
return __ieee754_gamma_r(x,&signgam); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_hypot.c |
---|
0,0 → 1,43 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_hypot.c,v 1.2 1995/05/30 05:51:13 rgrimes Exp $"; |
#endif |
/* |
* wrapper hypot(x,y) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_hypot(x,y); |
if(_LIB_VERSION == _IEEE_) return z; |
if((!finite(z))&&finite(x)&&finite(y)) |
return __kernel_standard(x,y,4); /* hypot overflow */ |
else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_sinhf.c |
---|
0,0 → 1,46 |
/* w_sinhf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_sinhf.c,v 1.2 1995/05/30 05:51:44 rgrimes Exp $"; |
#endif |
/* |
* wrapper sinhf(x) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_sinhf(x); |
if(_LIB_VERSION == _IEEE_) return z; |
if(!finitef(z)&&finitef(x)) { |
/* sinhf overflow */ |
return (float)__kernel_standard((double)x,(double)x,125); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_rint.c |
---|
0,0 → 1,93 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_rint.c,v 1.3.2.1 1997/02/23 11:03:20 joerg Exp $"; |
#endif |
/* |
* rint(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 rint(x). |
*/ |
#include "math.h" |
#include "math_private.h" |
/* |
* TWO23 is long double instead of double to avoid a bug in gcc. Without |
* this, gcc thinks that TWO23[sx]+x and w-TWO23[sx] already have double |
* precision and doesn't clip them to double precision when they are |
* assigned and returned. Use long double even in the !__STDC__ case in |
* case this is compiled with gcc -traditional. |
*/ |
#ifdef __STDC__ |
static const long double |
#else |
static long double |
#endif |
TWO52[2]={ |
4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ |
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ |
}; |
#ifdef __STDC__ |
double __generic_rint(double x) |
#else |
double __generic_rint(x) |
double x; |
#endif |
{ |
int32_t i0,j0,sx; |
u_int32_t i,i1; |
double w,t; |
EXTRACT_WORDS(i0,i1,x); |
sx = (i0>>31)&1; |
j0 = ((i0>>20)&0x7ff)-0x3ff; |
if(j0<20) { |
if(j0<0) { |
if(((i0&0x7fffffff)|i1)==0) return x; |
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 { |
i = (0x000fffff)>>j0; |
if(((i0&i)|i1)==0) return x; /* x is integral */ |
i>>=1; |
if(((i0&i)|i1)!=0) { |
if(j0==19) i1 = 0x40000000; else |
i0 = (i0&(~i))|((0x20000)>>j0); |
} |
} |
} else if (j0>51) { |
if(j0==0x400) return x+x; /* inf or NaN */ |
else return x; /* x is integral */ |
} else { |
i = ((u_int32_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]; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_erf.c |
---|
0,0 → 1,314 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_erf.c,v 1.2 1995/05/30 05:49:31 rgrimes Exp $"; |
#endif |
/* 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 "math.h" |
#include "math_private.h" |
#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 = ((u_int32_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)(((u_int32_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; |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_jnf.c |
---|
0,0 → 1,42 |
/* w_jnf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_jnf.c,v 1.2.6.1 1997/03/03 14:21:08 bde Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_jnf(n,x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; |
if(fabsf(x)>(float)X_TLOSS) { |
/* jn(|x|>X_TLOSS,n) */ |
return (float)__kernel_standard((double)n,(double)x,138); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_cabsf.c |
---|
0,0 → 1,21 |
/* |
* cabsf() wrapper for hypotf(). |
* |
* Written by J.T. Conklin, <jtc@wimsey.com> |
* Placed into the Public Domain, 1994. |
*/ |
#include "math.h" |
#include "math_private.h" |
struct complex { |
float x; |
float y; |
}; |
float |
cabsf(z) |
struct complex z; |
{ |
return hypotf(z.x, z.y); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_logb.c |
---|
0,0 → 1,42 |
/* @(#)s_logb.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_logb.c,v 1.2.6.1 1997/02/23 11:03:20 joerg Exp $"; |
#endif |
/* |
* double logb(x) |
* IEEE 754 logb. Included to pass IEEE test suite. Not recommend. |
* Use ilogb instead. |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
double __generic_logb(double x) |
#else |
double __generic_logb(x) |
double x; |
#endif |
{ |
int32_t lx,ix; |
EXTRACT_WORDS(ix,lx,x); |
ix &= 0x7fffffff; /* high |x| */ |
if((ix|lx)==0) return -1.0/fabs(x); |
if(ix>=0x7ff00000) return x*x; |
if((ix>>=20)==0) /* IEEE 754 logb */ |
return -1022.0; |
else |
return (double) (ix-1023); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_gamma.c |
---|
0,0 → 1,49 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_gamma.c,v 1.2 1995/05/30 05:51:04 rgrimes Exp $"; |
#endif |
/* double gamma(double x) |
* Return the logarithm of the Gamma function of x. |
* |
* Method: call gamma_r |
*/ |
#include "math.h" |
#include "math_private.h" |
extern int signgam; |
#ifdef __STDC__ |
double gamma(double x) |
#else |
double gamma(x) |
double x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_gamma_r(x,&signgam); |
#else |
double y; |
y = __ieee754_gamma_r(x,&signgam); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finite(y)&&finite(x)) { |
if(floor(x)==x&&x<=0.0) |
return __kernel_standard(x,x,41); /* gamma pole */ |
else |
return __kernel_standard(x,x,40); /* gamma overflow */ |
} else |
return y; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/k_sinf.c |
---|
0,0 → 1,54 |
/* k_sinf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: k_sinf.c,v 1.2 1995/05/30 05:49:10 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_atanf.c |
---|
0,0 → 1,119 |
/* s_atanf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_atanf.c,v 1.2 1995/05/30 05:49:22 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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(ix>0x7f800000) |
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; |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_jn.c,v 1.3 1995/05/30 05:48:24 rgrimes Exp $"; |
#endif |
/* |
* __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 "math.h" |
#include "math_private.h" |
#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|((u_int32_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/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|((u_int32_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/sqrt(x); |
} else { |
u_int32_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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_gammaf.c |
---|
0,0 → 1,48 |
/* 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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_gammaf.c,v 1.2 1995/05/30 05:51:10 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
extern int signgam; |
#ifdef __STDC__ |
float gammaf(float x) |
#else |
float gammaf(x) |
float x; |
#endif |
{ |
#ifdef _IEEE_LIBM |
return __ieee754_gammaf_r(x,&signgam); |
#else |
float y; |
y = __ieee754_gammaf_r(x,&signgam); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finitef(y)&&finitef(x)) { |
if(floorf(x)==x&&x<=(float)0.0) |
/* gammaf pole */ |
return (float)__kernel_standard((double)x,(double)x,141); |
else |
/* gammaf overflow */ |
return (float)__kernel_standard((double)x,(double)x,140); |
} else |
return y; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_sinf.c |
---|
0,0 → 1,53 |
/* s_sinf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_sinf.c,v 1.2 1995/05/30 05:50:32 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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 (ix>=0x7f800000) 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]); |
} |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_cbrtf.c |
---|
0,0 → 1,83 |
/* s_cbrtf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_cbrtf.c,v 1.2 1995/05/30 05:49:23 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
/* cbrtf(x) |
* Return cube root of x |
*/ |
#ifdef __STDC__ |
static const unsigned |
#else |
static unsigned |
#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 |
{ |
float r,s,t; |
int32_t hx; |
u_int32_t sign; |
u_int32_t high; |
GET_FLOAT_WORD(hx,x); |
sign=hx&0x80000000; /* sign= sign(x) */ |
hx ^=sign; |
if(hx>=0x7f800000) return(x+x); /* cbrt(NaN,INF) is itself */ |
if(hx==0) |
return(x); /* cbrt(0) is itself */ |
SET_FLOAT_WORD(x,hx); /* x <- |x| */ |
/* rough cbrt to 5 bits */ |
if(hx<0x00800000) /* 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); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_log.c,v 1.2.6.1 1997/02/23 11:03:05 joerg Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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 __generic___ieee754_log(double x) |
#else |
double __generic___ieee754_log(x) |
double x; |
#endif |
{ |
double hfsq,f,s,z,R,w,t1,t2,dk; |
int32_t k,hx,i,j; |
u_int32_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); |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_sinh.c |
---|
0,0 → 1,42 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_sinh.c,v 1.2 1995/05/30 05:51:43 rgrimes Exp $"; |
#endif |
/* |
* wrapper sinh(x) |
*/ |
#include "math.h" |
#include "math_private.h" |
#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; |
z = __ieee754_sinh(x); |
if(_LIB_VERSION == _IEEE_) return z; |
if(!finite(z)&&finite(x)) { |
return __kernel_standard(x,x,25); /* sinh overflow */ |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_scalb.c,v 1.2.6.1 1997/02/23 11:03:08 joerg Exp $"; |
#endif |
/* |
* __ieee754_scalb(x, fn) is provide for |
* passing various standard test suite. One |
* should use scalbn() instead. |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef _SCALB_INT |
#ifdef __STDC__ |
double __generic___ieee754_scalb(double x, int fn) |
#else |
double __generic___ieee754_scalb(x,fn) |
double x; int fn; |
#endif |
#else |
#ifdef __STDC__ |
double __generic___ieee754_scalb(double x, double fn) |
#else |
double __generic___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 |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_fini1.c |
---|
0,0 → 1,38 |
/* s_finitef.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_finitef.c,v 1.2 1995/05/30 05:49:38 rgrimes Exp $"; |
#endif |
/* |
* finitef(x) returns 1 is x is finite, else 0; |
* no branching! |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
int finitef(float x) |
#else |
int finitef(x) |
float x; |
#endif |
{ |
int32_t ix; |
GET_FLOAT_WORD(ix,x); |
return (int)((u_int32_t)((ix&0x7fffffff)-0x7f800000)>>31); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_expf.c |
---|
0,0 → 1,58 |
/* w_expf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_expf.c,v 1.2 1995/05/30 05:51:00 rgrimes Exp $"; |
#endif |
/* |
* wrapper expf(x) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_expf(x); |
if(_LIB_VERSION == _IEEE_) return z; |
if(finitef(x)) { |
if(x>o_threshold) |
/* exp overflow */ |
return (float)__kernel_standard((double)x,(double)x,106); |
else if(x<u_threshold) |
/* exp underflow */ |
return (float)__kernel_standard((double)x,(double)x,107); |
} |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_copysi.c |
---|
0,0 → 1,38 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_copysign.c,v 1.2.6.1 1997/02/23 11:03:16 joerg Exp $"; |
#endif |
/* |
* copysign(double x, double y) |
* copysign(x,y) returns a value with the magnitude of x and |
* with the sign bit of y. |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
double __generic_copysign(double x, double y) |
#else |
double __generic_copysign(x,y) |
double x,y; |
#endif |
{ |
u_int32_t hx,hy; |
GET_HIGH_WORD(hx,x); |
GET_HIGH_WORD(hy,y); |
SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000)); |
return x; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_acos.c,v 1.2.6.1 1997/02/23 11:02:58 joerg Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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 __generic___ieee754_acos(double x) |
#else |
double __generic___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 */ |
u_int32_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 = 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 = 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); |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_rem1.c |
---|
0,0 → 1,46 |
/* w_remainderf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_remainderf.c,v 1.2 1995/05/30 05:51:40 rgrimes Exp $"; |
#endif |
/* |
* wrapper remainderf(x,p) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_remainderf(x,y); |
if(_LIB_VERSION == _IEEE_ || isnanf(y)) return z; |
if(y==(float)0.0) |
/* remainder(x,0) */ |
return (float)__kernel_standard((double)x,(double)y,128); |
else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_isnan.c |
---|
0,0 → 1,39 |
/* @(#)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. |
* ==================================================== |
*/ |
#if 0 |
#ifndef lint |
static char rcsid[] = "$\Id: s_isnan.c,v 1.2 1995/05/30 05:49:47 rgrimes Exp $"; |
#endif |
/* |
* isnan(x) returns 1 is x is nan, else 0; |
* no branching! |
*/ |
#include "math.h" |
#include "math_private.h" |
#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 |= (u_int32_t)(lx|(-lx))>>31; |
hx = 0x7ff00000 - hx; |
return (int)((u_int32_t)(hx))>>31; |
} |
#endif |
/shark/trunk/libc/arch/x86/libm/msun/src/e_log10f.c |
---|
0,0 → 1,67 |
/* e_log10f.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_log10f.c,v 1.3 1995/05/30 05:48:31 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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 (hx < 0x00800000) { /* x < 2**-126 */ |
if ((hx&0x7fffffff)==0) |
return -two25/zero; /* log(+-0)=-inf */ |
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */ |
k -= 25; x *= two25; /* subnormal number, scale up x */ |
GET_FLOAT_WORD(hx,x); |
} |
if (hx >= 0x7f800000) return x+x; |
k += (hx>>23)-127; |
i = ((u_int32_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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/k_tan.c |
---|
0,0 → 1,131 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: k_tan.c,v 1.2 1995/05/30 05:49:14 rgrimes Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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 */ |
u_int32_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); |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: k_cos.c,v 1.2 1995/05/30 05:48:53 rgrimes Exp $"; |
#endif |
/* |
* __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 "math.h" |
#include "math_private.h" |
#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)); |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_scalbf.c |
---|
0,0 → 1,52 |
/* e_scalbf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_scalbf.c,v 1.2 1995/05/30 05:48:45 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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 (isnanf(x)||isnanf(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 ( fn > (float)65000.0) return scalbnf(x, 65000); |
if (-fn > (float)65000.0) return scalbnf(x,-65000); |
return scalbnf(x,(int)fn); |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_hypotf.c |
---|
0,0 → 1,47 |
/* w_hypotf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_hypotf.c,v 1.2 1995/05/30 05:51:15 rgrimes Exp $"; |
#endif |
/* |
* wrapper hypotf(x,y) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_hypotf(x,y); |
if(_LIB_VERSION == _IEEE_) return z; |
if((!finitef(z))&&finitef(x)&&finitef(y)) |
/* hypot overflow */ |
return (float)__kernel_standard((double)x,(double)y,104); |
else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_gamf1.c |
---|
0,0 → 1,38 |
/* e_gammaf_r.c -- float version of e_gamma_r.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_gammaf_r.c,v 1.2 1995/05/30 05:48:15 rgrimes Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.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_lgammaf_r(x,signgamp); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_cosh.c,v 1.3 1996/07/12 18:57:52 jkh Exp $"; |
#endif |
/* __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 "math.h" |
#include "math_private.h" |
#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; |
u_int32_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<=(u_int32_t)0x8fb9f87d))) { |
w = __ieee754_exp(half*fabs(x)); |
t = half*w; |
return t*w; |
} |
/* |x| > overflowthresold, cosh(x) overflow */ |
return huge*huge; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_powf.c |
---|
0,0 → 1,72 |
/* w_powf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_powf.c,v 1.2 1995/05/30 05:51:38 rgrimes Exp $"; |
#endif |
/* |
* wrapper powf(x,y) return x**y |
*/ |
#include "math.h" |
#include "math_private.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; |
z=__ieee754_powf(x,y); |
if(_LIB_VERSION == _IEEE_|| isnanf(y)) return z; |
if(isnanf(x)) { |
if(y==(float)0.0) |
/* powf(NaN,0.0) */ |
return (float)__kernel_standard((double)x,(double)y,142); |
else |
return z; |
} |
if(x==(float)0.0){ |
if(y==(float)0.0) |
/* powf(0.0,0.0) */ |
return (float)__kernel_standard((double)x,(double)y,120); |
if(finitef(y)&&y<(float)0.0) |
/* powf(0.0,negative) */ |
return (float)__kernel_standard((double)x,(double)y,123); |
return z; |
} |
if(!finitef(z)) { |
if(finitef(x)&&finitef(y)) { |
if(isnanf(z)) |
/* powf neg**non-int */ |
return (float)__kernel_standard((double)x,(double)y,124); |
else |
/* powf overflow */ |
return (float)__kernel_standard((double)x,(double)y,121); |
} |
} |
if(z==(float)0.0&&finitef(x)&&finitef(y)) |
/* powf underflow */ |
return (float)__kernel_standard((double)x,(double)y,122); |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_tan.c |
---|
0,0 → 1,76 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_tan.c,v 1.2.6.1 1997/02/23 11:03:23 joerg Exp $"; |
#endif |
/* 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 "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
double __generic_tan(double x) |
#else |
double __generic_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 */ |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_cos.c,v 1.2.6.1 1997/02/23 11:03:17 joerg Exp $"; |
#endif |
/* 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 "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
double __generic_cos(double x) |
#else |
double __generic_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); |
} |
} |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_coshf.c |
---|
0,0 → 1,71 |
/* e_coshf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_coshf.c,v 1.2 1995/05/30 05:48:07 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.h" |
#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(ix>=0x7f800000) 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 < 0x42b17180) return half*__ieee754_expf(fabsf(x)); |
/* |x| in [log(maxdouble), overflowthresold] */ |
if (ix<=0x42b2d4fc) { |
w = __ieee754_expf(half*fabsf(x)); |
t = half*w; |
return t*w; |
} |
/* |x| > overflowthresold, cosh(x) overflow */ |
return huge*huge; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_nextaf.c |
---|
0,0 → 1,79 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_nextafter.c,v 1.2 1995/05/30 05:50:11 rgrimes Exp $"; |
#endif |
/* IEEE functions |
* nextafter(x,y) |
* return the next machine floating-point number of x in the |
* direction toward y. |
* Special cases: |
*/ |
#include "math.h" |
#include "math_private.h" |
#ifdef __STDC__ |
double nextafter(double x, double y) |
#else |
double nextafter(x,y) |
double x,y; |
#endif |
{ |
int32_t hx,hy,ix,iy; |
u_int32_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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/e_pow.c |
---|
0,0 → 1,312 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: e_pow.c,v 1.2 1995/05/30 05:48:34 rgrimes Exp $"; |
#endif |
/* __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 muti-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 |
* 3. (anything) ** NAN is NAN |
* 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 NAN |
* 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 "math.h" |
#include "math_private.h" |
#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; |
u_int32_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; |
/* +-NaN return x+y */ |
if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || |
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) |
return x+y; |
/* 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 y - y; /* inf**+-1 is NaN */ |
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 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 */ |
/* CYGNUS 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(((((u_int32_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 = x-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(((((u_int32_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,n); /* subnormal output */ |
else SET_HIGH_WORD(z,j); |
return s*z; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_log1pf.c |
---|
0,0 → 1,112 |
/* s_log1pf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_log1pf.c,v 1.2 1995/05/30 05:49:58 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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 (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 (hx >= 0x7f800000) return x+x; |
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); |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_tanh.c |
---|
0,0 → 1,86 |
/* @(#)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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_tanh.c,v 1.2 1995/05/30 05:50:35 rgrimes Exp $"; |
#endif |
/* 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 "math.h" |
#include "math_private.h" |
#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; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_gamf1.c |
---|
0,0 → 1,51 |
/* w_gammaf_r.c -- float version of w_gamma_r.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_gammaf_r.c,v 1.2 1995/05/30 05:51:12 rgrimes Exp $"; |
#endif |
/* |
* wrapper float gammaf_r(float x, int *signgamp) |
*/ |
#include "math.h" |
#include "math_private.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; |
y = __ieee754_gammaf_r(x,signgamp); |
if(_LIB_VERSION == _IEEE_) return y; |
if(!finitef(y)&&finitef(x)) { |
if(floorf(x)==x&&x<=(float)0.0) |
/* gammaf pole */ |
return (float)__kernel_standard((double)x,(double)x,141); |
else |
/* gamma overflow */ |
return (float)__kernel_standard((double)x,(double)x,140); |
} else |
return y; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/s_ilogbf.c |
---|
0,0 → 1,43 |
/* s_ilogbf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: s_ilogbf.c,v 1.2 1995/05/30 05:49:46 rgrimes Exp $"; |
#endif |
#include "math.h" |
#include "math_private.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(hx<0x00800000) { |
if(hx==0) |
return 0x80000001; /* ilogb(0) = 0x80000001 */ |
else /* subnormal x */ |
for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1; |
return ix; |
} |
else if (hx<0x7f800000) return (hx>>23)-127; |
else return 0x7fffffff; |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_coshf.c |
---|
0,0 → 1,46 |
/* w_coshf.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. |
* ==================================================== |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_coshf.c,v 1.2 1995/05/30 05:50:53 rgrimes Exp $"; |
#endif |
/* |
* wrapper coshf(x) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_coshf(x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; |
if(fabsf(x)>(float)8.9415985107e+01) { |
/* cosh overflow */ |
return (float)__kernel_standard((double)x,(double)x,105); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/src/w_acoshf.c |
---|
0,0 → 1,47 |
/* w_acoshf.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. |
* ==================================================== |
* |
*/ |
#ifndef lint |
static char rcsid[] = "$\Id: w_acoshf.c,v 1.2 1995/05/30 05:50:40 rgrimes Exp $"; |
#endif |
/* |
* wrapper acoshf(x) |
*/ |
#include "math.h" |
#include "math_private.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; |
z = __ieee754_acoshf(x); |
if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; |
if(x<(float)1.0) { |
/* acosh(x<1) */ |
return (float)__kernel_standard((double)x,(double)x,129); |
} else |
return z; |
#endif |
} |
/shark/trunk/libc/arch/x86/libm/msun/Makefile |
---|
0,0 → 1,2 |
targets:= i387/ src/ |
/shark/trunk/libc/arch/x86/libm/machine/Makefile |
---|
0,0 → 1,2 |
targets:= stub.o |
/shark/trunk/libc/arch/x86/libm/machine/infinity.c |
---|
0,0 → 1,26 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/math.h> |
/* bytes for +Infinity on a 387 */ |
char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; |
/shark/trunk/libc/arch/x86/libm/machine/stub.c |
---|
0,0 → 1,64 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <ll/i386/cons.h> |
#include <arch/stdlib.h> |
#include <ll/sys/types.h> |
/* bytes for +Infinity on a 387 */ |
char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; |
static int (*__errnumber)(void) = NULL; |
static int errno; |
int *__errnumber1() |
{ |
if (__errnumber == NULL) { |
return &errno; |
} |
return (void *)__errnumber(); |
} |
void seterrnumber(int (*e)(void)) |
{ |
__errnumber = e; |
} |
int isnan(double d) |
{ |
register struct IEEEdp { |
u_int manl : 32; |
u_int manh : 20; |
u_int exp : 11; |
u_int sign : 1; |
} *p = (struct IEEEdp *)&d; |
return(p->exp == 2047 && (p->manh || p->manl)); |
} |
/* By Luca.... The write stub */ |
int write(int a, char *b, int c) |
{ |
b[c] = 0; |
cputs(b); |
return c; |
} |
/shark/trunk/libc/arch/x86/libm/machine/defs.h |
---|
0,0 → 1,75 |
/*- |
* Copyright (c) 1990 The Regents of the University of California. |
* All rights reserved. |
* |
* This code is derived from software contributed to Berkeley by |
* William Jolitz. |
* |
* 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. |
* |
* from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 |
* |
* $\Id: DEFS.h,v 1.3.2.1 1997/02/14 11:08:46 bde Exp $ |
*/ |
/* |
* Just enough to avoid changing too much source code ... |
*/ |
#include <ll/i386/linkage.h> |
#ifdef __LINUX__ |
# define P2ALIGN(p2) .align (1<<(p2)) |
#else |
# define P2ALIGN(p2) .align p2 |
#endif |
#ifdef __LINUX__ |
#define FUNCSYM(x) .type x,@function |
#else |
#define FUNCSYM(x) /* nothing */ |
#endif |
#define TEXT_ALIGN 4 |
#define ENTRY(x) FUNCSYM(x); .globl SYMBOL_NAME(x); P2ALIGN(TEXT_ALIGN); SYMBOL_NAME_LABEL(x) |
/* |
#define ENTRY2(x,y) .globl SYMBOL_NAME(x); .globl SYMBOL_NAME(y); \ |
P2ALIGN(TEXT_ALIGN); LEXT(x) LEXT(y) |
#define ASENTRY(x) .globl x; P2ALIGN(TEXT_ALIGN); gLB(x) |
*/ |
#define CNAME(x) SYMBOL_NAME(x) |
/* |
* No PIC at the moment. |
*/ |
#define PIC_PROLOGUE |
#define PIC_EPILOGUE |
#define PIC_PLT(x) x |
/shark/trunk/libc/arch/x86/libm/machine/asmacros.h |
---|
0,0 → 1,31 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#ifndef _MACHINE_ASMACROS_H_ |
#define _MACHINE_ASMACROS_H_ |
#include "defs.h" /* Now it's OK... Luca :) */ |
#ifndef RCSID |
#define RCSID(a) |
#endif |
#endif /* !_MACHINE_ASMACROS_H_ */ |
/shark/trunk/libc/arch/x86/libm/Makefile |
---|
0,0 → 1,5 |
targets:= msun/ machine/ |
exported-aflags:= -I$(curdir) |
exported-cppflags:= -I$(curdir) |
/shark/trunk/libc/arch/x86/stdlib/Makefile |
---|
0,0 → 1,7 |
targets:= \ |
random.o \ |
stdlib.o \ |
strtod.o \ |
strtoi.o \ |
strtou.o |
/shark/trunk/libc/arch/x86/stdlib/strtod.c |
---|
0,0 → 1,89 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/string.h> |
#include <arch/i386/limits.h> |
#include <arch/stdarg.h> |
#include <arch/ctype.h> |
#include <arch/math.h> |
FILE(strod); |
double strtod(char *s,char **scan_end) |
{ |
int sign,i; |
double result = 0; |
double value; |
double mantissa = 0,divisor = 1; |
unsigned short power = 0; |
/* Evaluate sign */ |
if (*s == '-') { |
sign = -1; |
s++; |
} |
else sign = 1; |
/* Skip trailing zeros */ |
while (*s == '0') s++; |
/* Convert integer part */ |
while (*s <= '9' && *s >= '0') { |
value = *s++ - '0'; |
result *= 10.0; |
result += value; |
} |
/* Detect floating point & mantissa */ |
if (*s == '.') { |
s++; |
while (*s <= '9' && *s >= '0') { |
value = *s++ - '0'; |
mantissa *= 10.0; |
mantissa += value; |
divisor *= 10.0; |
} |
} |
mantissa /= divisor; |
/* Adjust result */ |
result += mantissa; |
/* Adjust sign */ |
result *= sign; |
/* Detect exponent */ |
if (*s == 'e' || *s == 'E') { |
s++; |
if (*s == '-') { |
sign = -1; |
s++; |
} else if (*s == '+') { |
sign = 1; |
s++; |
} |
else sign = 1; |
while (*s <= '9' && *s >= '0') { |
value = *s++ - '0'; |
power *= 10.0; |
power += value; |
} |
} |
/* Adjust result on exponent sign */ |
if (sign > 0) for (i = 0; i < power; i++) result *= 10.0; |
else for (i = 0; i < power; i++) result /= 10.0; |
if (scan_end != 0L) *scan_end = s; |
return(result); |
} |
/shark/trunk/libc/arch/x86/stdlib/random.c |
---|
0,0 → 1,46 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/math.h> |
FILE(random); |
#define MODULUS 2147483647L |
#define FACTOR 16807L |
#define DIVISOR 127773L |
#define REMAINDER 2836L |
static long int last_val; |
long int rand(void) |
{ |
long int last_div = last_val / DIVISOR; |
long int last_rem = last_val % DIVISOR; |
last_val = (FACTOR * last_rem) - (REMAINDER * last_div); |
if (last_val < 0) last_val += MODULUS; |
return(last_val); |
} |
void srand(long int seed) |
{ |
last_val = seed; |
} |
/shark/trunk/libc/arch/x86/stdlib/strtou.c |
---|
0,0 → 1,55 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/string.h> |
#include <arch/i386/limits.h> |
#include <arch/stdarg.h> |
#include <arch/ctype.h> |
FILE(strtou); |
long unsigned strtou(char *s,int base,char **scan_end) |
{ |
int value,overflow = 0; |
long unsigned result = 0,oldresult; |
/* Skip trailing zeros */ |
while (*s == '0') s++; |
if (*s == 'x' && base == 16) { |
s++; |
while (*s == '0') s++; |
} |
/* Convert number */ |
while (isnumber(*s,base)) { |
value = tonumber(*s++); |
if (value > base || value < 0) return(0); |
oldresult = result; |
result *= base; |
result += value; |
/* Detect overflow */ |
if (oldresult > result) overflow = 1; |
} |
if (scan_end != 0L) *scan_end = s; |
if (overflow) result = INT_MAX; |
return(result); |
} |
/shark/trunk/libc/arch/x86/stdlib/stdlib.c |
---|
0,0 → 1,76 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <ll/i386/hw-func.h> |
#include <arch/i386/stdlib.h> |
#include <arch/unistd.h> |
FILE(stdlib); |
int ll_exit_mode = EXIT_MODE_REAL; |
unsigned abs(int x) |
{ |
if (x < 0) return(-x); |
else return(x); |
} |
int ll_set_reboot(int mode) |
{ |
switch(mode) { |
case EXIT_MODE_HALT: |
ll_exit_mode = EXIT_MODE_HALT; |
break; |
case EXIT_MODE_COLD: |
ll_exit_mode = EXIT_MODE_COLD; |
break; |
case EXIT_MODE_WARM: |
ll_exit_mode = EXIT_MODE_WARM; |
break; |
default: |
ll_exit_mode = EXIT_MODE_REAL; |
break; |
} |
return ll_exit_mode; |
} |
void l1_exit(int code) |
{ |
extern void bios_restore(void); |
bios_restore(); |
//printk("Exiting with mode: %d\n", ll_exit_mode); |
switch (ll_exit_mode) { |
case EXIT_MODE_HALT: |
halt(); |
break; |
case EXIT_MODE_COLD: |
cold_reboot(); |
break; |
case EXIT_MODE_WARM: |
warm_reboot(); |
break; |
default: |
__exit(code); |
break; |
} |
} |
/shark/trunk/libc/arch/x86/stdlib/strtoi.c |
---|
0,0 → 1,60 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/string.h> |
#include <arch/i386/limits.h> |
#include <arch/stdarg.h> |
#include <arch/ctype.h> |
#include <arch/math.h> |
FILE(strtoi); |
long int strtoi(char *s,int base,char **scan_end) |
{ |
int sign,value,overflow = 0; |
long int result = 0,oldresult; |
/* Evaluate sign */ |
if (*s == '-') { |
sign = -1; |
s++; |
} else if (*s == '+') { |
sign = 1; |
s++; |
} |
else sign = 1; |
/* Skip trailing zeros */ |
while (*s == '0') s++; |
/* Convert number */ |
while (isnumber(*s,base)) { |
value = tonumber(*s++); |
if (value > base || value < 0) return(0); |
oldresult = result; |
result *= base; |
result += value; |
/* Detect overflow */ |
if (oldresult > result) overflow = 1; |
} |
if (scan_end != 0L) *scan_end = s; |
if (overflow) result = INT_MAX; |
result *= sign; |
return(result); |
} |
/shark/trunk/libc/arch/x86/stdlib/strtol.c |
---|
0,0 → 1,129 |
/*- |
* Copyright (c) 1990, 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. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "@(#)strtol.c 8.1 (Berkeley) 6/4/93"; |
#endif /* LIBC_SCCS and not lint */ |
#include <arch/limits.h> |
#include <arch/ctype.h> |
#include <arch/errno.h> |
#include <arch/stdlib.h> |
FILE(strtol); |
/* |
* Convert a string to a long integer. |
* |
* Ignores `locale' stuff. Assumes that the upper and lower case |
* alphabets and digits are each contiguous. |
*/ |
long strtol(const char *nptr, char **endptr, int base) |
{ |
register const char *s = nptr; |
register unsigned long acc; |
register unsigned char 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 (!isascii(c)) */ |
if (!isalnum(c)) |
break; |
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; |
errno = ERANGE; |
} else if (neg) |
acc = -acc; |
if (endptr != 0) |
*endptr = (char *)(any ? s - 1 : nptr); |
return (acc); |
} |
/shark/trunk/libc/arch/x86/stdlib/strtoul.c |
---|
0,0 → 1,108 |
/* |
* Copyright (c) 1990, 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. |
*/ |
#if defined(LIBC_SCCS) && !defined(lint) |
static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93"; |
#endif /* LIBC_SCCS and not lint */ |
#include <arch/limits.h> |
#include <arch/ctype.h> |
#include <arch/errno.h> |
#include <arch/stdlib.h> |
FILE(strtoul); |
/* |
* 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 strtoul(const char *nptr, char **endptr, int base) |
{ |
register const char *s = nptr; |
register unsigned long acc; |
register unsigned char 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 (!isascii(c))*/ |
if (!isalnum(c)) |
break; |
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; |
errno = ERANGE; |
} else if (neg) |
acc = -acc; |
if (endptr != 0) |
*endptr = (char *)(any ? s - 1 : nptr); |
return (acc); |
} |
/shark/trunk/libc/arch/x86/Makefile |
---|
0,0 → 1,5 |
targets:= reboot.o ioformat/ libm/ stdlib/ string/ |
exported-aflags:= -I. |
exported-cppflags:= -I. |
exported-cflags:= -Dwrite=glue_write -Dlint -Wno-uninitialized -Wno-parentheses |
/shark/trunk/libc/arch/x86/ioformat/Makefile |
---|
0,0 → 1,8 |
targets:= \ |
ecvt.o \ |
fcvt.o \ |
gcvt.o \ |
sprintf.o \ |
ksprintf.o \ |
sscanf.o \ |
ucvt.o |
/shark/trunk/libc/arch/x86/ioformat/ksprintf.c |
---|
0,0 → 1,176 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/string.h> |
#include <arch/i386/limits.h> |
#include <arch/i386/float.h> |
#include <ll/i386/mem.h> |
#include <arch/stdarg.h> |
#include "sprintf.h" |
FILE(ksprintf); |
#define STD_SIZE 0 |
#define SHORT_SIZE 1 |
#define LONG_SIZE 2 |
int vksprintf(char *buf,char *fmt,va_list parms) |
{ |
int scanned = 0,w = 0,prec = 0,l = 0,size = 0; |
int n1 = 0; |
unsigned n2 = 0,parsing = 0,flag = 0; |
char *base = buf; |
char *sp = NULL; |
while (*fmt != 0) { |
if (*fmt != '%' && !parsing) { |
/* No token detected */ |
*buf++ = *fmt++; |
scanned++; |
} |
else { |
/* We need to make a conversion */ |
if (*fmt == '%') { |
fmt++; |
parsing = 1; |
w = 10; |
prec = 4; |
size = STD_SIZE; |
flag = 0; |
} |
/* Parse token */ |
switch(*fmt) { |
case '%' : *buf++ = '%'; |
scanned++; |
parsing = 0; |
break; |
case 'c' : *buf++ = va_arg(parms, char); |
scanned++; |
parsing = 0; |
break; |
case 'i' : |
case 'd' : switch (size) { |
case STD_SIZE : n1 = va_arg(parms, int); |
break; |
case LONG_SIZE : n1 = va_arg(parms, long int); |
break; |
case SHORT_SIZE : n1 = va_arg(parms, short int); |
break; |
} |
l = dcvt(n1,buf,10,w,flag); |
scanned += l; |
buf += l; |
parsing = 0; |
break; |
case 'u' : switch (size) { |
case STD_SIZE : n2 = va_arg(parms, unsigned); |
break; |
case LONG_SIZE : n2 = va_arg(parms, unsigned long); |
break; |
case SHORT_SIZE : n2 = va_arg(parms, unsigned short); |
break; |
} |
l = ucvt(n2,buf,10,w,flag); |
scanned += l; |
buf += l; |
parsing = 0; |
break; |
case 'x' : switch (size) { |
case STD_SIZE : n2 = va_arg(parms, unsigned); |
break; |
case LONG_SIZE : n2 = va_arg(parms, unsigned long); |
break; |
case SHORT_SIZE : n2 = va_arg(parms, unsigned short); |
break; |
} |
l = ucvt(n2,buf,16,w,flag); |
scanned += l; |
buf += l; |
parsing = 0; |
break; |
case 's' : sp = va_arg(parms, char *); |
while (*sp != 0) { |
*buf++ = *sp++; |
l++; |
} |
scanned += l; |
parsing = 0; |
break; |
case 'l' : size = LONG_SIZE; |
break; |
case 'n' : |
case 'h' : size = SHORT_SIZE; |
break; |
case '+' : flag |= ADD_PLUS; |
break; |
case '-' : flag |= LEFT_PAD; |
break; |
case '.' : parsing = 2; |
flag |= RESPECT_WIDTH; |
break; |
case '1' : |
case '2' : |
case '3' : |
case '4' : |
case '5' : |
case '6' : |
case '7' : |
case '8' : |
case '9' : |
case '0' : if (parsing == 1) { |
w = strtou(fmt,10,&base); |
/* MG */ |
/* if the first numeral is zero a ZERO pad is */ |
/* required */ |
/* but not if LEFT_PAD is set*/ |
if (*fmt!='0'||flag&LEFT_PAD) |
flag |= SPACE_PAD ; |
else |
flag |= ZERO_PAD ; |
fmt = base-1; |
} else if (parsing == 2) { |
prec = strtou(fmt,10,&base); |
fmt = base-1; |
parsing = 1; |
} |
break; |
case '#' : break; |
default : parsing = 0; |
break; |
} |
fmt++; |
} |
} |
*buf = 0; |
return(scanned); |
} |
int ksprintf(char *buf,char *fmt,...) |
{ |
va_list parms; |
int result; |
va_start(parms,fmt); |
result = vksprintf(buf,fmt,parms); |
va_end(parms); |
return(result); |
} |
/shark/trunk/libc/arch/x86/ioformat/ecvt.c |
---|
0,0 → 1,84 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/string.h> |
#include <arch/i386/limits.h> |
#include <arch/i386/float.h> |
#include <ll/i386/mem.h> |
#include <arch/stdarg.h> |
#include <arch/ctype.h> |
#include <arch/math.h> |
#include "sprintf.h" |
FILE(ecvt); |
unsigned ecvt(double v,char *buffer,int width,int prec,int flag) |
{ |
register int len=0; |
long int exponent,abs_exponent; |
/* Manage Inf & NaN */ |
if (isspecial(v,buffer)) return(strlen(buffer)); |
/* Check for negative value & add optional + sign */ |
if (v < 0) { |
*buffer++ = '-'; |
v = -v; |
len++; |
} else if (flag & ADD_PLUS) { |
*buffer++ = '+'; |
len++; |
} |
/* Zero check! */ |
if (v < DBL_MIN) { |
*buffer++ = '0'; |
*buffer = 0; |
return(1); |
} |
/* Evaluate the exponent */ |
if (v < 1) { |
exponent = 0; |
while (v < 1.0) { |
v *= 10.0; |
exponent--; |
} |
} |
else { |
exponent = 0; |
while (v >= 10.0) { |
v /= 10.0; |
exponent++; |
} |
} |
abs_exponent = abs(exponent); |
if (abs_exponent > 99) width -= 3; |
else if (abs_exponent > 9) width -= 2; |
else if (exponent > 0) width -= 1; |
/* Now the number as IP in range [0,1] */ |
/* Convert this as a fixed point format */ |
len += fcvt(v,buffer,width,prec,flag | RESPECT_WIDTH); |
/* Now convert the exponent */ |
if (exponent == 0) return(len); |
buffer += len; |
*buffer++ = 'e'; |
len += dcvt(exponent,buffer,10,exponent/10+2,ADD_PLUS)+1; |
return(len); |
} |
/shark/trunk/libc/arch/x86/ioformat/ucvt.c |
---|
0,0 → 1,115 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/string.h> |
#include <arch/i386/limits.h> |
#include <arch/i386/float.h> |
#include <ll/i386/mem.h> |
#include <arch/stdarg.h> |
#include <arch/ctype.h> |
#include "sprintf.h" |
FILE(ucvt); |
unsigned ucvt(unsigned long v,char *buffer,int base,int width,int flag) |
{ |
register int i = 0,j; |
unsigned ret = 0,abs_base; |
unsigned long abs_v; |
char tmp[12]; |
/* Extract the less significant digit */ |
/* Put it into temporary buffer */ |
/* It has to be local to have */ |
/* reentrant functions */ |
/* |
MG: fix to handle zero correctly |
if (v == 0) { |
*buffer++ = '0'; |
*buffer = 0; |
return(1); |
} |
*/ |
/* MG: is this required? */ |
/* the vsprintf() function seems to call this procedure with */ |
/* this flag inverted */ |
flag ^= LEFT_PAD; |
abs_base = (base >= 0) ? base : -base; |
if (base < 0) abs_v = ((long)(v) < 0) ? -v : v; |
else abs_v = v; |
/* Process left space-padding flags */ |
if (flag & ADD_PLUS || ((base < 0) && ((long)(v) < 0))) { |
ret++; |
} |
/* MG: fix to handle zero correctly */ |
if (v == 0) |
tmp[i++]='0'; |
else |
while (abs_v > 0) { |
tmp[i++] = todigit(abs_v % abs_base); |
abs_v = abs_v / abs_base; |
} |
ret += i; |
if ((flag & LEFT_PAD) && (flag & SPACE_PAD)) { |
j = ret; |
while (j < width) { |
*buffer++ = ' '; |
ret++; |
j++; |
} |
} |
/* Add plus if wanted */ |
if (base < 0) { |
if (((long)(v)) < 0) *buffer++ = '-'; |
else if (flag & ADD_PLUS) *buffer++ = '+'; |
} else if (flag & ADD_PLUS) *buffer++ = '+'; |
/* Process left zero-padding flags */ |
if ((flag & LEFT_PAD) && (flag & ZERO_PAD)) { |
j = ret; |
while (j < width) { |
*buffer++ = '0'; |
ret++; |
j++; |
} |
} |
/* Reverse temporary buffer into output buffer */ |
/* If wanted left pad with zero/space; anyway only one at once is ok */ |
for (j = i-1; j >= 0; j--) *buffer++ = tmp[j]; |
if ((flag & (SPACE_PAD)) && !(flag & LEFT_PAD)) { |
/* If wanted, pad with space to specified width */ |
j = ret; |
while (j < width) { |
*buffer++ = ' '; |
ret++; |
j++; |
} |
} |
/* Null terminate the output buffer */ |
*buffer = 0; |
return(ret); |
} |
unsigned dcvt(long v,char *buffer,int base,int width,int flag) |
{ |
return(ucvt((unsigned long)(v),buffer,-base,width,flag)); |
} |
/shark/trunk/libc/arch/x86/ioformat/fcvt.c |
---|
0,0 → 1,112 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/string.h> |
#include <arch/i386/limits.h> |
#include <arch/i386/float.h> |
#include <ll/i386/mem.h> |
#include <arch/stdarg.h> |
#include <arch/ctype.h> |
#include <arch/math.h> |
#include "sprintf.h" |
FILE(fcvt); |
unsigned fcvt(double v,char *buffer,int width,int prec,int flag) |
{ |
double ip,fp,val; |
register int l=0; |
register int digits; |
int conv,got_a_digit,exceeded,len = 0; |
char tmp[300]; |
memset(tmp,0,300); |
/* Manage Inf & NaN */ |
if (isspecial(v,buffer)) return(strlen(buffer)); |
/* Check for negative value & add optional + sign */ |
if (v < 0) { |
*buffer++ = '-'; |
v = -v; |
len++; |
} else if (flag & ADD_PLUS) { |
*buffer++ = '+'; |
len++; |
} |
/* Extract integer part & mantissa */ |
fp = modf(v,&ip); |
/* Process integer part */ |
digits = 0; |
if (ip >= 1.0) { |
while (ip >= 1.0) { |
/* The 0.01 here is used to correct rounding errors*/ |
/* Ex: 1.2 --> 1.1999999999999... adjust to 1.2 */ |
/* |
ip = ip / 10.0; |
modf(ip,&val); |
val = (ip - val)*10.0; |
*/ |
val = fmod(ip,10.0); |
ip = ip / 10.0; |
tmp[digits++] = todigit((unsigned)(val)); |
} |
len += digits; |
/* Now reverse the temporary buffer into output buffer */ |
/* Translate only the last 15 digits */ |
/* The others are beyond double precision limit! */ |
for (l = digits-1; l >= max(digits-15,0); l--) *buffer++ = tmp[l]; |
if (l >= 0) for (l = digits-16; l >= 0; l--) *buffer++ = '0'; |
*buffer = 0; |
/* If IP == 0 -> just put in a 0 */ |
} else { |
*buffer++ = '0'; |
len++; |
} |
/* Process fractionary part according to width specification */ |
/* If RESPECT_WIDTH is set, scan until you reach wanted precision */ |
/* Else scan until you find a not 0 digit */ |
if (fp > 1e-307 && len < width+1) { |
*buffer++ = '.'; |
len++; |
if (flag & RESPECT_WIDTH) got_a_digit = 1; |
else got_a_digit = 0; |
exceeded = 0; |
digits = 1; |
while (!exceeded) { |
/* The DBL_EPSILON here is used to correct rounding errors */ |
fp = (fp + DBL_EPSILON) * 10.0; |
fp = modf(fp,&ip); |
conv = (int)(ip); |
if (conv != 0 && !got_a_digit) got_a_digit = 1; |
*buffer++ = todigit(conv); |
len++; |
digits++; |
if (got_a_digit && (digits > prec)) exceeded = 1; |
if (width < len) exceeded = 1; |
} |
/* Drop trailing zeros after decimal point */ |
while (*--buffer == '0' && *(buffer-1) != '.') len--; |
buffer++; |
} |
*buffer = 0; |
return(len); |
} |
/shark/trunk/libc/arch/x86/ioformat/gcvt.c |
---|
0,0 → 1,67 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/string.h> |
#include <arch/i386/limits.h> |
#include <arch/i386/float.h> |
#include <ll/i386/mem.h> |
#include <arch/stdarg.h> |
#include <arch/ctype.h> |
#include <arch/math.h> |
#include "sprintf.h" |
FILE(gcvt); |
unsigned gcvt(double v,char *buffer,int width,int prec,int flag) |
{ |
double v_abs; |
int exponent; |
/* Manage Inf & NaN */ |
if (isspecial(v,buffer)) return(strlen(buffer)); |
/* Extract absolute value */ |
if (v < 0.0) v_abs = -v; |
else v_abs = v; |
/* Zero check! */ |
if (v_abs < DBL_MIN) { |
*buffer++ = '0'; |
*buffer = 0; |
return(1); |
} |
exponent = 0; |
/* Evaluate exponent */ |
if (v_abs < 1.0) { |
while (v_abs < 1) { |
v_abs *= 10.0; |
exponent--; |
} |
} |
else { |
while (v_abs >= 10.0) { |
v_abs /= 10.0; |
exponent++; |
} |
} |
/* Choose shortest format on exponent value */ |
if (exponent > 7 || exponent < -7) |
return(ecvt(v,buffer,width,prec,flag)); |
else return(fcvt(v,buffer,width,prec,flag)); |
} |
/shark/trunk/libc/arch/x86/ioformat/sprintf.c |
---|
0,0 → 1,236 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/string.h> |
#include <arch/i386/limits.h> |
#include <arch/i386/float.h> |
#include <ll/i386/mem.h> |
#include <arch/stdarg.h> |
//#include <arch/ctype.h> |
#include <arch/math.h> |
#include "sprintf.h" |
FILE(sprintf); |
#define STD_SIZE 0 |
#define SHORT_SIZE 1 |
#define LONG_SIZE 2 |
int vsprintf(char *buf,char *fmt,va_list parms) |
{ |
int scanned = 0,w = 0,prec = 0,l = 0,size = 0; |
int n1 = 0; |
unsigned n2 = 0,parsing = 0,flag = 0; |
double n3 = 0.0; |
char *base = buf; |
char *sp = NULL; |
void *fp = NULL; |
while (*fmt != 0) { |
if (*fmt != '%' && !parsing) { |
/* No token detected */ |
*buf++ = *fmt++; |
scanned++; |
} |
else { |
/* We need to make a conversion */ |
if (*fmt == '%') { |
fmt++; |
parsing = 1; |
w = 10; |
prec = 4; |
size = STD_SIZE; |
flag = 0; |
} |
/* Parse token */ |
switch(*fmt) { |
case '%' : *buf++ = '%'; |
scanned++; |
parsing = 0; |
break; |
case 'c' : *buf++ = va_arg(parms, char); |
scanned++; |
parsing = 0; |
break; |
case 'i' : |
case 'd' : switch (size) { |
case STD_SIZE : n1 = va_arg(parms, int); |
break; |
case LONG_SIZE : n1 = va_arg(parms, long int); |
break; |
case SHORT_SIZE : n1 = va_arg(parms, short int); |
break; |
} |
l = dcvt(n1,buf,10,w,flag); |
scanned += l; |
buf += l; |
parsing = 0; |
break; |
case 'u' : switch (size) { |
case STD_SIZE : n2 = va_arg(parms, unsigned); |
break; |
case LONG_SIZE : n2 = va_arg(parms, unsigned long); |
break; |
case SHORT_SIZE : n2 = va_arg(parms, unsigned short); |
break; |
} |
l = ucvt(n2,buf,10,w,flag); |
scanned += l; |
buf += l; |
parsing = 0; |
break; |
case 'x' : switch (size) { |
case STD_SIZE : n2 = va_arg(parms, unsigned); |
break; |
case LONG_SIZE : n2 = va_arg(parms, unsigned long); |
break; |
case SHORT_SIZE : n2 = va_arg(parms, unsigned short); |
break; |
} |
l = ucvt(n2,buf,16,w,flag); |
scanned += l; |
buf += l; |
parsing = 0; |
break; |
case 'p' : fp = va_arg(parms, void *); |
n2 = (unsigned long)(fp); |
l = ucvt(n2,buf,16,w,0); |
scanned += l; |
buf += l; |
parsing = 0; |
break; |
case 's' : sp = va_arg(parms, char *); |
while (*sp != 0) { |
*buf++ = *sp++; |
l++; |
} |
scanned += l; |
parsing = 0; |
break; |
case 'f' : switch (size) { |
case STD_SIZE : n3 = va_arg(parms, double); |
break; |
case LONG_SIZE : n3 = va_arg(parms, double); |
break; |
/* |
It seems that the compilers push a float as |
a double ... Need to check! |
*/ |
case SHORT_SIZE : n3 = va_arg(parms, double); |
break; |
} |
l = fcvt(n3,buf,w,prec,flag); |
scanned += l; |
buf += l; |
parsing = 0; |
break; |
case 'e' : switch (size) { |
case STD_SIZE : n3 = va_arg(parms, double); |
break; |
case LONG_SIZE : n3 = va_arg(parms, double); |
break; |
/* |
It seems that the compilers push a float as |
a double ... Need to check! |
*/ |
case SHORT_SIZE : n3 = va_arg(parms, double); |
break; |
} |
l = ecvt(n3,buf,w,prec,flag); |
scanned += l; |
buf += l; |
parsing = 0; |
break; |
case 'g' : switch (size) { |
case STD_SIZE : n3 = va_arg(parms, double); |
break; |
case LONG_SIZE : n3 = va_arg(parms, double); |
break; |
/* |
It seems that the compilers push a float as |
a double ... Need to check! |
*/ |
case SHORT_SIZE : n3 = va_arg(parms, double); |
break; |
} |
l = gcvt(n3,buf,w,prec,flag); |
scanned += l; |
buf += l; |
parsing = 0; |
break; |
case 'l' : size = LONG_SIZE; |
break; |
case 'n' : |
case 'h' : size = SHORT_SIZE; |
break; |
case '+' : flag |= ADD_PLUS; |
break; |
case '-' : flag |= LEFT_PAD; |
break; |
case '.' : parsing = 2; |
flag |= RESPECT_WIDTH; |
break; |
case '1' : |
case '2' : |
case '3' : |
case '4' : |
case '5' : |
case '6' : |
case '7' : |
case '8' : |
case '9' : |
case '0' : if (parsing == 1) { |
w = strtou(fmt,10,&base); |
/* MG */ |
/* if the first numeral is zero a ZERO pad is */ |
/* required */ |
/* but not if LEFT_PAD is set*/ |
if (*fmt!='0'||flag&LEFT_PAD) |
flag |= SPACE_PAD ; |
else |
flag |= ZERO_PAD ; |
fmt = base-1; |
} else if (parsing == 2) { |
prec = strtou(fmt,10,&base); |
fmt = base-1; |
parsing = 1; |
} |
break; |
case '#' : break; |
default : parsing = 0; |
break; |
} |
fmt++; |
} |
} |
*buf = 0; |
return(scanned); |
} |
int sprintf(char *buf,char *fmt,...) |
{ |
va_list parms; |
int result; |
va_start(parms,fmt); |
result = vsprintf(buf,fmt,parms); |
va_end(parms); |
return(result); |
} |
/shark/trunk/libc/arch/x86/ioformat/sscanf.c |
---|
0,0 → 1,210 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/string.h> |
#include <arch/i386/limits.h> |
#include <arch/stdarg.h> |
#include <arch/ctype.h> |
#include "sprintf.h" |
FILE(sscanf); |
#define STD_SIZE 0 |
#define SHORT_SIZE 1 |
#define LONG_SIZE 2 |
int vsscanf(char *buf,char *fmt,va_list parms) |
{ |
int scanned = 0,size = 0,suppress = 0; |
int w = 0,flag = 0,l = 0; |
char c,*c_ptr; |
long int n1,*n1l; |
int *n1b; |
short int *n1s; |
long unsigned n2,*n2l,parsing = 0; |
unsigned *n2b; |
short unsigned *n2s; |
double n3,*n3l; |
float *n3s; |
char *base = buf; |
while (*fmt != 0) { |
if (*fmt != '%' && !parsing) { |
/* No token detected */ |
fmt++; |
} |
else { |
/* We need to make a conversion */ |
if (*fmt == '%') { |
fmt++; |
parsing = 1; |
size = STD_SIZE; |
suppress = 0; |
w = 0; |
flag = 0; |
l = 0; |
} |
/* Parse token */ |
switch(*fmt) { |
case '1' : |
case '2' : |
case '3' : |
case '4' : |
case '5' : |
case '6' : |
case '7' : |
case '8' : |
case '9' : |
case '0' : if (parsing == 1) { |
w = strtou(fmt,10,&base); |
/* We use SPACE_PAD to parse %10s |
commands where the number is the |
maximum number of char to store! |
*/ |
flag |= SPACE_PAD; |
fmt = base-1; |
} |
break; |
case 'c' : c = *buf++; |
c_ptr = va_arg(parms, char *); |
*c_ptr = c; |
scanned++; |
parsing = 0; |
break; |
case 's' : c_ptr = va_arg(parms, char *); |
while (*buf != 0 && isspace(*buf)) buf++; |
l = 0; |
while (*buf != 0 && !isspace(*buf)) { |
if (!(flag & SPACE_PAD)) *c_ptr++ = *buf; |
else if (l < w) { |
*c_ptr++ = *buf; |
l++; |
} |
buf++; |
} |
*c_ptr = 0; |
scanned++; |
parsing = 0; |
break; |
case 'i' : |
case 'd' : buf = strscn(buf,"1234567890-+"); |
n1 = strtoi(buf,10,&base); |
buf = base; |
if (!suppress) { |
switch (size) { |
case STD_SIZE : n1b = va_arg(parms, int *); |
*n1b = (int)n1; |
break; |
case LONG_SIZE : n1l = va_arg(parms, long int *); |
*n1l = n1; |
break; |
case SHORT_SIZE : n1s = va_arg(parms, short int *); |
*n1s = (short)(n1); |
break; |
} |
scanned++; |
} |
parsing = 0; |
break; |
case 'u' : buf = strscn(buf,"1234567890"); |
n2 = strtou(buf,10,&base); |
buf = base; |
if (!suppress) { |
switch (size) { |
case STD_SIZE : n2b = va_arg(parms, unsigned *); |
*n2b = (unsigned)n2; |
break; |
case LONG_SIZE : n2l = va_arg(parms, long unsigned *); |
*n2l = n2; |
break; |
case SHORT_SIZE : n2s = va_arg(parms, short unsigned *); |
*n2s = (short)(n2); |
break; |
} |
scanned++; |
} |
parsing = 0; |
break; |
case 'x' : buf = strscn(buf,"1234567890xabcdefABCDEF"); |
n2 = strtou(buf,16,&base); |
buf = base; |
if (!suppress) { |
switch (size) { |
case STD_SIZE : n2b = va_arg(parms, unsigned *); |
*n2b = (unsigned)n2; |
break; |
case LONG_SIZE : n2l = va_arg(parms, long unsigned *); |
*n2l = n2; |
break; |
case SHORT_SIZE : n2s = va_arg(parms, short unsigned *); |
*n2s = (short)(n2); |
break; |
} |
scanned++; |
} |
parsing = 0; |
break; |
case 'f' : |
case 'g' : |
case 'e' : buf = strscn(buf,"1234567890.e+-"); |
n3 = strtod(buf,&base); |
buf = base; |
if (!suppress) { |
switch (size) { |
case STD_SIZE : n3l = va_arg(parms, double *); |
*n3l = n3; |
break; |
case LONG_SIZE : n3l = va_arg(parms, double *); |
*n3l = n3; |
break; |
case SHORT_SIZE : n3s = va_arg(parms, float *); |
*n3s = (float)(n3); |
break; |
} |
scanned++; |
} |
parsing = 0; |
break; |
case 'l' : size = LONG_SIZE; |
break; |
case 'h' : |
case 'n' : size = SHORT_SIZE; |
break; |
case '*' : suppress = 1; |
break; |
default : parsing = 0; |
break; |
} |
fmt++; |
} |
} |
return(scanned); |
} |
int sscanf(char *buf,char *fmt,...) |
{ |
va_list parms; |
int result; |
va_start(parms,fmt); |
result = vsscanf(buf,fmt,parms); |
va_end(parms); |
return(result); |
} |
/shark/trunk/libc/arch/x86/ioformat/sprintf.h |
---|
0,0 → 1,32 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLin is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#ifndef __INTERNAL_SPRINTF_H__ |
#define __INTERNAL_SPRINTF_H__ |
/* Flag bit settings */ |
#define RESPECT_WIDTH 1 /* Fixed width wanted */ |
#define ADD_PLUS 2 /* Add + for positive/floats */ |
#define SPACE_PAD 4 /* Padding possibility */ |
#define ZERO_PAD 8 |
#define LEFT_PAD 16 |
#endif |
/shark/trunk/libc/arch/x86/string/Makefile |
---|
0,0 → 1,9 |
targets:= \ |
strncat.o \ |
strrchr.o \ |
strstr.o \ |
string.o \ |
special.o \ |
strnum.o \ |
strbase.o |
/shark/trunk/libc/arch/x86/string/strncat.c |
---|
0,0 → 1,46 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/string.h> |
FILE(strncat); |
/* |
* Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes |
* are written at dst (at most n+1 bytes being appended). Return dst. |
*/ |
char *strncat(char *dest, const char *src, int n) |
{ |
if (n != 0) { |
char *d = dest; |
const char *s = src; |
while (*d != 0) |
d++; |
do { |
if ((*d = *s++) == 0) |
break; |
d++; |
} while (--n != 0); |
*d = 0; |
} |
return (dest); |
} |
/shark/trunk/libc/arch/x86/string/special.c |
---|
0,0 → 1,52 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/ctype.h> |
#include <arch/i386/string.h> |
FILE(IsSpecial); |
int isspecial(double d, char *bufp) |
{ |
/* IEEE standard number rapresentation */ |
register struct IEEEdp { |
unsigned manl:32; |
unsigned manh:20; |
unsigned exp:11; |
unsigned sign:1; |
} *ip = (struct IEEEdp *) &d; |
if (ip->exp != 0x7ff) |
return (0); |
if (ip->manh || ip->manl) { |
if (bufp != NULL) |
strcpy(bufp, "NaN"); |
return (1); |
} else if (ip->sign) { |
if (bufp != NULL) |
strcpy(bufp, "+Inf"); |
return (2); |
} else { |
if (bufp != NULL) |
strcpy(bufp, "-Inf"); |
return (3); |
} |
} |
/shark/trunk/libc/arch/x86/string/strstr.c |
---|
0,0 → 1,42 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/string.h> |
FILE(strstr); |
char *strstr(const char *haystack, const char *needle) |
{ |
int hlen; |
int nlen; |
hlen = strlen((char *)haystack); |
nlen = strlen((char *)needle); |
while (hlen >= nlen) |
{ |
if (!memcmp(haystack, needle, nlen)) |
return (char *)haystack; |
haystack++; |
hlen--; |
} |
return 0; |
} |
/shark/trunk/libc/arch/x86/string/strbase.c |
---|
0,0 → 1,79 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/ctype.h> |
#include <arch/i386/string.h> |
FILE(strbase); |
int isalnum(char c) |
{ |
return (isalpha(c) || isdigit(c)); |
} |
int isalpha(char c) |
{ |
if ((c >= 'A' && c <= 'z')) |
return(1); |
else return(0); |
} |
int iscntrl(char c) |
{ |
if (c < '0') { |
return 1; |
} else { |
return 0; |
} |
} |
int islower(char c) |
{ |
if ((c >= 'a' && c <= 'z')) |
return(1); |
else return(0); |
} |
int isspace(char c) |
{ |
if ((c >= 0x09 && c <= 0x0d) || (c == 0x20)) return(1); |
return(0); |
} |
int isupper(char c) |
{ |
if ((c >= 'A' && c <= 'Z')) |
return(1); |
else return(0); |
} |
char toupper(char c) |
{ |
if (c >= 'a' && c <= 'z') return(c-'a'+'A'); |
else return(c); |
} |
char tolower(char c) |
{ |
if (c >= 'A' && c <= 'Z') return(c-'A'+'a'); |
else return(c); |
} |
/shark/trunk/libc/arch/x86/string/string.c |
---|
0,0 → 1,122 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/string.h> |
FILE(string); |
char *strcpy(char *dst,const char *src) |
{ |
char *retval = dst; |
while (*src != 0) *dst++ = *src++; |
*dst = 0; |
return(retval); |
} |
char *strncpy(char *dst,const char *src,int n) |
{ |
char *retval = dst; |
while (*src != 0 && n-- > 0) *dst++ = *src++; |
*dst = 0; |
return(retval); |
} |
int strcmp(const char *s1,const char *s2) |
{ |
while (*s1 == *s2) { |
if (*s1 == 0) return 0; |
s1++; |
s2++; |
} |
return *(unsigned const char *)s1 - *(unsigned const char *)(s2); |
} |
int strncmp(const char *s1,const char *s2,int n) |
{ |
if (n == 0) return 0; |
do { |
if (*s1 != *s2++) |
return *(unsigned const char *)s1 - *(unsigned const char *)--s2; |
if (*s1++ == 0) break; |
} while (--n != 0); |
return 0; |
} |
char *strupr(char *s) |
{ |
char *base = s; |
while (*s != 0) { |
if (*s >= 'a' && *s <= 'z') |
*s = *s + 'A' -'a'; |
s++; |
} |
return(base); |
} |
char *strlwr(char *s) |
{ |
char *base = s; |
while (*s != 0) { |
if (*s >= 'A' && *s <= 'Z') |
*s = *s + 'a' -'A'; |
s++; |
} |
return(base); |
} |
int strlen(const char *s) |
{ |
register int result = 0; |
while (*s != 0) s++ , result++; |
return(result); |
} |
char *strcat(char *dst,char *src) |
{ |
char *base = dst; |
while (*dst != 0) dst++; |
while (*src != 0) *dst++ = *src++; |
*dst = 0; |
return(base); |
} |
char *strscn(char *s,char *pattern) |
{ |
char *scan; |
while (*s != 0) { |
scan = pattern; |
while (*scan != 0) { |
if (*s == *scan) return(s); |
else scan++; |
} |
s++; |
} |
return(NULL); |
} |
char *strchr(char *s,int c) |
{ |
while (*s != 0) { |
if (*s == (char)(c)) return(s); |
else s++; |
} |
return(NULL); |
} |
/shark/trunk/libc/arch/x86/string/strrchr.c |
---|
0,0 → 1,35 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/i386/string.h> |
FILE(strchr); |
char *strrchr(const char *s, int c) |
{ |
char *save; |
for (save = NULL; *s != NULL; s++) |
if (*s == c) |
save = (char *)s; |
return save; |
} |
/shark/trunk/libc/arch/x86/string/strnum.c |
---|
0,0 → 1,62 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <arch/ctype.h> |
#include <arch/i386/string.h> |
FILE(strnum); |
int isnumber(char c,int base) |
{ |
static char *digits = "0123456789ABCDEF"; |
if ((c >= '0' && c <= digits[base-1])) |
return(1); |
else return(0); |
} |
int tonumber(char c) |
{ |
if (c >= '0' && c <= '9') return(c - '0'); |
else if (c >= 'A' && c <= 'F') return(c - 'A' + 10); |
else if (c >= 'a' && c <= 'f') return(c - 'a' + 10); |
else return(c); |
} |
char todigit(int c) |
{ |
if (c >= 0 && c <= 9) return(c+'0'); |
else if (c >= 10 && c <= 15) return(c + 'A' - 10); |
else return(c); |
} |
int isxdigit(char c) |
{ |
if ((c >= '0' && c <= 'F') || (c >= 'a' && c <= 'f')) |
return(1); |
else return(0); |
} |
int isdigit(char c) |
{ |
if ((c >= '0' && c <= '9')) |
return(1); |
else return(0); |
} |
/shark/trunk/libc/arch/x86/include/arch/math.h |
---|
0,0 → 1,141 |
/* |
* Copyright (c) 1985, 1990, 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. |
* |
* @(#)math.h 8.1 (Berkeley) 6/2/93 |
*/ |
#ifndef __LL_MATH_H__ |
#define __LL_MATH_H__ |
#if defined(vax) || defined(tahoe) /* DBL_MAX from float.h */ |
#define HUGE_VAL 1.701411834604692294E+38 |
#else |
#define HUGE_VAL 1e500 /* IEEE: positive infinity */ |
#endif |
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) |
#if defined(vax) || defined(tahoe) |
/* |
* HUGE for the VAX and Tahoe converts to the largest possible F-float value. |
* This implies an understanding of the conversion behavior of atof(3). It |
* was defined to be the largest float so that overflow didn't occur when it |
* was assigned to a single precision number. HUGE_VAL is strongly preferred. |
*/ |
#define HUGE 1.701411733192644270E+38 |
#else |
#define HUGE HUGE_VAL |
#endif |
#define M_E 2.7182818284590452354 /* e */ |
#define M_LOG2E 1.4426950408889634074 /* log 2e */ |
#define M_LOG10E 0.43429448190325182765 /* log 10e */ |
#define M_LN2 0.69314718055994530942 /* log e2 */ |
#define M_LN10 2.30258509299404568402 /* log e10 */ |
#define M_PI 3.14159265358979323846 /* pi */ |
#define M_PI_2 1.57079632679489661923 /* pi/2 */ |
#define M_PI_4 0.78539816339744830962 /* pi/4 */ |
#define M_1_PI 0.31830988618379067154 /* 1/pi */ |
#define M_2_PI 0.63661977236758134308 /* 2/pi */ |
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ |
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ |
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ |
#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ |
#include <arch/sys/cdefs.h> |
/* |
* Most of these functions have the side effect of setting errno, except |
* in the (broken) BSD libm, so they not declared as __pure2. |
*/ |
__BEGIN_DECLS double acos __P((double)); |
double asin __P((double)); |
double atan __P((double)); |
double atan2 __P((double, double)); |
double ceil __P((double)); |
double cos __P((double)); |
double cosh __P((double)); |
double exp __P((double)); |
double fabs __P((double)); |
double floor __P((double)); |
double fmod __P((double, double)); |
double frexp __P((double, int *)); /* fundamentally !__pure2 */ |
double ldexp __P((double, int)); |
double log __P((double)); |
double log10 __P((double)); |
double modf __P((double, double *)); /* fundamentally !__pure2 */ |
double pow __P((double, double)); |
double sin __P((double)); |
double sinh __P((double)); |
double sqrt __P((double)); |
double tan __P((double)); |
double tanh __P((double)); |
/* |
* These functions are non-ANSI so they can be "right". The ones that |
* don't set errno in [lib]msun are declared as __pure2. |
*/ |
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) |
double acosh __P((double)); |
double asinh __P((double)); |
double atanh __P((double)); |
double cabs(); /* we can't describe cabs()'s argument properly */ |
double cbrt __P((double)) __pure2; |
double copysign __P((double, double)) __pure2; |
double drem __P((double, double)); |
double erf __P((double)); |
double erfc __P((double)) __pure2; |
double expm1 __P((double)) __pure2; |
int finite __P((double)) __pure2; |
double hypot __P((double, double)); |
#if defined(vax) || defined(tahoe) |
double infnan __P((int)); |
#endif |
int isinf __P((double)) __pure2; |
int isnan __P((double)) __pure2; |
double j0 __P((double)); |
double j1 __P((double)); |
double jn __P((int, double)); |
double lgamma __P((double)); |
double log1p __P((double)) __pure2; |
double logb __P((double)) __pure2; |
double rint __P((double)) __pure2; |
double scalb __P((double, int)); |
double y0 __P((double)); |
double y1 __P((double)); |
double yn __P((int, double)); |
#endif |
#define isinf(x) (isspecial(x, NULL) > 1) |
#define isnan(x) (isspecial(x, NULL) == 1) |
__END_DECLS |
#endif /* !_MATH_H_ */ |
/shark/trunk/libc/arch/x86/include/arch/endian.h |
---|
0,0 → 1,120 |
/* |
* Copyright (c) 1987, 1991 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. |
* |
* from: @(#)endian.h 7.8 (Berkeley) 4/3/91 |
* endian.h,v 1.5 1994/09/10 20:03:14 csgr Exp |
*/ |
#ifndef _MACHINE_ENDIAN_H_ |
#define _MACHINE_ENDIAN_H_ 1 |
/* |
* Define the order of 32-bit words in 64-bit words. |
*/ |
#define _QUAD_HIGHWORD 1 |
#define _QUAD_LOWWORD 0 |
/* |
* Definitions for byte order, according to byte significance from low |
* address to high. |
*/ |
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ |
#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ |
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ |
#define BYTE_ORDER LITTLE_ENDIAN |
#ifndef KERNEL |
#include <arch/sys/cdefs.h> |
#endif |
#define __word_swap_long(x) \ |
({ register u_long X = (x); \ |
__asm ("rorl $16, %1" \ |
: "=r" (X) \ |
: "0" (X)); \ |
X; }) |
#if __GNUC__ >= 2 |
#define __byte_swap_long(x) \ |
({ register u_long X = (x); \ |
__asm ("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" \ |
: "=q" (X) \ |
: "0" (X)); \ |
X; }) |
#define __byte_swap_word(x) \ |
({ register u_short X = (x); \ |
__asm ("xchgb %h1, %b1" \ |
: "=q" (X) \ |
: "0" (X)); \ |
X; }) |
#else /* __GNUC__ >= 2 */ |
#define __byte_swap_long(x) \ |
({ register u_long X = (x); \ |
__asm ("rorw $8, %w1\n\trorl $16, %1\n\trorw $8, %w1" \ |
: "=r" (X) \ |
: "0" (X)); \ |
X; }) |
#define __byte_swap_word(x) \ |
({ register u_short X = (x); \ |
__asm ("rorw $8, %w1" \ |
: "=r" (X) \ |
: "0" (X)); \ |
X; }) |
#endif /* __GNUC__ >= 2 */ |
/* |
* Macros for network/external number representation conversion. |
*/ |
#if BYTE_ORDER == BIG_ENDIAN && !defined(lint) |
#define ntohl(x) (x) |
#define ntohs(x) (x) |
#define htonl(x) (x) |
#define htons(x) (x) |
#define NTOHL(x) (x) |
#define NTOHS(x) (x) |
#define HTONL(x) (x) |
#define HTONS(x) (x) |
#else |
#define ntohl __byte_swap_long |
#define ntohs __byte_swap_word |
#define htonl __byte_swap_long |
#define htons __byte_swap_word |
#define NTOHL(x) (x) = ntohl((u_long)x) |
#define NTOHS(x) (x) = ntohs((u_short)x) |
#define HTONL(x) (x) = htonl((u_long)x) |
#define HTONS(x) (x) = htons((u_short)x) |
#endif |
#endif /* _MACHINE_ENDIAN_H_ */ |
/shark/trunk/libc/arch/x86/include/arch/time.h |
---|
0,0 → 1,35 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* A wrapper to the time handling functions */ |
#ifndef __LL_TIME_H__ |
#define __LL_TIME_H__ |
#include <ll/sys/types.h> |
#ifndef NULL |
#define NULL 0L |
#endif |
#include <ll/sys/ll/time.h> |
#endif |
/shark/trunk/libc/arch/x86/include/arch/assert.h |
---|
0,0 → 1,39 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Assert & demand: diagnostic routines */ |
#ifndef __LL_ASSERT_H__ |
#define __LL_ASSERT_H__ |
#include "i386/error.h" |
#define assert(x) { \ |
if (! (x)) \ |
message("%s:%d: assertion failed: %s", __FILE__, __LINE__, #x); \ |
} |
#define demand(x,y) { \ |
if (! (x)) \ |
message("%s:%d: demand %s failed: %s", __FILE__, __LINE__, #x, #y); \ |
} |
#endif |
/shark/trunk/libc/arch/x86/include/arch/limits.h |
---|
0,0 → 1,22 |
/* |
* This program 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 2 of the License, or |
* (at your option) any later version. |
* |
* This program 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. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
#ifndef __LL_LIMITS_H__ |
#define __LL_LIMITS_H__ |
#include "i386/limits.h" |
#endif |
/shark/trunk/libc/arch/x86/include/arch/stdlib.h |
---|
0,0 → 1,27 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The system independent part of the standard library */ |
#ifndef __LL_STDLIB_H__ |
#define __LL_STDLIB_H__ |
#include "i386/stdlib.h" |
#endif |
/shark/trunk/libc/arch/x86/include/arch/stdio.h |
---|
0,0 → 1,26 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The standard input/output */ |
#ifndef __LL_STDIO_H__ |
#define __LL_STDIO_H__ |
#include "i386/stdio.h" |
#endif |
/shark/trunk/libc/arch/x86/include/arch/i386/limits.h |
---|
0,0 → 1,48 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Some POSIX compliance stuff */ |
#ifndef __LL_I386_LIMITS_H__ |
#define __LL_I386_LIMITS_H__ |
/* Number limits */ |
#define CHAR_BIT 8 |
#define CHAR_MAX 255 |
#define CHAR_MIN 0 |
#define SCHAR_MAX 127 |
#define SCHAR_MIN -128 |
#define UCHAR_MAX 255 |
#define INT_MAX 2147483647 |
#define INT_MIN (-INT_MAX - 1) |
#define UINT_MAX 4294967295U |
#define SHRT_MIN (-32768) |
#define SHRT_MAX 32767 |
#define USHRT_MAX 65535 |
#define LONG_MAX 2147483647L |
#define LONG_MIN (-LONG_MAX - 1) |
#define ULONG_MAX 4294967295UL |
#endif |
/shark/trunk/libc/arch/x86/include/arch/i386/stdlib.h |
---|
0,0 → 1,100 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Standard library for OSLib applications */ |
#ifndef __LL_I386_STDLIB_H__ |
#define __LL_I386_STDLIB_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#define EXIT_FAILURE 1 /* Failing exit status. */ |
#define EXIT_SUCCESS 0 /* Successful exit status. */ |
/* Added by Nino - Begin */ |
#define EXIT_MODE_HALT 0 /* End the system using the 'hlt' instruction. */ |
#define EXIT_MODE_COLD 1 /* End the system with a _cold_ reboot. */ |
#define EXIT_MODE_WARM 2 /* End the system with a _warm_ reboot. */ |
#define EXIT_MODE_REAL 3 /* End the system returning in real-mode. */ |
/* Added by Nino - End */ |
#ifndef NULL |
#define NULL 0L |
#endif |
#define RAND_MAX 2147483647 |
/* String conversion functions */ |
/* File: StrConv.C */ |
long strtoi(char *s,int base,char **scan_end); |
unsigned long strtou(char *s,int base,char **scan_end); |
double strtod(char *s,char **scan_end); |
long strtol(const char *nptr, char **endptr, int base); |
unsigned long strtoul(const char *nptr, char **endptr, int base); |
unsigned ecvt(double v,char *buffer,int width,int prec,int flag); |
unsigned fcvt(double v,char *buffer,int width,int prec,int flag); |
unsigned gcvt(double v,char *buffer,int width,int prec,int flag); |
unsigned dcvt(long v,char *buffer,int base,int width,int flag); |
unsigned ucvt(unsigned long v,char *buffer,int base,int width,int flag); |
/* StdLib Macro */ |
#define atof(s) strtod(s, NULL) |
#define atoi(s) strtoi(s, 10, NULL) |
#define atou(s) strtou(s, 10, NULL) |
#define atol(s) strtol(s, 10, NULL) |
/* Generic utility functions */ |
/* File StdLib.C */ |
void srand(long int seed); |
long int rand(void); |
unsigned abs(int x); |
/* The stdlib exit functions */ |
void l1_exit(int code); |
int ll_set_reboot(int mode); |
/* Stdlib Macro */ |
#ifndef __WC16__ |
#define labs(x) abs(x) |
#endif |
#if !defined(__max) |
#define __max(a,b) (((a) > (b)) ? (a) : (b)) |
#endif |
#if !defined(max) && !defined(__cplusplus) |
#define max(a,b) (((a) > (b)) ? (a) : (b)) |
#endif |
#if !defined(__min) |
#define __min(a,b) (((a) < (b)) ? (a) : (b)) |
#endif |
#if !defined(min) && !defined(__cplusplus) |
#define min(a,b) (((a) < (b)) ? (a) : (b)) |
#endif |
END_DEF |
#endif |
/shark/trunk/libc/arch/x86/include/arch/i386/stdio.h |
---|
0,0 → 1,40 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#ifndef __LL_I386_STDIO_H__ |
#define __LL_I386_STDIO_H__ |
#include <arch/stdarg.h> |
#include <ll/i386/defs.h> |
BEGIN_DEF |
int vsprintf(char *buf,char *fmt,va_list parms); |
int vksprintf(char *buf,char *fmt,va_list parms); |
int sprintf(char *buf,char *fmt,...) __attribute__((__format__(printf,2,3))); |
int ksprintf(char *buf,char *fmt,...) __attribute__((__format__(printf,2,3))); |
int vsscanf(char *buf,char *fmt,va_list parms); |
int sscanf(char *buf,char *fmt,...) __attribute__((__format__(scanf,2,3))); |
int ll_printf(char *fmt,...); |
END_DEF |
#endif |
/shark/trunk/libc/arch/x86/include/arch/i386/float.h |
---|
0,0 → 1,59 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The POSIX float.h header */ |
#ifndef __LL_I386_FLOAT_H |
#define __LL_I386_FLOAT_H__ |
#define DBL_DIG 15 |
#define DBL_EPSILON 2.22044604925031300e-016 |
#define DBL_MANT_DIG 53 |
#define DBL_MAX 1.79769313486231500e+308 |
#define DBL_MAX_10_EXP 308 |
#define DBL_MAX_EXP 1024 |
#define DBL_MIN 2.22507385850720200e-308 |
#define DBL_MIN_10_EXP (-307) |
#define DBL_MIN_EXP (-1021) |
#define FLT_DIG 6 |
#define FLT_EPSILON 1.192092896e-7f |
#define FLT_MANT_DIG 24 |
#define FLT_MAX 3.402823466e+38f |
#define FLT_MAX_10_EXP 38 |
#define FLT_MAX_EXP 128 |
#define FLT_MIN 1.175494351e-38f |
#define FLT_MIN_10_EXP (-37) |
#define FLT_MIN_EXP (-125) |
#define FLT_RADIX 2 |
#define FLT_ROUNDS 1 |
#define LDBL_DIG DBL_DIG |
#define LDBL_EPSILON DBL_EPSILON |
#define LDBL_MANT_DIG DBL_MANT_DIG |
#define LDBL_MAX DBL_MAX |
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP |
#define LDBL_MAX_EXP DBL_MAX_EXP |
#define LDBL_MIN DBL_MIN |
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP |
#define LDBL_MIN_EXP DBL_MIN_EXP |
#endif |
/shark/trunk/libc/arch/x86/include/arch/i386/string.h |
---|
0,0 → 1,50 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* String manipulation functions */ |
#ifndef __LL_I386_STRING_H__ |
#define __LL_I386_STRING_H__ |
#include <ll/i386/mem.h> |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* Various string manipulation functions */ |
/* File: String.C */ |
char *strcpy(char *dst,const char *src); |
char *strncpy(char *dst,const char *src,int n); |
int strcmp(const char *s1,const char *s2); |
int strncmp(const char *s1,const char *s2,int n); |
int strlen(const char *s); |
char *strscn(char *s,char *pattern); |
char *strchr(char *s,int c); |
char *strupr(char *s); |
char *strlwr(char *s); |
char *strcat(char *dst,char *src); |
END_DEF |
#endif |
/shark/trunk/libc/arch/x86/include/arch/ctype.h |
---|
0,0 → 1,47 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Standard character conversions and tests */ |
#ifndef __LL_CTYPE_H__ |
#define __LL_CTYPE_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* String conversion functions */ |
char toupper(char c); |
char tolower(char c); |
int tonumber(char c); |
char todigit(int c); |
int isalnum(char c); |
int isalpha(char c); |
int iscntrl(char c); |
int isdigit(char c); |
int islower(char c); |
int isspace(char c); |
int isupper(char c); |
int isxdigit(char c); |
int isnumber(char c,int base); |
int isspecial(double d,char *bufp); |
END_DEF |
#endif |
/shark/trunk/libc/arch/x86/include/arch/stdarg.h |
---|
0,0 → 1,90 |
/* |
* Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
* |
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
* Gerardo Lamastra <gerardo@sssup.it> |
* |
* Authors : Paolo Gai <pj@hartik.sssup.it> |
* (see authors.txt for full list of hartik's authors) |
* |
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
* |
* http://www.sssup.it |
* http://retis.sssup.it |
* http://hartik.sssup.it |
*/ |
/** |
------------ |
CVS : $Id: stdarg.h,v 1.2 2003-03-17 09:27:56 pj Exp $ |
File: $File$ |
Revision: $Revision: 1.2 $ |
Last update: $Date: 2003-03-17 09:27:56 $ |
------------ |
lowlevel's stdarg.h |
**/ |
/* |
* Copyright (C) 2000 Paolo Gai |
* |
* This program 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 2 of the License, or |
* (at your option) any later version. |
* |
* This program 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. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
#ifndef __dj_include_stdarg_h_ |
#define __dj_include_stdarg_h_ |
#include <ll/i386/defs.h> |
#ifndef __dj_ENFORCE_ANSI_FREESTANDING |
#ifdef __dj_include_varargs_h_ |
#error stdarg.h and varargs.h are mutually exclusive |
#endif |
#include <ll/sys/types.h> |
BEGIN_DEF |
#define __dj_va_rounded_size(T) \ |
(((sizeof (T) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) |
#define va_arg(ap, T) \ |
(ap = (va_list) ((char *) (ap) + __dj_va_rounded_size (T)), \ |
*((T *) (void *) ((char *) (ap) - __dj_va_rounded_size (T)))) |
#define va_end(ap) |
#define va_start(ap, last_arg) \ |
(ap = ((va_list) __builtin_next_arg (last_arg))) |
#ifndef __STRICT_ANSI__ |
#ifndef _POSIX_SOURCE |
#endif /* !_POSIX_SOURCE */ |
#endif /* !__STRICT_ANSI__ */ |
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ |
#ifndef __dj_ENFORCE_FUNCTION_CALLS |
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ |
END_DEF |
#endif /* !__dj_include_stdarg_h_ */ |
/shark/trunk/libc/arch/x86/include/arch/errno.h |
---|
0,0 → 1,38 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Stuff needed by the Math library... It wants to set errno!!! */ |
#ifndef __LL_ERRNO_H__ |
#define __LL_ERRNO_H__ |
void seterrnumber(int *(*e)(void)); |
extern int *__errnumber1(); |
/*+ this macro refers the correct errno... +*/ |
#define errno (*__errnumber1()) |
#define __set_errno(val) ((*__errnumber1()) = (val) ) |
#define EDOM 33 |
#define EILSEQ 84 |
#define ERANGE 34 |
#endif |
/shark/trunk/libc/arch/x86/include/arch/float.h |
---|
0,0 → 1,22 |
/* |
* This program 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 2 of the License, or |
* (at your option) any later version. |
* |
* This program 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. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
#ifndef __LL_FLOAT_H__ |
#define __LL_FLOAT_H__ |
#include "i386/float.h" |
#endif |
/shark/trunk/libc/arch/x86/include/arch/string.h |
---|
0,0 → 1,29 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* String operations... */ |
#ifndef __LL_STRING_H__ |
#define __LL_STRING_H__ |
#include "i386/string.h" |
#include <ll/sys/types.h> |
#endif |
/shark/trunk/libc/arch/x86/include/arch/unistd.h |
---|
0,0 → 1,33 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#ifndef __LL_UNISTD_H__ |
#define __LL_UNISTD_H__ |
/* _exit */ |
#include <ll/i386/hw-func.h> |
/* cprintf */ |
#include <ll/i386/cons.h> |
#include <ll/sys/types.h> |
#endif /* !_SYS_UNISTD_H_ */ |
/shark/trunk/libc/arch/x86/include/arch/sys/cdefs.h |
---|
0,0 → 1,147 |
/* |
* 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.7 (Berkeley) 1/21/94 |
*/ |
#ifndef __LL_SYS_CDEFS_H__ |
#define __LL_SYS_CDEFS_H__ |
#if defined(__cplusplus) |
#define __BEGIN_DECLS extern "C" { |
#define __END_DECLS }; |
#else |
#define __BEGIN_DECLS |
#define __END_DECLS |
#endif |
/* |
* 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 -- make sure you don't put spaces |
* in between its arguments. __CONCAT can also concatenate double-quoted |
* strings produced by the __STRING macro, but this only works with ANSI C. |
*/ |
#if defined(__STDC__) || defined(__cplusplus) |
#define __P(protos) protos /* full-blown ANSI C */ |
#define __CONCAT1(x,y) x ## y |
#define __CONCAT(x,y) __CONCAT1(x,y) |
#define __STRING(x) #x |
#define __const const /* define reserved names to standard */ |
#define __signed signed |
#define __volatile volatile |
#if defined(__cplusplus) |
#define __inline inline /* convert to C++ keyword */ |
#else |
#ifndef __GNUC__ |
#define __inline /* delete GCC keyword */ |
#endif /* !__GNUC__ */ |
#endif /* !__cplusplus */ |
#else /* !(__STDC__ || __cplusplus) */ |
#define __P(protos) () /* traditional C preprocessor */ |
#define __CONCAT(x,y) x/**/y |
#define __STRING(x) "x" |
#ifndef __GNUC__ |
#define __const /* delete pseudo-ANSI C keywords */ |
#define __inline |
#define __signed |
#define __volatile |
/* |
* In non-ANSI C environments, new programs will want ANSI-only C keywords |
* deleted from the program and old programs will want them left alone. |
* When using a compiler other than gcc, programs using the ANSI C keywords |
* const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. |
* When using "gcc -traditional", we assume that this is the intent; if |
* __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. |
*/ |
#ifndef NO_ANSI_KEYWORDS |
#define const /* delete ANSI C keywords */ |
#define inline |
#define signed |
#define volatile |
#endif |
#endif /* !NO_ANSI_KEYWORDS */ |
#endif /* !(__STDC__ || __cplusplus) */ |
/* |
* GCC1 and some versions of GCC2 declare dead (non-returning) and |
* pure (no side effects) functions using "volatile" and "const"; |
* unfortunately, these then cause warnings under "-ansi -pedantic". |
* GCC2.5 uses a new, peculiar __attribute__((attrs)) style. All of |
* these work for GNU C++ (modulo a slight glitch in the C++ grammar |
* in the distribution version of 2.5.5). |
*/ |
#if __GNUC__ < 2 |
#define __dead |
#define __dead2 |
#define __pure |
#define __pure2 |
#define __attribute__(x) |
#endif |
#if __GNUC__ == 2 && __GNUC_MINOR__ < 5 |
#define __dead __volatile |
#define __dead2 |
#define __pure __const |
#define __pure2 |
#endif |
#if __GNUC__ == 2 && __GNUC_MINOR__ > 5 || __GNUC__ >= 3 |
#define __dead |
#define __dead2 __attribute__((noreturn)) |
#define __pure |
#define __pure2 __attribute__((const)) |
#endif |
#ifdef __GNUC__ |
#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 |
#endif |
#endif /* !_SYS_CDEFS_H_ */ |
/shark/trunk/libc/arch/x86/reboot.c |
---|
0,0 → 1,75 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Reset (or halt...) the system */ |
#include <ll/i386/hw-func.h> |
#include <ll/i386/error.h> |
FILE(reboot); |
int no_idt[] = { 0, 0 }; |
void halt(void) |
{ |
cputs("Halt called"); |
__asm__("hlt"); |
} |
/* |
* This code has been taken by the Linux Kernel and it has been |
* freely modified and simplified to do a reboot! |
*/ |
void cold_reboot(void) |
{ |
reboot(0); |
} |
void warm_reboot(void) |
{ |
reboot(0x1234); |
} |
/* |
* This routine reboots the machine by asking the keyboard |
* controller to pulse the reset-line low. If mode = 0x1234 you |
* tell to BIOS to do a warm boot, else cold boot is performed! |
*/ |
void reboot(int mode) |
{ |
register int n, i,j; |
lmempokew((LIN_ADDR)0x472,mode); |
for (n = 0; n < 100; n++) { |
// Wait for keyboard controller ready |
for (i=0; i<0x10000; i++) |
if ((inp(0x64) & 0x02) == 0) break; |
// Do nothing for a while... |
for(j = 0; j < 100000 ; j++); |
// pulse reset low |
outp(0xfe,0x64); |
// Do nothing for a while... |
for(j = 0; j < 100000 ; j++); |
} |
/* That didn't work - force a triple fault.. */ |
// __asm__ __volatile__("lidt %0": :"m" (no_idt)); |
// __asm__ __volatile__("int3"); |
} |
/shark/trunk/libc/arch/x86/modf.s |
---|
0,0 → 1,59 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Assembler portion of the library: |
function: modf! */ |
#include <ll/i386/linkage.h> |
.text |
.globl SYMBOL_NAME(modf) |
SYMBOL_NAME_LABEL(modf) |
pushl %ebp |
movl %esp,%ebp |
subl $16,%esp |
pushl %ebx |
fnstcw -4(%ebp) |
fwait |
movw -4(%ebp),%ax |
orw $0x0c3f,%ax |
movw %ax,-8(%ebp) |
fldcw -8(%ebp) |
fwait |
fldl 8(%ebp) |
frndint |
fstpl -16(%ebp) |
fwait |
movl -16(%ebp),%edx |
movl -12(%ebp),%ecx |
movl 16(%ebp),%ebx |
movl %edx,(%ebx) |
movl %ecx,4(%ebx) |
fldl 8(%ebp) |
fsubl -16(%ebp) |
leal -20(%ebp),%esp |
fclex |
fldcw -4(%ebp) |
fwait |
popl %ebx |
leave |
ret |
/shark/trunk/libc/libio/makefile |
---|
File deleted |
/shark/trunk/libc/libio/Makefile |
---|
0,0 → 1,16 |
targets:= \ |
close.o \ |
dir.o \ |
dup.o \ |
dup2.o \ |
getcwd.o \ |
getumask.o \ |
getwd.o \ |
lseek.o \ |
read.o \ |
truncate.o \ |
umask.o \ |
unlink.o \ |
wrappers.o \ |
write.o |
/shark/trunk/arch/x86/x1.c |
---|
0,0 → 1,143 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* File: X1.C */ |
/* Startup code: */ |
/* Build parameters list & make info accessible */ |
#include <arch/stdlib.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/mb-info.h> |
#include <ll/i386/mem.h> |
FILE(X1); |
/* #define __DUMP_MEM__ */ |
/* We need to copy from X address space to the application space */ |
/* the info structure to allow pointer access using flat model */ |
/* Remember that flat model is similar to small model also if we */ |
/* can see the whole memory, because it has no explicit far */ |
/* pointers; then if we pass into _args[] the address of the */ |
/* string of the n-th argument it could not be correctly accessed */ |
/* because it lies in a memory zone unseen from PM application. */ |
/* This is due to the ELF format which has no relocation info */ |
/* since the file is already relocated starting from address 0! */ |
/* Then the PM application cannot see a real flat memory (segment */ |
/* with 0 base) but CS,DS & SS MUST have the base correctly set. */ |
/* Refer to this figure: */ |
/* */ |
/* DOS Memory <- X is there */ |
/* */ |
/* EXTENDED Memory -----[ */ |
/* [ */ |
/* Address xxxx [ <- Application code is here! */ |
/* [ */ |
/* Address yyyy [ <- Application Data & Stack! */ |
/* */ |
/* Then CS has xxxx base while DS & SS have yyyy base! */ |
/* Stack base address; use this to check stack overflow! */ |
/* With Flat model I do not think we can use 386 protection */ |
/* to detect a stack overflow; anyway Watcom C use a standard */ |
/* function __CHK to detect it! The compiler place it whenever */ |
/* it calls a function to detect overflow */ |
DWORD _stkbase; |
DWORD _stktop; |
/* This is some extra stuff we need to compile with argument */ |
/* passing and math extensions */ |
DWORD _argc = 0; |
typedef char *charp; |
charp _argv[100]; |
extern void __kernel_init__(int argc, char *argv[]); |
extern void bios_save(void); |
extern void bios_restore(void); |
/* This is used in GNU-C to implement C++ constructors/destructors */ |
/* See the lib sources for more details */ |
void __main(int argc, char **argv) |
{ |
} |
struct multiboot_info * mbi_address(void) |
{ |
/* This is declared in [wc32/gnu]\x0.[asm/s] */ |
extern struct multiboot_info *mbi; |
return (mbi); |
} |
void _startup(void) |
{ |
register int i = 0; |
char temp[1000]; |
struct multiboot_info *mbi = mbi_address(); |
char *cmdline = (char *)(mbi->cmdline); |
if (!(mbi->flags & MB_INFO_MEMORY)) { |
cputs("X/Runtime library error!!! Unable to find memory information!\n"); |
l1_exit(-1); |
} |
if (mbi->flags & MB_INFO_CMDLINE) { |
/* Build parameter list, up to 100 parms... */ |
while (cmdline[i] != 0 && i < 1000) { |
temp[i] = cmdline[i]; |
_argv[_argc] = &(temp[i]); |
while (cmdline[i] != ' ' && cmdline[i] != 0 && i < 1000) { |
temp[i] = cmdline[i]; |
i++; |
} |
if (cmdline[i] == ' ') { |
temp[i] = 0; i++; _argc++; |
} |
} |
temp[i] = 0; |
_argc++; |
} |
bios_save(); |
/* Call main procedure using standard C convention */ |
/* Remember you cannot call any console I/O function */ |
/* if you do not call bios_save() */ |
#ifdef __DUMP_MEM__ |
message("X/MEM : %u\n",mbi->mem_upper); |
message("DOS/MEM : %u\n",mbi->mem_lower); |
message("x_bios Size : %u\n",sizeof(X_BIOSCALL)); |
message("mbi Size : %u\n",sizeof(struct multiboot_info)); |
message("Cmdline : %s\n",mbi->cmdline); |
message("Argc : %u\n",_argc); |
message("Argv[0] : %s\n",_argv[0]); |
message("Argv[1] : %s\n",_argv[1]); |
message("Argv[2] : %s\n",_argv[2]); |
message("Argv[3] : %s\n",_argv[3]); |
#endif |
__kernel_init__(_argc,_argv); |
bios_restore(); |
} |
/shark/trunk/arch/x86/Makefile |
---|
0,0 → 1,36 |
targets:= \ |
abort.o \ |
advtimer.o \ |
aspace.o \ |
ccpu.o \ |
cpu2.o \ |
ctx.o \ |
cxsw-2.o \ |
ctxsw.o \ |
event.o \ |
event1.o \ |
exc.o \ |
fpu.o \ |
idtinit.o \ |
init.o \ |
intevt.o \ |
irq.o \ |
mem.o \ |
time.o \ |
timeint.o \ |
vm86.o \ |
x1.o \ |
xbios.o \ |
xconv.o \ |
xdosf.o \ |
xdosm.o \ |
xinfo.o \ |
xsystab.o \ |
xinit.o \ |
xsys0.o |
install-objs:= x0.o |
aflags+= -D__VIRCSW__ |
cppflags+= -I$(srctree)/libc/arch/$(ARCH)/include -D__VIRCSW__ |
/shark/trunk/arch/x86/mem.s |
---|
0,0 → 1,63 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Memcopy to other address spaces */ |
#include <ll/i386/linkage.h> |
#include <ll/i386/defs.h> |
.data |
ASMFILE(Mem-ASM) |
.text |
.globl SYMBOL_NAME(fmemcpy) |
/* void fmemcpy(unsigned short ds,unsigned long do, |
unsigned short ss,unsigned long so,unsigned n) */ |
SYMBOL_NAME_LABEL(fmemcpy) |
/* Build the standard stack frame */ |
pushl %ebp |
movl %esp,%ebp |
pushl %esi |
pushl %edi |
pushw %ds |
pushw %es |
/* Get parms into register */ |
movl 8(%ebp),%eax |
movw %ax,%es |
movl 12(%ebp),%edi |
movl 16(%ebp),%eax |
movw %ax,%ds |
movl 20(%ebp),%esi |
movl 24(%ebp),%ecx |
cld |
rep |
movsb |
popw %es |
popw %ds |
popl %edi |
popl %esi |
leave |
ret |
/shark/trunk/arch/x86/init.c |
---|
0,0 → 1,242 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* KL initialization code */ |
#include <arch/i386/stdlib.h> |
#include <ll/i386/x-bios.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/mb-info.h> |
#include <ll/i386/error.h> |
#include <ll/i386/pit.h> |
#include <ll/i386/pic.h> |
#include <ll/i386/advtimer.h> |
#include <ll/i386/tss-ctx.h> |
#include <ll/i386/hw-arch.h> |
#include <ll/sys/ll/ll-func.h> |
#include <ll/sys/ll/ll-mem.h> |
#include <ll/sys/ll/ll-instr.h> |
#include <ll/sys/ll/event.h> /* for irq_bind() & irq_init() */ |
#include <ll/sys/ll/exc.h> /* These are the HW exceptions */ |
FILE(LL-Init); |
/* These are declared in llCx32b.C */ |
TSS TSS_table[TSSMax]; |
WORD TSS_control[TSSMax]; |
BYTE ll_FPU_stdctx[FPU_CONTEXT_SIZE]; |
void debug_info(void) { |
static DWORD fault_ip; |
static DWORD fault_cs; |
static DWORD error_code; |
static DWORD fault_eflag; |
static DWORD sp; |
static DWORD fault_sp; |
static DWORD data0; |
static DWORD data1; |
static DWORD data2; |
static DWORD sdata4; |
static DWORD sdata8; |
asm (" movl %%esp,%0\n\t":"=r"(sp)); |
asm (" movl -8(%%ebp),%0\n\t":"=r"(sdata8)); |
asm (" movl -4(%%ebp),%0\n\t":"=r"(sdata4)); |
asm (" movl 0(%%ebp),%0\n\t":"=r"(data0)); |
asm (" movl 4(%%ebp),%0\n\t":"=r"(error_code)); |
asm (" movl 8(%%ebp),%0\n\t":"=r"(fault_ip)); |
asm (" movl 12(%%ebp),%0\n\t":"=r"(fault_cs)); |
asm (" movl 16(%%ebp),%0\n\t":"=r"(fault_eflag)); |
asm (" movl 20(%%ebp),%0\n\t":"=r"(fault_sp)); |
asm (" movl 24(%%ebp),%0\n\t":"=r"(data1)); |
message(":F -8: %lx:", sdata8); |
message(":F -4: %lx:", sdata4); |
message(":F 0: %lx:", data0); |
message(":F ec/4: %lx:", error_code); |
message(":F ip/8: %lx:", fault_ip); |
message(":F cs/12 : %lx:", fault_cs); |
message(":F eflag/16 : %lx:", fault_eflag); |
message(":F sp/20 : %lx:", fault_sp); |
message(":F 24 : %lx:", data1); |
} |
void ll_exc_hook(int i) |
{ |
static char *exc_mess[] = { |
"#Division by 0", |
"#Debug fault", |
"#NMI detected", |
"#Breakpoint trap", |
"#Overflow detected on INTO", |
"#BOUND limit exceeded", |
"*Unvalid opcode", |
"1FPU context switch", /* Handled in the llCtx.Asm/S File */ |
"*Double defect", |
"#INTEL reserved", |
"*Unvalid TSS", |
"*Segment not present", |
"*Stack exception", |
"*General protection fault", |
"#Page fault", |
"#INTEL reserved", |
"2Coprocessor error" |
}; |
static int exc_code[] = { |
DIV_BY_0, NMI_EXC, DEBUG_EXC, BREAKPOINT_EXC, |
HW_FAULT, HW_FAULT, HW_FAULT, |
0, /* This is the FPU ctx Switch */ |
HW_FAULT, HW_FAULT, HW_FAULT, HW_FAULT, |
HW_FAULT, HW_FAULT, HW_FAULT, HW_FAULT, |
MATH_EXC |
}; |
char code = *exc_mess[i]; |
#ifdef __LL_DEBUG__ |
extern long int ndp_called,ndp_switched; |
extern wu_called; |
extern ai_called; |
extern DWORD *smain; |
#endif |
/* Math error! FPU has to be acknowledgded */ |
if (code == '2') ll_out(0x0F0,0); |
message("Exception %d occurred\n", i); |
message("%s\n", &exc_mess[i][1]); |
#ifdef __LL_DEBUG__ |
if (code == '*') { |
/* Dump additional info */ |
message("DS:%nx CS:%nx\n",get_DS(),get_CS()); |
/* message("WU : %d AI : %d\n",wu_called,ai_called); */ |
message("Actual stack : %x\n",get_SP()); |
/* message("Main stack : %p\n",smain); */ |
dump_TSS(get_TR()); |
} |
#endif |
/* halt(); */ |
message("Actual stack : %x\n",get_SP()); |
dump_TSS(get_TR()); |
ll_abort(exc_code[i]); |
} |
void *ll_init(void) |
{ |
void *p; |
int i; |
LIN_ADDR b; |
/* |
DWORD s; |
BYTE *base; |
*/ |
TSS dummy_tss; /* Very dirty, but we need it, in order to |
get an initial value for the FPU |
context... |
*/ |
p = l1_init(); |
/* First of all, init the exc and irq tables... */ |
irq_init(); |
for(i = 0; i < 32; i++) { |
/* Warning!!! The hw exceptions should be 32.... Fix it!!! */ |
/* |
ll_irq_table[i] = (DWORD)act_int; |
ll_exc_table[i] = (DWORD)ll_exc_hook; |
*/ |
l1_exc_bind(i, ll_exc_hook); |
} |
for(i = 0; i < 16; i++) { |
void act_int(int i); |
l1_irq_bind(i, act_int); |
} |
/* Init TSS table & put the corrispondent selectors into GDT */ |
TSS_control[TSSMain] |= TSS_USED; |
for (i = 0; i < TSSMax; i++) { |
/* b = appl2linear(&TSS_table[i]); */ |
b = (LIN_ADDR)(&TSS_table[i]); |
GDT_place(TSSindex2sel(i),(DWORD)b,sizeof(TSS),FREE_TSS386, GRAN_16); |
} |
#if 0 |
ll_FPU_save(); |
memcpy(ll_FPU_stdctx,ll_FPU_savearea,FPU_CONTEXT_SIZE); |
#else |
save_fpu(&dummy_tss); /* OK???*/ |
memcpy(ll_FPU_stdctx, dummy_tss.ctx_FPU, FPU_CONTEXT_SIZE); |
#endif |
init_fpu(); |
/* ll_mem_init must be explicitelly called by program... */ |
#if 0 |
/* Get info about extended memory! We suppose that X has loaded */ |
/* there the application; if you switch to DOS memory, then you */ |
/* have to change the stuff in order it works; check X_... for */ |
/* details. */ |
X_meminfo(&b,&s,NULL,NULL); |
base = (BYTE *)b; |
#ifdef __MEM_DEBUG__ |
message("PM Free Mem Base : %lx\n",b); |
message("PM null addr (0L) : %lx\n",appl2linear((void *)0L)); |
message("PM Free Mem Base (Cnvrtd): %lp\n",base); |
#endif |
ll_mem_init(base,s); |
#ifdef __MEM_DEBUG__ |
ll_mem_dump(); |
#endif |
#endif |
return p; |
} |
void abort_tail(int code) |
{ |
message("ABORT %d !!!",code); |
ll_restore_adv(); |
l1_end(); |
sti(); |
l1_exit(1); |
} |
void ll_end(void) |
{ |
ll_restore_adv(); |
l1_end(); |
} |
/shark/trunk/arch/x86/idtinit.c |
---|
0,0 → 1,544 |
/* |
* This program 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 2 of the License, or |
* (at your option) any later version. |
* |
* This program 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. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-func.h> |
/* ll hardware interrupt hooks */ |
extern void h0(void); |
extern void h1(void); |
extern void h2(void); |
extern void h3(void); |
extern void h4(void); |
extern void h5(void); |
extern void h6(void); |
extern void exc7(void); |
extern void h8(void); |
extern void h9(void); |
extern void h10(void); |
extern void h11(void); |
extern void h12(void); |
extern void h13(void); |
extern void h14(void); |
extern void h15(void); |
extern void h16(void); |
extern void h17(void); |
extern void h18(void); |
extern void h19(void); |
extern void h20(void); |
extern void h21(void); |
extern void h22(void); |
extern void h23(void); |
extern void h24(void); |
extern void h25(void); |
extern void h26(void); |
extern void h27(void); |
extern void h28(void); |
extern void h29(void); |
extern void h30(void); |
extern void h31(void); |
extern void h32(void); |
extern void h33(void); |
extern void h34(void); |
extern void h35(void); |
extern void h36(void); |
extern void h37(void); |
extern void h38(void); |
extern void h39(void); |
extern void h40(void); |
extern void h41(void); |
extern void h42(void); |
extern void h43(void); |
extern void h44(void); |
extern void h45(void); |
extern void h46(void); |
extern void h47(void); |
extern void h48(void); |
extern void h49(void); |
extern void h50(void); |
extern void h51(void); |
extern void h52(void); |
extern void h53(void); |
extern void h54(void); |
extern void h55(void); |
extern void h56(void); |
extern void h57(void); |
extern void h58(void); |
extern void h59(void); |
extern void h60(void); |
extern void h61(void); |
extern void h62(void); |
extern void h63(void); |
extern void h64(void); |
extern void h65(void); |
extern void h66(void); |
extern void h67(void); |
extern void h68(void); |
extern void h69(void); |
extern void h70(void); |
extern void h71(void); |
extern void h72(void); |
extern void h73(void); |
extern void h74(void); |
extern void h75(void); |
extern void h76(void); |
extern void h77(void); |
extern void h78(void); |
extern void h79(void); |
extern void h80(void); |
extern void h81(void); |
extern void h82(void); |
extern void h83(void); |
extern void h84(void); |
extern void h85(void); |
extern void h86(void); |
extern void h87(void); |
extern void h88(void); |
extern void h89(void); |
extern void h90(void); |
extern void h91(void); |
extern void h92(void); |
extern void h93(void); |
extern void h94(void); |
extern void h95(void); |
extern void h96(void); |
extern void h97(void); |
extern void h98(void); |
extern void h99(void); |
extern void h100(void); |
extern void h101(void); |
extern void h102(void); |
extern void h103(void); |
extern void h104(void); |
extern void h105(void); |
extern void h106(void); |
extern void h107(void); |
extern void h108(void); |
extern void h109(void); |
extern void h110(void); |
extern void h111(void); |
extern void h112(void); |
extern void h113(void); |
extern void h114(void); |
extern void h115(void); |
extern void h116(void); |
extern void h117(void); |
extern void h118(void); |
extern void h119(void); |
extern void h120(void); |
extern void h121(void); |
extern void h122(void); |
extern void h123(void); |
extern void h124(void); |
extern void h125(void); |
extern void h126(void); |
extern void h127(void); |
extern void h128(void); |
extern void h129(void); |
extern void h130(void); |
extern void h131(void); |
extern void h132(void); |
extern void h133(void); |
extern void h134(void); |
extern void h135(void); |
extern void h136(void); |
extern void h137(void); |
extern void h138(void); |
extern void h139(void); |
extern void h140(void); |
extern void h141(void); |
extern void h142(void); |
extern void h143(void); |
extern void h144(void); |
extern void h145(void); |
extern void h146(void); |
extern void h147(void); |
extern void h148(void); |
extern void h149(void); |
extern void h150(void); |
extern void h151(void); |
extern void h152(void); |
extern void h153(void); |
extern void h154(void); |
extern void h155(void); |
extern void h156(void); |
extern void h157(void); |
extern void h158(void); |
extern void h159(void); |
extern void h160(void); |
extern void h161(void); |
extern void h162(void); |
extern void h163(void); |
extern void h164(void); |
extern void h165(void); |
extern void h166(void); |
extern void h167(void); |
extern void h168(void); |
extern void h169(void); |
extern void h170(void); |
extern void h171(void); |
extern void h172(void); |
extern void h173(void); |
extern void h174(void); |
extern void h175(void); |
extern void h176(void); |
extern void h177(void); |
extern void h178(void); |
extern void h179(void); |
extern void h180(void); |
extern void h181(void); |
extern void h182(void); |
extern void h183(void); |
extern void h184(void); |
extern void h185(void); |
extern void h186(void); |
extern void h187(void); |
extern void h188(void); |
extern void h189(void); |
extern void h190(void); |
extern void h191(void); |
extern void h192(void); |
extern void h193(void); |
extern void h194(void); |
extern void h195(void); |
extern void h196(void); |
extern void h197(void); |
extern void h198(void); |
extern void h199(void); |
extern void h200(void); |
extern void h201(void); |
extern void h202(void); |
extern void h203(void); |
extern void h204(void); |
extern void h205(void); |
extern void h206(void); |
extern void h207(void); |
extern void h208(void); |
extern void h209(void); |
extern void h210(void); |
extern void h211(void); |
extern void h212(void); |
extern void h213(void); |
extern void h214(void); |
extern void h215(void); |
extern void h216(void); |
extern void h217(void); |
extern void h218(void); |
extern void h219(void); |
extern void h220(void); |
extern void h221(void); |
extern void h222(void); |
extern void h223(void); |
extern void h224(void); |
extern void h225(void); |
extern void h226(void); |
extern void h227(void); |
extern void h228(void); |
extern void h229(void); |
extern void h230(void); |
extern void h231(void); |
extern void h232(void); |
extern void h233(void); |
extern void h234(void); |
extern void h235(void); |
extern void h236(void); |
extern void h237(void); |
extern void h238(void); |
extern void h239(void); |
extern void h240(void); |
extern void h241(void); |
extern void h242(void); |
extern void h243(void); |
extern void h244(void); |
extern void h245(void); |
extern void h246(void); |
extern void h247(void); |
extern void h248(void); |
extern void h249(void); |
extern void h250(void); |
extern void h251(void); |
extern void h252(void); |
extern void h253(void); |
extern void h254(void); |
extern void h255(void); |
void IDT_init(void) |
{ |
/* Insert the Exceptions handler into IDT */ |
IDT_place(0x00, h0); |
IDT_place(0x01, h1); |
IDT_place(0x02, h2); |
IDT_place(0x03, h3); |
IDT_place(0x04, h4); |
IDT_place(0x05, h5); |
IDT_place(0x06, h6); |
IDT_place(0x07, exc7); |
IDT_place(0x08, h8); |
IDT_place(0x09, h9); |
IDT_place(0x0A, h10); |
IDT_place(0x0B, h11); |
IDT_place(0x0C, h12); |
IDT_place(0x0D, h13); |
IDT_place(0x0E, h14); |
IDT_place(0x0F, h15); |
IDT_place(0x10, h16); |
IDT_place(0x11, h17); |
IDT_place(0x12, h18); |
IDT_place(0x13, h19); |
IDT_place(0x14, h20); |
IDT_place(0x15, h21); |
IDT_place(0x16, h22); |
IDT_place(0x17, h23); |
IDT_place(0x18, h24); |
IDT_place(0x19, h25); |
IDT_place(0x1A, h26); |
IDT_place(0x1B, h27); |
IDT_place(0x1C, h28); |
IDT_place(0x1D, h29); |
IDT_place(0x1E, h30); |
IDT_place(0x1F, h31); |
IDT_place(0x20, h32); |
IDT_place(0x21, h33); |
IDT_place(0x22, h34); |
IDT_place(0x23, h35); |
IDT_place(0x24, h36); |
IDT_place(0x25, h37); |
IDT_place(0x26, h38); |
IDT_place(0x27, h39); |
IDT_place(0x28, h40); |
IDT_place(0x29, h41); |
IDT_place(0x2A, h42); |
IDT_place(0x2B, h43); |
IDT_place(0x2C, h44); |
IDT_place(0x2D, h45); |
IDT_place(0x2E, h46); |
IDT_place(0x2F, h47); |
IDT_place(0x30, h48); |
IDT_place(0x31, h49); |
IDT_place(0x32, h50); |
IDT_place(0x33, h51); |
IDT_place(0x34, h52); |
IDT_place(0x35, h53); |
IDT_place(0x36, h54); |
IDT_place(0x37, h55); |
IDT_place(0x38, h56); |
IDT_place(0x39, h57); |
IDT_place(0x3A, h58); |
IDT_place(0x3B, h59); |
IDT_place(0x3C, h60); |
IDT_place(0x3D, h61); |
IDT_place(0x3E, h62); |
IDT_place(0x3F, h63); |
IDT_place(0x40, h64); |
IDT_place(0x41, h65); |
IDT_place(0x42, h66); |
IDT_place(0x43, h67); |
IDT_place(0x44, h68); |
IDT_place(0x45, h69); |
IDT_place(0x46, h70); |
IDT_place(0x47, h71); |
IDT_place(0x48, h72); |
IDT_place(0x49, h73); |
IDT_place(0x4A, h74); |
IDT_place(0x4B, h75); |
IDT_place(0x4C, h76); |
IDT_place(0x4D, h77); |
IDT_place(0x4E, h78); |
IDT_place(0x4F, h79); |
IDT_place(0x50, h80); |
IDT_place(0x51, h81); |
IDT_place(0x52, h82); |
IDT_place(0x53, h83); |
IDT_place(0x54, h84); |
IDT_place(0x55, h85); |
IDT_place(0x56, h86); |
IDT_place(0x57, h87); |
IDT_place(0x58, h88); |
IDT_place(0x59, h89); |
IDT_place(0x5A, h90); |
IDT_place(0x5B, h91); |
IDT_place(0x5C, h92); |
IDT_place(0x5D, h93); |
IDT_place(0x5E, h94); |
IDT_place(0x5F, h95); |
IDT_place(0x60, h96); |
IDT_place(0x61, h97); |
IDT_place(0x62, h98); |
IDT_place(0x63, h99); |
IDT_place(0x64, h100); |
IDT_place(0x65, h101); |
IDT_place(0x66, h102); |
IDT_place(0x67, h103); |
IDT_place(0x68, h104); |
IDT_place(0x69, h105); |
IDT_place(0x6A, h106); |
IDT_place(0x6B, h107); |
IDT_place(0x6C, h108); |
IDT_place(0x6D, h109); |
IDT_place(0x6E, h110); |
IDT_place(0x6F, h111); |
IDT_place(0x70, h112); |
IDT_place(0x71, h113); |
IDT_place(0x72, h114); |
IDT_place(0x73, h115); |
IDT_place(0x74, h116); |
IDT_place(0x75, h117); |
IDT_place(0x76, h118); |
IDT_place(0x77, h119); |
IDT_place(0x78, h120); |
IDT_place(0x79, h121); |
IDT_place(0x7A, h122); |
IDT_place(0x7B, h123); |
IDT_place(0x7C, h124); |
IDT_place(0x7D, h125); |
IDT_place(0x7E, h127); |
IDT_place(0x7F, h127); |
IDT_place(0x80, h128); |
IDT_place(0x81, h129); |
IDT_place(0x82, h130); |
IDT_place(0x83, h131); |
IDT_place(0x84, h132); |
IDT_place(0x85, h133); |
IDT_place(0x86, h134); |
IDT_place(0x87, h135); |
IDT_place(0x88, h136); |
IDT_place(0x89, h137); |
IDT_place(0x8A, h138); |
IDT_place(0x8B, h139); |
IDT_place(0x8C, h140); |
IDT_place(0x8D, h141); |
IDT_place(0x8E, h142); |
IDT_place(0x8F, h143); |
IDT_place(0x90, h144); |
IDT_place(0x91, h145); |
IDT_place(0x92, h146); |
IDT_place(0x93, h147); |
IDT_place(0x94, h148); |
IDT_place(0x95, h149); |
IDT_place(0x96, h150); |
IDT_place(0x97, h151); |
IDT_place(0x98, h152); |
IDT_place(0x99, h153); |
IDT_place(0x9A, h154); |
IDT_place(0x9B, h155); |
IDT_place(0x9C, h156); |
IDT_place(0x9D, h157); |
IDT_place(0x9E, h158); |
IDT_place(0x9F, h159); |
IDT_place(0xA0, h160); |
IDT_place(0xA1, h161); |
IDT_place(0xA2, h162); |
IDT_place(0xA3, h163); |
IDT_place(0xA4, h164); |
IDT_place(0xA5, h165); |
IDT_place(0xA6, h166); |
IDT_place(0xA7, h167); |
IDT_place(0xA8, h168); |
IDT_place(0xA9, h169); |
IDT_place(0xAA, h170); |
IDT_place(0xAB, h171); |
IDT_place(0xAC, h172); |
IDT_place(0xAD, h173); |
IDT_place(0xAE, h174); |
IDT_place(0xAF, h175); |
IDT_place(0xB0, h176); |
IDT_place(0xB1, h177); |
IDT_place(0xB2, h178); |
IDT_place(0xB3, h179); |
IDT_place(0xB4, h180); |
IDT_place(0xB5, h181); |
IDT_place(0xB6, h182); |
IDT_place(0xB7, h183); |
IDT_place(0xB8, h184); |
IDT_place(0xB9, h185); |
IDT_place(0xBA, h186); |
IDT_place(0xBB, h187); |
IDT_place(0xBC, h188); |
IDT_place(0xBD, h189); |
IDT_place(0xBE, h190); |
IDT_place(0xBF, h191); |
IDT_place(0xC0, h192); |
IDT_place(0xC1, h193); |
IDT_place(0xC2, h194); |
IDT_place(0xC3, h195); |
IDT_place(0xC4, h196); |
IDT_place(0xC5, h197); |
IDT_place(0xC6, h198); |
IDT_place(0xC7, h199); |
IDT_place(0xC8, h200); |
IDT_place(0xC9, h201); |
IDT_place(0xCA, h202); |
IDT_place(0xCB, h203); |
IDT_place(0xCC, h204); |
IDT_place(0xCD, h205); |
IDT_place(0xCE, h206); |
IDT_place(0xCF, h207); |
IDT_place(0xD0, h208); |
IDT_place(0xD1, h209); |
IDT_place(0xD2, h210); |
IDT_place(0xD3, h211); |
IDT_place(0xD4, h212); |
IDT_place(0xD5, h213); |
IDT_place(0xD6, h214); |
IDT_place(0xD7, h215); |
IDT_place(0xD8, h216); |
IDT_place(0xD9, h217); |
IDT_place(0xDA, h218); |
IDT_place(0xDB, h219); |
IDT_place(0xDC, h220); |
IDT_place(0xDD, h221); |
IDT_place(0xDE, h222); |
IDT_place(0xDF, h223); |
IDT_place(0xE0, h224); |
IDT_place(0xE1, h225); |
IDT_place(0xE2, h226); |
IDT_place(0xE3, h227); |
IDT_place(0xE4, h228); |
IDT_place(0xE5, h229); |
IDT_place(0xE6, h230); |
IDT_place(0xE7, h231); |
IDT_place(0xE8, h232); |
IDT_place(0xE9, h233); |
IDT_place(0xEA, h234); |
IDT_place(0xEB, h235); |
IDT_place(0xEC, h236); |
IDT_place(0xED, h237); |
IDT_place(0xEE, h238); |
IDT_place(0xEF, h239); |
IDT_place(0xF0, h240); |
IDT_place(0xF1, h241); |
IDT_place(0xF2, h242); |
IDT_place(0xF3, h243); |
IDT_place(0xF4, h244); |
IDT_place(0xF5, h245); |
IDT_place(0xF6, h246); |
IDT_place(0xF7, h247); |
IDT_place(0xF8, h248); |
IDT_place(0xF9, h249); |
IDT_place(0xFA, h250); |
IDT_place(0xFB, h251); |
IDT_place(0xFC, h252); |
IDT_place(0xFD, h253); |
IDT_place(0xFE, h254); |
IDT_place(0xFF, h255); |
} |
/shark/trunk/arch/x86/x0.s |
---|
0,0 → 1,237 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The first things to do when an OSLib application starts : */ |
/* Set up segment registers & stack; then execute startup code */ |
/* When the application returns the gate-jmp make us return to */ |
/* RM through X interface! */ |
/* Use X standard GDT selectors */ |
#include <ll/i386/sel.h> |
#include <ll/i386/linkage.h> |
#include <ll/i386/defs.h> |
#include <ll/i386/mb-hdr.h> |
/* #define __DEBUG__ */ |
#ifdef __LINUX__ /* ELF mode */ |
#define MULTIBOOT_FLAGS (MULTIBOOT_MEMORY_INFO) |
#else /* else it is COFF! */ |
#define MULTIBOOT_FLAGS (MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE) |
#endif |
.extern SYMBOL_NAME(_startup) |
.extern SYMBOL_NAME(_stkbase) |
.extern SYMBOL_NAME(_stktop) |
.extern SYMBOL_NAME(halt) |
.data |
ASMFILE(X0) |
.globl SYMBOL_NAME(IDT) |
.globl SYMBOL_NAME(GDT_base) |
.globl SYMBOL_NAME(mb_signature) |
.globl SYMBOL_NAME(mbi) |
/* GDT Definition */ |
GDT: |
.word 0,0,0,0 /* X_NULL_SEL */ |
.word 0,0,0,0 /* X_DATA16_SEL */ |
.word 0,0,0,0 /* X_CODE16_SEL */ |
.word 0,0,0,0 /* X_CODE32_SEL */ |
/* X_RM_BACK_GATE */ |
rmBckGateFix1: /* X_FLATCODE_SEL */ |
.word 0 |
.word X_FLATCODE_SEL |
.word 0x8C00 |
rmBckGateFix2: |
.word 0 |
.word 0,0,0,0 /* X_PM_BACK_GATE */ |
.word 0xFFFF /* X_FLATDATA_SEL */ |
.word 0 |
.word 0x9200 |
.word 0x00CF |
.word 0xFFFF /* X_FLATCODE_SEL */ |
.word 0 |
.word 0x9A00 |
.word 0x00CF |
.word 0,0,0,0 /* X_CALLBIOS_SEL */ |
.word 0,0,0,0 /* X_CALLBIOS_GATE */ |
.word 0,0,0,0 /* X_VM86_TSS */ |
.word 0,0,0,0 /* X_MAIN_TSS */ |
.fill 256 - 12,8,0 |
GDT_descr: |
.word 256*8-1 |
SYMBOL_NAME_LABEL(GDT_base) |
.long GDT |
IDT_descr: |
.word 256*8-1 # idt contains 256 entries |
.long SYMBOL_NAME(IDT) |
/* MultiBoot Data Stuff definition */ |
SYMBOL_NAME_LABEL(mb_signature) .long 0 |
SYMBOL_NAME_LABEL(mbi) .long 0 |
.bss /* This MUST be in the BSS !!! */ |
/* IDT definition */ |
SYMBOL_NAME_LABEL(IDT) |
.fill 256,8,0 # idt is uninitialized |
/* Protected mode stack */ |
base: |
.space 8192,0 |
tos: |
.text |
.globl SYMBOL_NAME(_start) |
.globl SYMBOL_NAME(__exit) |
.globl SYMBOL_NAME(start) |
.globl start |
SYMBOL_NAME_LABEL(_start) |
SYMBOL_NAME_LABEL(start) |
start: |
.align 8 |
/*start:*/ |
jmp boot_entry |
/* |
Here we go with the multiboot header... |
--------------------------------------- |
*/ |
.align 8 |
boot_hdr: |
.align 8 |
.long MULTIBOOT_MAGIC |
.long MULTIBOOT_FLAGS |
/* Checksum */ |
.long -(MULTIBOOT_MAGIC+MULTIBOOT_FLAGS) |
#ifndef __LINUX__ /* COFF mode */ |
.long boot_hdr |
/* .long SYMBOL_NAME(start)*/ |
.long start |
.long _edata |
.long _end |
.long boot_entry |
#endif |
boot_entry: /* Just a brief debug check */ |
#ifdef __DEBUG__ |
/* A Brown 1 should appear... */ |
movl $0xB8000,%edi |
addl $158,%edi |
movb $'1',%gs:0(%edi) |
incl %edi |
movb $6,%gs:0(%edi) |
#endif |
/* |
* Hopefully if it gets here, CS & DS are |
* Correctly set for FLAT LINEAR mode |
*/ |
/* Test if GDT is usable */ |
movl %gs:0(%ebx),%ecx |
andl $0x0200,%ecx /* MB_INFO_BOOT_LOADER_NAME */ |
movl $0xB8000,%edi |
addl $150,%edi |
movb $'1',%gs:0(%edi) |
incl %edi |
movb $6,%gs:0(%edi) |
jz GDT_is_not_OK |
incl %edi |
movb $'2',%gs:0(%edi) |
incl %edi |
movb $6,%gs:0(%edi) |
movl %gs:64(%ebx), %ebp /* Name Address... */ |
cmpb $'X', %gs:0(%ebp) |
je GDT_is_OK |
GDT_is_not_OK: |
/* |
* Fix the X_RM_BACK_GATE with the address of halt() |
*/ |
/* Now I test if the check mechanism is OK... */ |
movl $SYMBOL_NAME(halt),%eax |
movw %ax,%gs:rmBckGateFix1 |
shrl $16,%eax |
movw %ax,%gs:rmBckGateFix2 |
/* Load GDT, using the predefined assignment! */ |
lgdt GDT_descr |
movl $0xB8000,%edi |
addl $146,%edi |
movb $'0',%gs:0(%edi) |
incl %edi |
movb $6,%gs:0(%edi) |
GDT_is_OK: movw $(X_FLATDATA_SEL),%ax |
movw %ax,%ds |
movw %ax,%es |
movw %ax,%ss |
movw %ax,%fs |
movw %ax,%gs |
movl $tos,%esp |
movl $base,SYMBOL_NAME(_stkbase) |
movl $tos,SYMBOL_NAME(_stktop) |
/* Store the MULTIBOOT informations */ |
movl %eax,SYMBOL_NAME(mb_signature) |
movl %ebx,SYMBOL_NAME(mbi) |
/* Store the X passed GDT address! |
* If GDT is not available is a dummy instruction! |
*/ |
sgdt GDT_descr |
/* Now probably is the case to load CS... */ |
ljmp $X_FLATCODE_SEL, $load_cs |
load_cs: |
/* Load IDT */ |
lidt IDT_descr |
cld |
call SYMBOL_NAME(_startup) |
/* Well I hope when I reach this |
The X_RM_BACK_GATE has been setup correctly |
even if the kernel has not been loaded through X! |
*/ |
.byte 0x0EA /* Direct gate jmp */ |
.long 0 |
.word X_RM_BACK_GATE |
/* Simple function to terminate PM application */ |
/* void __exit(int code) */ |
SYMBOL_NAME_LABEL(__exit) |
pushl %ebp |
movl %esp,%ebp |
movl 8(%ebp),%eax |
.byte 0x0ea /* Direct gate jmp */ |
.long 0 |
.word X_RM_BACK_GATE |
/shark/trunk/arch/x86/intevt.c |
---|
0,0 → 1,118 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Interrupt Events */ |
#include <arch/i386/stdlib.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/error.h> |
#include <ll/i386/hw-arch.h> |
#include <ll/i386/pit.h> |
#include <ll/i386/pic.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/ll-instr.h> |
#include <ll/sys/ll/time.h> |
#include <ll/sys/ll/event.h> |
FILE(IntEvent); |
extern int activeInt; |
void (*evt_prol) (void) = NULL; |
void (*evt_epil) (void) = NULL; |
struct intentry irqs[16]; |
void irq_init(void) |
{ |
int i; |
/* Initialize the interrupt handlers list!!! */ |
for (i = 0; i < 16; i++) { |
irqs[i].status = INTSTAT_FREE; |
irqs[i].index = i; |
irqs[i].handler = NULL; /* Paranoia */ |
irqs[i].par = NULL; /* Paranoia */ |
} |
activeInt = 0; |
} |
int ll_ActiveInt(void) |
{ |
return activeInt; |
} |
int irq_bind(int irq, void (*handler) (void *p), DWORD flags) |
{ |
if ((irqs[irq].status != INTSTAT_FREE) && |
((flags & INT_FORCE) != INT_FORCE)) { |
return -1; |
} |
irqs[irq].status = INTSTAT_ASSIGNED; |
if (handler != NULL) { |
irqs[irq].handler = handler; |
irqs[irq].par = &(irqs[irq].index); |
irqs[irq].flags = flags; |
} else { |
irqs[irq].status = INTSTAT_FREE; |
} |
return 1; |
} |
void act_int(BYTE n) |
{ |
static int ai_called = 0; |
if ((n >= PIC1_BASE) && (n < PIC1_BASE + 8)) { |
n = n - PIC1_BASE; |
} else if ((n >= PIC2_BASE) && (n < PIC2_BASE + 8)) { |
n = n - PIC2_BASE + 8; |
} else { |
/* Wow... Here, we are in error... Return? */ |
return; |
} |
activeInt++; |
if (activeInt == 1 && evt_prol != NULL) { |
evt_prol(); |
} |
if (irqs[n].status == INTSTAT_ASSIGNED) { |
irqs[n].status = INTSTAT_BUSY; |
if (irqs[n].flags & INT_PREEMPTABLE) { |
sti(); |
} |
irqs[n].handler(irqs[n].par); |
if (irqs[n].flags & INT_PREEMPTABLE) { |
cli(); |
} |
irqs[n].status = INTSTAT_ASSIGNED; |
} |
ai_called++; |
if (activeInt == 1 && evt_epil != NULL) { |
evt_epil(); |
} |
activeInt--; |
} |
/shark/trunk/arch/x86/advtimer.c |
---|
0,0 → 1,513 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Advanced Timer Managment |
* Author: Giacomo Guidi <giacomo@gandalf.sssup.it> |
*/ |
#include <arch/i386/stdlib.h> |
#include <ll/i386/error.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/ll-func.h> |
#include <ll/i386/pic.h> |
#include <ll/i386/apic.h> |
#include <ll/i386/64bit.h> |
#include <ll/sys/ll/event.h> |
#include <ll/sys/ll/time.h> |
#include <ll/i386/advtimer.h> |
#define CALIBRATE_USING_CMOS |
unsigned long long init_tsc; |
unsigned long long * ptr_init_tsc = &init_tsc; |
struct timespec init_time; |
struct timespec * ptr_init_time = &init_time; |
unsigned int clk_per_msec = 0; |
unsigned int apic_clk_per_msec = 0; |
unsigned int apic_set_limit = 0; |
/* Precalcolated const |
used in ll_read_timer */ |
unsigned int clk_opt_0 = 0; |
unsigned int clk_opt_1 = 0; |
unsigned int clk_opt_2 = 0; |
unsigned int clk_opt_3 = 0; |
unsigned int clk_opt_4 = 0; |
unsigned int clk_opt_5 = 0; |
unsigned char save_CMOS_regA; |
unsigned char save_CMOS_regB; |
unsigned long msr_original_low, msr_original_high; |
unsigned char X86_tsc = 0; |
unsigned char X86_apic = 0; |
unsigned char use_tsc = 0; |
unsigned char use_apic = 0; |
#ifdef CONFIG_MELAN |
# define CLOCK_TICK_RATE 1189200 /* AMD Elan has different frequency! */ |
#else |
# define CLOCK_TICK_RATE 1193182 /* Underlying HZ */ |
#endif |
#define COUNTER_END 100 |
#define barrier() __asm__ __volatile__("" ::: "memory"); |
//TSC Calibration (idea from the linux kernel code) |
void ll_calibrate_tsc(void) |
{ |
unsigned long long start; |
unsigned long long end; |
unsigned long long dtsc; |
unsigned int start_8253, end_8253, delta_8253; |
outp(0x61, (inp(0x61) & ~0x02) | 0x01); |
outp(0x43,0xB0); /* binary, mode 0, LSB/MSB, Ch 2 */ |
outp(0x42,0xFF); /* LSB of count */ |
outp(0x42,0xFF); /* MSB of count */ |
barrier(); |
rdtscll(start); |
barrier(); |
outp(0x43,0x00); |
start_8253 = inp(0x42); |
start_8253 |= inp(0x42) << 8; |
barrier(); |
rdtscll(start); |
barrier(); |
do { |
outp(0x43,0x00); |
end_8253 = inp(0x42); |
end_8253 |= inp(0x42) << 8; |
} while (end_8253 > COUNTER_END); |
barrier(); |
rdtscll(end); |
barrier(); |
outp(0x43,0x00); |
end_8253 = inp(0x42); |
end_8253 |= inp(0x42) << 8; |
barrier(); |
rdtscll(end); |
barrier(); |
//Delta TSC |
dtsc = end - start; |
//Delta PIT |
delta_8253 = start_8253 - end_8253; |
if (delta_8253 > 0x20000) { |
message("Error calculating Delta PIT\n"); |
ll_abort(10); |
} |
message("Delta TSC = %10d\n",(int)dtsc); |
message("Delta PIT = %10d\n",delta_8253); |
clk_per_msec = dtsc * CLOCK_TICK_RATE / delta_8253 / 1000; |
message("Calibrated Clk_per_msec = %10d\n",clk_per_msec); |
} |
#define CMOS_INIT 0 |
#define CMOS_BEGIN 1 |
#define CMOS_START 2 |
#define CMOS_END 3 |
int cmos_calibrate_status = CMOS_INIT; |
unsigned long long irq8_start; |
unsigned long long irq8_end; |
void calibrate_tsc_IRQ8(void *p) |
{ |
unsigned char set; |
CMOS_READ(0x0C,set); |
barrier(); |
rdtscll(irq8_end); |
barrier(); |
if (cmos_calibrate_status == CMOS_START) { |
cmos_calibrate_status = CMOS_END; |
} |
if (cmos_calibrate_status == CMOS_BEGIN) { |
irq8_start = irq8_end; |
cmos_calibrate_status = CMOS_START; |
} |
if (cmos_calibrate_status == CMOS_INIT) { |
cmos_calibrate_status = CMOS_BEGIN; |
} |
} |
//TSC Calibration using RTC |
void ll_calibrate_tsc_cmos(void) |
{ |
unsigned long long dtsc; |
irq_bind(8, calibrate_tsc_IRQ8, INT_FORCE); |
CMOS_READ(0x0A,save_CMOS_regA); |
CMOS_READ(0x0B,save_CMOS_regB); |
CMOS_WRITE(0x0A,0x2F); // Set 2 Hz Periodic Interrupt |
CMOS_WRITE(0x0B,0x42); // Enable Interrupt |
irq_unmask(8); |
sti(); |
while (cmos_calibrate_status != CMOS_END) { |
barrier(); |
} |
cli(); |
dtsc = irq8_end - irq8_start; |
clk_per_msec = dtsc / 500; |
clk_opt_0 = (unsigned int)(dtsc); |
clk_opt_1 = (unsigned int)((unsigned long long)(dtsc << 1)); |
clk_opt_2 = (unsigned int)((unsigned long long)(dtsc << 33) / 1000000000L); |
clk_opt_3 = (unsigned int)((unsigned long long)(dtsc << 32) / 1000000000L); |
clk_opt_4 = (unsigned int)((unsigned long long)(dtsc << 31) / 1000000000L); |
clk_opt_5 = (unsigned int)((unsigned long long)(dtsc << 30) / 1000000000L); |
message("Calibrated CPU Clk/msec = %10u\n",clk_per_msec); |
#ifdef __O1000__ |
if (clk_per_msec < 1000000) { |
message("Timer Optimization CPU < 1 GHz\n"); |
} else { |
message("Bad Timer Optimization\n"); |
ll_abort(66); |
} |
#endif |
#ifdef __O2000__ |
if (clk_per_msec < 2000000 && clk_per_msec >= 1000000) { |
message("Timer Optimization 1 GHz < CPU < 2 GHz\n"); |
} else { |
message("Bad Timer Optimization\n"); |
ll_abort(66); |
} |
#endif |
#ifdef __O4000__ |
if (clk_per_msec < 4000000 && clk_per_msec >= 2000000) { |
message("Timer Optimization 2 GHz < CPU < 4 GHz\n"); |
} else { |
message("Bad Timer Optimization\n"); |
ll_abort(66); |
} |
#endif |
irq_mask(8); |
CMOS_WRITE(0x0A,save_CMOS_regA); |
CMOS_WRITE(0x0B,save_CMOS_regB); |
} |
int apic_get_maxlvt(void) |
{ |
unsigned int v, ver, maxlvt; |
v = apic_read(APIC_LVR); |
ver = GET_APIC_VERSION(v); |
/* 82489DXs do not report # of LVT entries. */ |
maxlvt = APIC_INTEGRATED(ver) ? GET_APIC_MAXLVT(v) : 2; |
return maxlvt; |
} |
/* Clear local APIC, from Linux kernel */ |
void clear_local_APIC(void) |
{ |
int maxlvt; |
unsigned long v; |
maxlvt = apic_get_maxlvt(); |
/* |
* Masking an LVT entry on a P6 can trigger a local APIC error |
* if the vector is zero. Mask LVTERR first to prevent this. |
*/ |
if (maxlvt >= 3) { |
v = 0xFF; /* any non-zero vector will do */ |
apic_write_around(APIC_LVTERR, v | APIC_LVT_MASKED); |
} |
/* |
* Careful: we have to set masks only first to deassert |
* any level-triggered sources. |
*/ |
v = apic_read(APIC_LVTT); |
apic_write_around(APIC_LVTT, v | APIC_LVT_MASKED); |
v = apic_read(APIC_LVT0); |
apic_write_around(APIC_LVT0, v | APIC_LVT_MASKED); |
v = apic_read(APIC_LVT1); |
apic_write_around(APIC_LVT1, v | APIC_LVT_MASKED); |
if (maxlvt >= 4) { |
v = apic_read(APIC_LVTPC); |
apic_write_around(APIC_LVTPC, v | APIC_LVT_MASKED); |
} |
/* |
* Clean APIC state for other OSs: |
*/ |
apic_write_around(APIC_LVTT, APIC_LVT_MASKED); |
apic_write_around(APIC_LVT0, APIC_LVT_MASKED); |
apic_write_around(APIC_LVT1, APIC_LVT_MASKED); |
if (maxlvt >= 3) |
apic_write_around(APIC_LVTERR, APIC_LVT_MASKED); |
if (maxlvt >= 4) |
apic_write_around(APIC_LVTPC, APIC_LVT_MASKED); |
v = GET_APIC_VERSION(apic_read(APIC_LVR)); |
if (APIC_INTEGRATED(v)) { /* !82489DX */ |
if (maxlvt > 3) |
apic_write(APIC_ESR, 0); |
apic_read(APIC_ESR); |
} |
} |
void disable_local_APIC(void) |
{ |
unsigned long value; |
clear_local_APIC(); |
/* |
* Disable APIC (implies clearing of registers |
* for 82489DX!). |
*/ |
value = apic_read(APIC_SPIV); |
value &= ~APIC_SPIV_APIC_ENABLED; |
apic_write_around(APIC_SPIV, value); |
} |
#define SPURIOUS_APIC_VECTOR 0xFF |
/* |
* Setup the local APIC, minimal code to run P6 APIC |
*/ |
void setup_local_APIC (void) |
{ |
unsigned long value; |
/* Pound the ESR really hard over the head with a big hammer - mbligh */ |
apic_write(APIC_ESR, 0); |
apic_write(APIC_ESR, 0); |
apic_write(APIC_ESR, 0); |
apic_write(APIC_ESR, 0); |
value = APIC_SPIV_FOCUS_DISABLED | APIC_SPIV_APIC_ENABLED | SPURIOUS_APIC_VECTOR; |
apic_write_around(APIC_SPIV, value); |
value = APIC_DM_EXTINT | APIC_LVT_LEVEL_TRIGGER; |
apic_write_around(APIC_LVT0, value); |
value = APIC_DM_NMI; |
apic_write_around(APIC_LVT1, value); |
apic_write(APIC_ESR, 0); |
} |
void disable_APIC_timer(void) |
{ |
unsigned long v; |
v = apic_read(APIC_LVTT); |
apic_write_around(APIC_LVTT, v | APIC_LVT_MASKED); |
} |
void enable_APIC_timer(void) |
{ |
unsigned long v; |
v = apic_read(APIC_LVTT); |
apic_write_around(APIC_LVTT, v & ~APIC_LVT_MASKED); |
} |
#define LOCAL_TIMER_VECTOR 0x39 |
/* Set APIC Timer... from Linux kernel */ |
void setup_APIC_timer() |
{ |
unsigned int lvtt1_value; |
lvtt1_value = SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV) | |
APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR; |
apic_write_around(APIC_LVTT, lvtt1_value); |
/* |
* Divide PICLK by 1 |
*/ |
apic_write_around(APIC_TDCR, APIC_TDR_DIV_1); |
apic_write_around(APIC_TMICT, MAX_DWORD); |
disable_APIC_timer(); |
} |
#define APIC_LIMIT 0xFF000000 |
#define APIC_SET_LIMIT 10 |
void ll_calibrate_apic(void) |
{ |
unsigned int apic_start = 0, apic_end = 0, dapic; |
unsigned long long tsc_start = 0, tsc_end = 0, dtsc; |
unsigned int tmp_value; |
tmp_value = SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV) | LOCAL_TIMER_VECTOR; |
apic_write_around(APIC_LVTT, tmp_value); |
apic_write_around(APIC_TDCR, APIC_TDR_DIV_1); |
apic_write(APIC_TMICT, MAX_DWORD); |
enable_APIC_timer(); |
barrier(); |
rdtscll(tsc_start); |
barrier(); |
apic_start = apic_read(APIC_TMCCT); |
barrier(); |
while (apic_read(APIC_TMCCT) > APIC_LIMIT) { |
barrier(); |
rdtscll(tsc_end); |
} |
barrier(); |
rdtscll(tsc_end); |
barrier(); |
apic_end = apic_read(APIC_TMCCT); |
barrier(); |
disable_APIC_timer(); |
dtsc = tsc_end - tsc_start; |
dapic = apic_start - apic_end; |
apic_clk_per_msec = (unsigned long long)(clk_per_msec) * (unsigned long long)(dapic) / dtsc; |
apic_set_limit = ((apic_clk_per_msec / 100) != 0) ? (apic_clk_per_msec/100) : APIC_SET_LIMIT; |
message("Calibrated APIC Clk/msec = %10d\n",apic_clk_per_msec); |
} |
void ll_init_advtimer() |
{ |
#ifdef __TSC__ |
use_tsc = X86_tsc; |
#ifdef __APIC__ |
use_apic = X86_apic; |
#endif |
#endif |
if (use_tsc == 0) use_apic = 0; |
if (use_tsc) { |
#ifdef CALIBRATE_USING_CMOS |
ll_calibrate_tsc_cmos(); |
#else |
ll_calibrate_tsc(); |
#endif |
rdtscll(init_tsc); // Read start TSC |
init_time.tv_sec = 0; |
init_time.tv_nsec = 0; |
if (use_apic) { |
rdmsr(APIC_BASE_MSR, msr_original_low, msr_original_high); |
wrmsr(APIC_BASE_MSR, msr_original_low|(1<<11), 0); |
clear_local_APIC(); |
ll_calibrate_apic(); |
setup_local_APIC(); |
setup_APIC_timer(); |
} |
} |
} |
void ll_restore_adv() |
{ |
SYS_FLAGS f; |
/* Disable APIC */ |
if (use_apic) { |
f = ll_fsave(); |
disable_APIC_timer(); |
wrmsr(APIC_BASE_MSR, msr_original_low, msr_original_high); |
ll_frestore(f); |
} |
} |
void ll_scale_advtimer(unsigned int old_f, unsigned int new_f) |
{ |
unsigned long long dtsc; |
unsigned long temp; |
struct timespec temp_time; |
SYS_FLAGS f; |
if (use_tsc) { |
f = ll_fsave(); |
__asm__("cpuid"::"a" (0), "b" (0), "c" (0), "d" (0)); |
ll_read_timespec(&temp_time); // Set new start TimeSpec |
TIMESPEC_ASSIGN(&init_time,&temp_time); |
rdtscll(init_tsc); // Set new start TSC |
__asm__("cpuid"::"a" (0), "b" (0), "c" (0), "d" (0)); |
mul32div32to32(clk_per_msec,new_f,old_f,temp); |
clk_per_msec = temp; |
dtsc = (unsigned long long)(clk_per_msec) * 500; |
clk_opt_0 = (unsigned int)(dtsc); |
clk_opt_1 = (unsigned int)((unsigned long long)(dtsc << 1)); |
clk_opt_2 = (unsigned int)((unsigned long long)(dtsc << 33) / 1000000000L); |
clk_opt_3 = (unsigned int)((unsigned long long)(dtsc << 32) / 1000000000L); |
clk_opt_4 = (unsigned int)((unsigned long long)(dtsc << 31) / 1000000000L); |
clk_opt_5 = (unsigned int)((unsigned long long)(dtsc << 30) / 1000000000L); |
ll_frestore(f); |
} |
} |
/shark/trunk/arch/x86/xinfo.c |
---|
0,0 → 1,102 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Access the info stucture */ |
#include <arch/i386/stdlib.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/mb-info.h> |
#include <ll/i386/x-bios.h> |
FILE(X-Info); |
/* |
The x_bios is stored in the low memory area and contains all the |
stuff necessary to perform a BIOS call from PM; it can be accessed |
using a linear pointer, which is returned by the following call! |
*/ |
X_CALLBIOS * x_bios_address(void) |
{ |
X_CALLBIOS *a = (X_CALLBIOS *)GDT_read(X_CALLBIOS_SEL,NULL,NULL,NULL); |
return (a); |
} |
/* Stuff information retrieving function */ |
WORD X_version(void) |
{ |
X_CALLBIOS *x_bios = x_bios_address(); |
return(x_bios->_ver); |
} |
void X_meminfo(LIN_ADDR *b1,DWORD *s1,LIN_ADDR *b2,DWORD *s2) |
{ |
struct multiboot_info *mbi = mbi_address(); |
int x = 0; |
if (mbi->flags & MB_INFO_BOOT_LOADER_NAME) { |
char *name; |
name = (char *) mbi->boot_loader_name; |
if (*name == 'X') { |
x = 1; |
} |
} |
if (x) { |
if (b1 != NULL) *b1 = (LIN_ADDR)mbi->mem_upbase; |
if (s1 != NULL) *s1 = mbi->mem_upper * 1024; |
if (b2 != NULL) *b2 = (LIN_ADDR)mbi->mem_lowbase; |
if (s2 != NULL) *s2 = mbi->mem_lower * 1024; |
} else { |
if (b1 != NULL) *b1 = (LIN_ADDR)0x100000; |
if (s1 != NULL) *s1 = mbi->mem_upper * 1024; |
if (b2 != NULL) *b2 = (LIN_ADDR)0x4000; |
if (s2 != NULL) *s2 = mbi->mem_lower * 1024; |
} |
/* |
#ifdef __OLD_MB__ |
if (b1 != NULL) *b1 = 0x100000; |
if (s1 != NULL) *s1 = mbi->mem_upper; |
if (b2 != NULL) *b2 = 0x4000; |
if (s2 != NULL) *s2 = mbi->mem_lower; |
#else |
if (b1 != NULL) *b1 = mbi->mem_upbase; |
if (s1 != NULL) *s1 = mbi->mem_upper; |
if (b2 != NULL) *b2 = mbi->mem_lowbase; |
if (s2 != NULL) *s2 = mbi->mem_lower; |
#endif |
*/ |
} |
#ifdef CHECK |
#include <cons.h> |
/* Alert if a wrong addressing is intercepted */ |
/* Used only for debug purposes */ |
void check_addr(void *addr,char *caller) |
{ |
extern DWORD _stktop; |
if ((DWORD)(addr) < _stktop) { |
cprintf("CRISIS! Addr : %lx(%lx) Caller was %s\n",(DWORD)(addr),_stktop,caller); |
} |
} |
#endif |
/shark/trunk/arch/x86/xdosf.c |
---|
0,0 → 1,234 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* DOS Interface toward disk */ |
#include <arch/string.h> |
#include <ll/i386/error.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/x-dos.h> |
#include <ll/i386/x-dosmem.h> |
FILE(X-Dos-File); |
/* Basic DOS I/O Flag */ |
/*#define __DEBUG__*/ |
#define DOS_READ 0 |
#define DOS_WRITE 1 |
#define DOS_RW 2 |
#define DOS_BUFSIZE 1024 /* I/O auxiliary buffer */ |
#define DOS_MAXDESCR 16 /* Maximum number of DOS file */ |
static DOS_FILE DOS_descr[DOS_MAXDESCR]; |
/* I Hope this array is initialized with 0... */ |
static BYTE busy[DOS_MAXDESCR]; |
/* The Last DOS Error occurred! */ |
static unsigned _DOS_error = 0; |
int DOS_init(void) |
{ |
/* Init the DOS memory allocator */ |
DOS_mem_init(); |
/* TODO: Add a check if we are run through X */ |
return 1; |
} |
unsigned DOS_error(void) |
{ |
unsigned v = _DOS_error; |
_DOS_error = 0; |
return(v); |
} |
DOS_FILE *DOS_fopen(char *name,char *mode) |
{ |
X_REGS16 ir,or; |
X_SREGS16 sr; |
DOS_FILE *f; |
register int i; |
#ifdef __DEBUG__ |
char xname[80]; |
#endif |
for (i = 0; busy[i] && i < DOS_MAXDESCR; i++); |
/* Return NULL if no descriptor is available... */ |
if (i == DOS_MAXDESCR) return(NULL); |
/* Otherwise, lock the descriptor & remember the index */ |
f = &DOS_descr[i]; busy[i] = 1; f->index = i; |
/* Allocate a DOS buffer for the file name */ |
f->n1 = DOS_alloc(80); |
strcpy(f->n2,name); |
if (mode[0] == 'r') { |
/* DOS Call: Intr 0x21 |
AH = 0x3D - Open existing file |
AL = 0,1,2 - Read,Write, R/W |
*/ |
f->mode = DOS_READ; |
ir.h.ah = 0x3D; |
ir.h.al = f->mode; |
} |
else if (mode[0] == 'w') { |
/* DOS Call: Intr 0x21 |
AH = 0x3C - Create a file |
AL = File attribute [0x20 = Standard,r/w,archive] |
*/ |
f->mode = DOS_WRITE; |
ir.h.ah = 0x3C; |
ir.x.cx = 0x20; |
} |
f->offset = 0; |
/* Copy th \0 also! */ |
memcpy(f->n1, name, strlen(name) + 1); |
#ifdef __DEBUG__ |
memcpy(xname, f->n1, strlen(name) + 1); |
message("Name is : %s -- Mode : %d\n",xname,f->mode); |
#endif |
/* Ask DOS to open File */ |
ir.x.dx = DOS_OFF(f->n1); |
sr.ds = DOS_SEG(f->n1); |
X_callBIOS(0x21,&ir,&or,&sr); |
f->handle = (!(or.x.cflag) ? or.x.ax : -1); |
if (f->handle == -1) { |
/* DOS request failed! Release the used resources */ |
DOS_free(f->n1,80); |
busy[i] = 0; |
_DOS_error = or.x.ax; |
return(NULL); |
} |
/* Allocate the DOS buffer for temporary I/O */ |
f->buf = DOS_alloc(DOS_BUFSIZE); |
return(f); |
} |
void DOS_fclose(DOS_FILE *f) |
{ |
X_REGS16 ir,or; |
X_SREGS16 sr; |
if (f == NULL || busy[f->index] == 0) return; |
/* DOS Call: Intr 0x21 |
AH = 0x3E - Close a file |
BX = File handle |
*/ |
ir.h.ah = 0x3E; |
ir.x.bx = f->handle; |
X_callBIOS(0x21,&ir,&or,&sr); |
DOS_free(f->buf,DOS_BUFSIZE); |
DOS_free(f->n1,80); |
busy[f->index] = 0; |
} |
DWORD DOS_fread(void *abuf,DWORD size,DWORD num,DOS_FILE *f) |
{ |
X_REGS16 ir,or; |
X_SREGS16 sr; |
DWORD count = size*num,now = 0,chunk; |
BYTE done = 0; |
BYTE *buf = (BYTE *)(abuf); |
while (done == 0) { |
/* Fragment the read operation ... */ |
if (count > DOS_BUFSIZE) chunk = DOS_BUFSIZE; |
else chunk = count; |
/* DOS Call: Intr 0x21 |
AH = 0x3F - Read data using a file handle |
BX = File handle |
CX = Buffer size |
DS:DX = Segment:Offset of the Buffer |
*/ |
ir.h.ah = 0x3F; |
ir.x.bx = f->handle; |
ir.x.cx = chunk; |
ir.x.dx = DOS_OFF(f->buf); |
sr.ds = DOS_SEG(f->buf); |
X_callBIOS(0x21,&ir,&or,&sr); |
/* If it was OK ... */ |
if (!(or.x.cflag)) { |
/* Copy data into application buffer */ |
memcpy(buf, f->buf, or.x.ax); |
buf += or.x.ax; |
now += or.x.ax; |
f->offset += or.x.ax; |
count -= or.x.ax; |
/* |
Finish if we have read all the data or |
if we have read less data than how expected |
*/ |
if (now == size*num || or.x.ax != chunk) done = 1; |
} else { |
done = -1; |
_DOS_error = or.x.ax; |
} |
} |
return(now); |
} |
DWORD DOS_fwrite(void *abuf,DWORD size,DWORD num,DOS_FILE *f) |
{ |
X_REGS16 ir,or; |
X_SREGS16 sr; |
DWORD count = size*num,now = 0,chunk; |
BYTE done = 0; |
BYTE *buf = (BYTE *)(abuf); |
while (done == 0) { |
/* Fragment the write operation ... */ |
if (count > DOS_BUFSIZE) chunk = DOS_BUFSIZE; |
else chunk = count; |
/* Copy data from application buffer */ |
memcpy(f->buf, buf, chunk); |
/* DOS Call: Intr 0x21 |
AH = 0x40 - Write data using a file handle |
BX = File handle |
CX = Buffer size |
DS:DX = Segment:Offset of the Buffer |
*/ |
ir.h.ah = 0x40; |
ir.x.bx = f->handle; |
ir.x.cx = chunk; |
ir.x.dx = DOS_OFF(f->buf); |
sr.ds = DOS_SEG(f->buf); |
X_callBIOS(0x21,&ir,&or,&sr); |
/* If it was OK ... */ |
if (!(or.x.cflag)) { |
f->offset += or.x.ax; |
count -= or.x.ax; |
buf += or.x.ax; |
now += or.x.ax; |
if (now == size*num || or.x.ax != chunk) done = 1; |
} else { |
done = -1; |
_DOS_error = or.x.ax; |
} |
} |
return(now); |
} |
/shark/trunk/arch/x86/cxsw-2.c |
---|
0,0 → 1,169 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Routines that implements threads (creation, end, dump, and AS |
assignment */ |
#include <arch/i386/stdio.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/error.h> |
#include <ll/i386/tss-ctx.h> |
#include <ll/sys/ll/ll-instr.h> /* Only for HW instr... */ |
#include <ll/sys/ll/ll-func.h> |
FILE(KL-Context-Switch); |
extern TSS TSS_table[TSSMax]; |
extern WORD TSS_control[TSSMax]; |
extern BYTE ll_FPU_stdctx[FPU_CONTEXT_SIZE]; |
#ifdef __VIRCSW__ |
extern unsigned short int currCtx; |
extern int activeInt; |
#endif |
extern DWORD entrypoint; |
/* Just a debugging function; it dumps the status of the TSS */ |
void dump_TSS(WORD sel) |
{ |
BYTE acc,gran; |
DWORD base,lim; |
message("TR %x\n", sel); |
sel = TSSsel2index(sel); |
message("SS:SP %x:%lx\n", TSS_table[sel].ss, TSS_table[sel].esp); |
message("Stack0 : %x:%lx\n", TSS_table[sel].ss0, TSS_table[sel].esp0); |
message("Stack1 : %x:%lx\n", TSS_table[sel].ss1, TSS_table[sel].esp1); |
message("Stack2 : %x:%lx\n", TSS_table[sel].ss2, TSS_table[sel].esp2); |
message("CS : %x DS : %x\n", TSS_table[sel].cs, TSS_table[sel].ds); |
sel = TSSindex2sel(sel); |
message("Descriptor [%x] Info",sel); |
base = GDT_read(sel,&lim,&acc,&gran); |
message("Base : %lx Lim : %lx Acc : %x Gran %x\n", base, lim, (unsigned)(acc),(unsigned)(gran)); |
} |
void ll_context_setspace(CONTEXT c, WORD as) |
{ |
int index = TSSsel2index(c); |
TSS_table[index].ss0 = as; |
TSS_table[index].cs = as + 8; |
TSS_table[index].es = as; |
TSS_table[index].ds = as; |
TSS_table[index].ss = as; |
} |
/* Initialize context -> TSS in 32 bit */ |
CONTEXT ll_context_create(void (*task)(void *p),BYTE *stack, |
void *parm,void (*killer)(void),WORD control) |
{ |
CONTEXT index = 0; |
DWORD *stack_ptr = (DWORD *)stack; |
/* Push onto stack the input parameter */ |
/* And the entry point to the task killer procedure */ |
stack_ptr--; |
*stack_ptr = (DWORD)(parm); |
stack_ptr--; |
*stack_ptr = (DWORD)(killer); |
/* Find a free TSS */ |
while ((TSS_control[index] & TSS_USED) && (index < TSSMain)) index++; |
/* This exception would signal an error */ |
if (index >= TSSMain) { |
message("No more Descriptors...\n"); |
return 0; |
} |
TSS_control[index] |= (TSS_USED | control); |
/* Fill the TSS structure */ |
/* No explicit protection; use only one stack */ |
TSS_table[index].esp0 = (DWORD)(stack_ptr); |
TSS_table[index].esp1 = 0; |
TSS_table[index].esp2 = 0; |
TSS_table[index].ss0 = get_DS(); |
TSS_table[index].ss1 = 0; |
TSS_table[index].ss2 = 0; |
/* No paging activated */ |
TSS_table[index].cr3 = 0; |
/* Task entry point */ |
TSS_table[index].eip = (DWORD)(task); |
/* Need only to unmask interrupts */ |
TSS_table[index].eflags = 0x00000200; |
TSS_table[index].eax = 0; |
TSS_table[index].ebx = 0; |
TSS_table[index].ecx = 0; |
TSS_table[index].edx = 0; |
TSS_table[index].esi = 0; |
TSS_table[index].edi = 0; |
TSS_table[index].esp = (DWORD)(stack_ptr); |
TSS_table[index].ebp = (DWORD)(stack_ptr); |
TSS_table[index].cs = get_CS(); |
TSS_table[index].es = get_DS(); |
TSS_table[index].ds = get_DS(); |
TSS_table[index].ss = get_DS(); |
TSS_table[index].gs = X_FLATDATA_SEL; |
TSS_table[index].fs = X_FLATDATA_SEL; |
/* Use only the GDT */ |
TSS_table[index].ldt = 0; |
TSS_table[index].trap = 0; |
TSS_table[index].io_base = 0; |
/* Fill in the coprocessor status */ |
memcpy(TSS_table[index].ctx_FPU,ll_FPU_stdctx,FPU_CONTEXT_SIZE); |
/* Convert the index into a valid selector */ |
/* Which really represent CONTEXT */ |
return(TSSindex2sel(index)); |
} |
/* Release the used TSS */ |
void ll_context_delete(CONTEXT c) |
{ |
int index = TSSsel2index(c); |
TSS_control[index] = 0; |
} |
#if 0 /* It does not work... Fix it!!! */ |
DWORD ll_push_func(void (*func)(void)) |
{ |
DWORD *p; |
DWORD old; |
p = (DWORD *)entrypoint; |
old = *p; |
*p = (DWORD)func; |
return old; |
} |
#endif |
/* Well this is used for debug purposes mainly; as the context is an */ |
/* abstract type, we must provide some function to convert in into a */ |
/* printable form; anyway this depend from the architecture as the context */ |
char *ll_context_sprintf(char *str, CONTEXT c) |
{ |
ksprintf(str, "%x (Hex)", c); |
return(str); |
} |
/shark/trunk/arch/x86/xbios.c |
---|
0,0 → 1,63 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* System calls for X extender */ |
/* BIOS Call from X (Basic Reflection Service) */ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/x-bios.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/advtimer.h> |
#include <ll/i386/apic.h> |
FILE(X-BIOS); |
/* The interface between X (and 32 bit PM) and BIOS (which runs at 16 bits */ |
/* It works as int86() standard library call */ |
void X_callBIOS(int service,X_REGS16 *in,X_REGS16 *out,X_SREGS16 *s) |
{ |
/* Assembler gate JMP instruction */ |
extern unsigned char use_apic; |
extern void _x_callBIOS(void); |
X_CALLBIOS *xbc = x_bios_address(); |
DWORD msr1 = 0,msr2 = 0; |
/* Send interrupt request & register through the X_Info structure */ |
xbc->_irqno = service; |
memcpy(&(xbc->_ir),in,sizeof(X_REGS16)); |
memcpy(&(xbc->_sr),s,sizeof(X_SREGS16)); |
if (use_apic) { |
rdmsr(APIC_BASE_MSR,msr1,msr2); |
disable_APIC_timer(); |
} |
/* Back to RM to execute the BIOS routine */ |
_x_callBIOS(); |
/* Get the return register values */ |
if (use_apic) { |
wrmsr(APIC_BASE_MSR,msr1,msr2); |
enable_APIC_timer(); |
} |
memcpy(out,&(xbc->_or),sizeof(X_REGS16)); |
memcpy(s,&(xbc->_sr),sizeof(X_SREGS16)); |
} |
/shark/trunk/arch/x86/timeint.s |
---|
0,0 → 1,252 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Safe abort routine & timer asm handler */ |
.title "Timer.S" |
#include <ll/i386/sel.h> |
#include <ll/i386/linkage.h> |
#include <ll/i386/defs.h> |
#include <ll/sys/ll/exc.h> |
.data |
ASMFILE(TimerHandler) |
.extern JmpSel |
.extern JmpZone |
.globl SYMBOL_NAME(ll_clock) |
.globl SYMBOL_NAME(last_handler) |
/* Used as JMP entry point to check if a real */ |
/* context switch is necessary */ |
SYMBOL_NAME_LABEL(ll_clock) .int 0 |
SYMBOL_NAME_LABEL(last_handler) .long 0 |
.extern SYMBOL_NAME(periodic_wake_up) |
.extern SYMBOL_NAME(oneshot_wake_up) |
.text |
.globl SYMBOL_NAME(ll_apic_timer) |
/* APIC ll_timer */ |
SYMBOL_NAME_LABEL(ll_apic_timer) |
pushal |
pushw %ds |
pushw %es |
pushw %fs |
pushw %gs |
/* Send ACK to APIC */ |
movl $0xFEE000B0,%ebx |
movl $0,(%ebx) |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%ds |
movw %ax,%es |
/* Call wake_up(actual_context) */ |
movl SYMBOL_NAME(ll_clock),%eax |
incl %eax |
movl %eax,SYMBOL_NAME(ll_clock) |
/* The following could be optimized a little... */ |
xorl %ebx, %ebx |
movw %ss, %bx |
/* We must switch to a ``safe stack'' */ |
/* |
* OK, this is the idea: in %esp we have the address of the |
* stack pointer in the APPLICATION address space... |
* We assume that address spaces are implemented through segments... |
* What we have to do is to add the segment base to %esp: |
* - Load the GDT base in a register |
* - Add DS * 8 to that value |
* - Read the corresponding GDT entry (the segment descriptor) |
* - Compute the base... |
* It is (*p & 0xFC) | (*(p +1) & 0x0F) << 16) | *(p + 2) |
*/ |
movl SYMBOL_NAME(GDT_base), %edi |
addl %ebx, %edi |
xorl %ebx, %ebx |
movb 7(%edi), %bh |
movb 4(%edi), %bl |
shl $16, %ebx |
movw 2(%edi), %bx |
/* Is it correct? I think so... Test it!!! */ |
addl %ebx, %esp |
/* Save EBX for returning to our stack... */ |
movw %ds, %cx |
movw %ss, %dx |
movw %cx, %ss |
pushl %ebx |
pushl %edx |
cld |
movl SYMBOL_NAME(timermode), %eax |
cmpl $1, %eax |
je apic_oneshot |
call SYMBOL_NAME(periodic_wake_up) |
jmp apic_Timer_OK |
apic_oneshot: call SYMBOL_NAME(oneshot_wake_up) |
apic_Timer_OK: |
/* Restore ESP */ |
popl %edx |
popl %ebx /* We must subtract it from ESP...*/ |
subl %ebx, %esp |
movw %dx, %ss |
#ifdef __VIRCSW__ |
movw SYMBOL_NAME(currCtx), %ax |
cmpw %ax,JmpSel |
je apic_NoPreempt2 |
movw %ax,JmpSel |
ljmp *JmpZone /* DISPATCH! */ |
#endif |
apic_NoPreempt2: |
cmpl $0, SYMBOL_NAME(last_handler) |
je apic_nohandler |
movl SYMBOL_NAME(last_handler), %ebx |
call *%ebx |
apic_nohandler: |
popw %gs |
popw %fs |
popw %es |
popw %ds |
popal |
iret |
.globl SYMBOL_NAME(ll_timer) |
/* This is the timer handler; it reloads for safety the DS register; this */ |
/* prevents from mess when timer interrupts linear access to memory (not in */ |
/* ELF address space); then EOI is sent in order to detect timer overrun */ |
/* The high level kernel procedure wake_up() is called to perform the */ |
/* preeption at higher level (process descriptos); the resulting context */ |
/* if different from the old one is used to trigger the task activation. */ |
SYMBOL_NAME_LABEL(ll_timer) |
pushal |
pushw %ds |
pushw %es |
pushw %fs |
pushw %gs |
/* Send ACK to master PIC */ |
movb $0x20,%al |
movl $0x20,%edx |
outb %al,%dx |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%ds |
movw %ax,%es |
/* Call wake_up(actual_context) */ |
movl SYMBOL_NAME(ll_clock),%eax |
incl %eax |
movl %eax,SYMBOL_NAME(ll_clock) |
/* The following could be optimized a little... */ |
xorl %ebx, %ebx |
movw %ss, %bx |
/* We must switch to a ``safe stack'' */ |
/* |
* OK, this is the idea: in %esp we have the address of the |
* stack pointer in the APPLICATION address space... |
* We assume that address spaces are implemented through segments... |
* What we have to do is to add the segment base to %esp: |
* - Load the GDT base in a register |
* - Add DS * 8 to that value |
* - Read the corresponding GDT entry (the segment descriptor) |
* - Compute the base... |
* It is (*p & 0xFC) | (*(p +1) & 0x0F) << 16) | *(p + 2) |
*/ |
movl SYMBOL_NAME(GDT_base), %edi |
addl %ebx, %edi |
xorl %ebx, %ebx |
movb 7(%edi), %bh |
movb 4(%edi), %bl |
shl $16, %ebx |
movw 2(%edi), %bx |
/* Is it correct? I think so... Test it!!! */ |
addl %ebx, %esp |
/* Save EBX for returning to our stack... */ |
movw %ds, %cx |
movw %ss, %dx |
movw %cx, %ss |
pushl %ebx |
pushl %edx |
cld |
movl SYMBOL_NAME(timermode), %eax |
cmpl $1, %eax |
je oneshot |
call SYMBOL_NAME(periodic_wake_up) |
jmp goon |
oneshot: call SYMBOL_NAME(oneshot_wake_up) |
jmp Timer_OK |
goon: |
/* This is the overrun test */ |
/* Do it after sending EOI to master PIC */ |
movb $0x0A,%al |
movl $0x020,%edx |
outb %al,%dx |
inb %dx,%al |
testb $1,%al |
jz Timer_OK |
movl $(CLOCK_OVERRUN),%eax |
pushl %eax |
call SYMBOL_NAME(ll_abort) |
Timer_OK: |
/* Restore ESP */ |
popl %edx |
popl %ebx /* We must subtract it from ESP...*/ |
subl %ebx, %esp |
movw %dx, %ss |
#ifdef __VIRCSW__ |
movw SYMBOL_NAME(currCtx), %ax |
cmpw %ax,JmpSel |
je NoPreempt2 |
movw %ax,JmpSel |
ljmp *JmpZone /* DISPATCH! */ |
#endif |
NoPreempt2: |
cmpl $0, SYMBOL_NAME(last_handler) |
je nohandler |
movl SYMBOL_NAME(last_handler), %ebx |
call *%ebx |
nohandler: |
popw %gs |
popw %fs |
popw %es |
popw %ds |
popal |
iret |
/shark/trunk/arch/x86/cpu2.s |
---|
0,0 → 1,257 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* CPU detection code */ |
.title "CPU2.S" |
#include <ll/i386/linkage.h> |
#include <ll/i386/defs.h> |
/* |
* The following code has been extracted by Intel AP-485 |
* Application Note: Intel Processor Identification with CPUID instruction |
*/ |
.data |
ASMFILE(CPU2) |
.globl SYMBOL_NAME(X86_fpu) |
SYMBOL_NAME_LABEL(X86_fpu) .byte 0 |
SYMBOL_NAME_LABEL(X86_cpu) .byte 0 |
fpu_status: .word 0 |
/* |
struct CPU { |
DWORD X86_cpu; 0 |
DWORD X86_cpuIdFlag; 4 |
DWORD X86_vendor_1; 8 |
DWORD X86_vendor_2; 12 |
DWORD X86_vendor_3; 16 |
DWORD X86_signature; 20 |
DWORD X86_IntelFeature_1; 24 |
DWORD X86_IntelFeature_2; 28 |
DWORD X86_StandardFeature; 32 |
} |
*/ |
.text |
.globl SYMBOL_NAME(X86_get_CPU) |
.globl SYMBOL_NAME(X86_get_FPU) |
.globl SYMBOL_NAME(X86_is386) |
.globl SYMBOL_NAME(X86_isCyrix) |
.globl SYMBOL_NAME(X86_hasCPUID) |
.globl SYMBOL_NAME(X86_enable_cyrix_cpuid) |
SYMBOL_NAME_LABEL(X86_is386) |
pushfl |
popl %eax |
movl %eax, %ecx |
xorl $0x40000, %eax |
pushl %eax |
popfl |
pushfl |
popl %eax |
cmp %ecx, %eax |
jz is386 |
pushl %ecx |
popfl |
movl $0, %eax |
ret |
is386: |
movl $1, %eax |
ret |
SYMBOL_NAME_LABEL(X86_enable_cyrix_cpuid) |
pushfl |
cli |
/* Get Cyrix reg c3h */ |
movb $0xc3,%al |
outb %al,$0x22 |
inb $0x23,%al |
/* Enable config access */ |
movb %al,%cl |
movb %al,%bl |
andb $0xf,%bl |
orb $0x10,%bl |
/* Set Cyrix reg c3h */ |
movb $0xc3,%al |
outb %al,$0x22 |
movb %bl,%al |
outb %al,$0x23 |
/* Get Cyrix reg e8 */ |
movb $0xe8,%al |
outb %al,$0x22 |
inb $0x23,%al |
/* Set "CPUID" bit */ |
orb $0x80,%al |
movb %al,%bl |
/* Set Cyrix reg e8 */ |
movb $0xe8,%al |
outb %al,$0x22 |
movb %bl,%al |
outb %al,$0x23 |
/* Get Cyrix reg fe */ |
movb $0xfe,%al |
outb %al,$0x22 |
inb $0x23,%al |
/* Is CPU a 6x86(L)? */ |
andb $0xf0,%al |
cmpb $0x30,%al |
jne not6x86 |
/* Get Cyrix reg e9 */ |
movb $0xe9,%al |
outb %al,$0x22 |
inb $0x23,%al |
/* Fix 6x86 SLOP bug */ |
andb $0xfd,%al |
movb %al,%bl |
/* Set Cyrix reg e9 */ |
movb $0xe9,%al |
outb %al,$0x22 |
movb %bl,%al |
outb %al,$0x23 |
not6x86: |
/* Set Cyrix reg c3 */ |
movb $0xc3,%al |
outb %al,$0x22 |
movb %cl,%al |
outb %al,$0x23 |
/* Disable suspended mode */ |
movb $0xc2,%al |
outb %al,$0x22 |
inb $0x23,%al |
andb $0x7F,%al |
movb %al,%bl |
movb $0xc2,%al |
outb %al,$0x22 |
movb %bl,%al |
outb %al,$0x23 |
popfl |
ret |
SYMBOL_NAME_LABEL(X86_hasCPUID) |
pushfl |
popl %eax |
movl %eax, %ecx |
xorl $0x200000, %eax |
pushl %eax |
popfl |
pushfl |
popl %eax |
xorl %ecx, %eax |
je noCPUID |
pushl %ecx /* Restore the old EFLAG value... */ |
popfl |
movl $1, %eax |
ret |
noCPUID: |
movl $0, %eax |
ret |
SYMBOL_NAME_LABEL(X86_isCyrix) |
xorw %ax, %ax |
sahf |
mov $5, %ax |
mov $2, %bx |
divb %bl |
lahf |
cmpb $2, %ah |
jne noCyrix |
movl $1, %eax |
ret |
noCyrix: |
movl $0, %eax |
ret |
SYMBOL_NAME_LABEL(X86_get_FPU) |
/* First of all, set the FPU type to 0... */ |
movb $0, SYMBOL_NAME(X86_fpu) |
fninit |
/* Let's give some time to the FPU... |
* We cannot use WAIT 'cause we don't know if an FPU is present... |
*/ |
movl $2, %ecx |
here: |
loop here |
movw $0x5a5a, fpu_status |
fnstsw fpu_status |
/* Guys, I really don't know when to wai and when not... |
*/ |
movl $2, %ecx |
here1: |
loop here1 |
movw fpu_status, %ax |
cmpb $0, %al |
jne endFPUProc |
chkCW: |
/* OK, if we are here, we have some kind of FPU... */ |
fnstcw fpu_status |
/* Guys, I really don't know when to wai and when not... |
*/ |
movl $2, %ecx |
here2: |
loop here2 |
movw fpu_status, %ax |
andw $0x103f, %ax |
cmpw $0x03F, %ax |
jne endFPUProc |
/* ... Err... I was wrong :(. Here we are sure to have an FPU */ |
movb $1, SYMBOL_NAME(X86_fpu) |
chkInf: |
/* Well... I assume that if we arrive to X86_get_FPU, we are running on a |
* 386+ processor... Hence, the following is a complete nonsense!!! |
* I'm commenting it out, we will see... |
*/ |
#if 0 |
/* Um... If we have a -386, end of the story! */ |
cmpb $3, SYMBOL_NAME(X86_cpu) |
jle endFPUProc |
movb $2, SYMBOL_NAME(X86_fpu) |
fld1 |
fldz |
fdivp |
fld %st |
fchs |
fcompp |
fstsw fpu_status |
wait |
sahf |
jz endFPUProc |
movb $3, SYMBOL_NAME(X86_fpu) |
#else |
movb $3, SYMBOL_NAME(X86_fpu) |
#endif |
endFPUProc: |
ret |
/shark/trunk/arch/x86/xdosm.c |
---|
0,0 → 1,125 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* This file contains the DOS memory allocator */ |
#include <ll/i386/mem.h> |
#include <ll/i386/x-bios.h> |
#include <ll/i386/x-dosmem.h> |
#include <ll/i386/error.h> |
FILE(X-Dos-Memory); |
/* |
We do not use the standard K&R pointer based memory allocator! |
This is because we cannot do pointer tricks easily with the GCC |
which only handles explicitely 32 bit non segmented address space. |
So we cannot use far pointers, and we cannot chain buckets of memory |
which are located in low memory area, beyond the accessibility |
of the ELF address space. |
A static allocation is so preferred; this should not give trouble |
since DOS memory is only used for reflection related purposes |
*/ |
#define MAX_PARTITION 50 /* Max available partition */ |
static struct { |
BYTE used; |
LIN_ADDR addr; |
DWORD size; |
} mem_table[MAX_PARTITION]; |
static int inited = 0; |
void DOS_dump_mem(void) |
{ |
register int i; |
for (i = 0; i < MAX_PARTITION; i++) { |
if (mem_table[i].used) message("(%d) Addr : %p Size : %lu/%lx\n", |
i, mem_table[i].addr, |
mem_table[i].size, mem_table[i].size); |
} |
} |
__attribute__ ((weak)) void DOS_mem_init(void) |
{ |
register int i; |
if (inited == 0) { |
mem_table[0].used = TRUE; |
X_meminfo(NULL,NULL,&(mem_table[0].addr),&(mem_table[0].size)); |
for (i = 1; i < MAX_PARTITION; i++) mem_table[i].used = FALSE; |
} else { |
inited = 1; |
} |
} |
/*__attribute__ ((weak)) LIN_ADDR DOS_alloc(DWORD s) |
{ |
LIN_ADDR p = 0; |
int i = 0; |
while (i < MAX_PARTITION && p == NULL) { |
if (mem_table[i].used && (mem_table[i].size >= s)) |
p = mem_table[i].addr; |
else i++; |
} |
if (p != 0) { |
if (mem_table[i].size > s) { |
mem_table[i].size -= s; |
mem_table[i].addr += s; |
} |
else mem_table[i].used = FALSE; |
} |
return(p); |
} |
__attribute__ ((weak)) int DOS_free(LIN_ADDR p,DWORD s) |
{ |
register int i = 1; |
unsigned i1 = 0, i2 = 0; |
while (i < MAX_PARTITION && ((i1 == 0) || (i2 == 0)) ) { |
if (mem_table[i].used) { |
if (mem_table[i].addr + mem_table[i].size == p) i1 = i; |
if (mem_table[i].addr == p + s) i2 = i; |
} |
i++; |
} |
if (i1 != 0 && i2 != 0) { |
mem_table[i1].size += mem_table[i2].size + s; |
mem_table[i2].used = FALSE; |
} |
else if (i1 == 0 && i2 != 0) { |
mem_table[i2].addr = p; |
mem_table[i2].size += s; |
} |
else if (i1 != 0 && i2 == 0) mem_table[i1].size += s; |
else { |
i = 0; |
while (i < MAX_PARTITION && (mem_table[i].used == TRUE)) i++; |
if (i == MAX_PARTITION) return(FALSE); |
mem_table[i].addr = p; |
mem_table[i].size = s; |
mem_table[i].used = TRUE; |
} |
return(TRUE); |
}*/ |
/shark/trunk/arch/x86/ccpu.c |
---|
0,0 → 1,97 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* CPU detection code */ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-arch.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/advtimer.h> |
#include <ll/i386/apic.h> |
FILE(Cpu-C); |
INLINE_OP void cpuid(DWORD a, DWORD *outa, DWORD *outb, DWORD *outc, DWORD *outd) |
{ |
#ifdef __OLD_GNU__ |
__asm__ __volatile__ (".byte 0x0F,0xA2" |
#else |
__asm__ __volatile__ ("cpuid" |
#endif |
: "=a" (*outa), |
"=b" (*outb), |
"=c" (*outc), |
"=d" (*outd) |
: "a" (a)); |
} |
void X86_get_CPU(struct ll_cpuInfo *p) |
{ |
DWORD tmp; |
memset(p, 0, sizeof(struct ll_cpuInfo)); |
if (X86_is386()) { |
p->X86_cpu = 3; |
return; |
} |
if (X86_isCyrix()) { |
X86_enable_cyrix_cpuid(); |
} |
if (X86_hasCPUID()) { |
p->X86_cpuIdFlag = 1; |
p->X86_cpu = 5; |
cpuid(0, &tmp, &(p->X86_vendor_1), |
&(p->X86_vendor_3), |
&(p->X86_vendor_2)); |
if (tmp >= 1) { |
cpuid(1, &(p->X86_signature), |
&(p->X86_IntelFeature_1), |
&(p->X86_IntelFeature_2), |
&(p->X86_StandardFeature)); |
#ifdef __APIC__ |
if ((p->X86_StandardFeature >> 5) & 1) { |
unsigned long msr_original_low, msr_original_high; |
rdmsr(APIC_BASE_MSR, msr_original_low, msr_original_high); |
wrmsr(APIC_BASE_MSR, msr_original_low|(1<<11), 0); |
cpuid(1, &(p->X86_signature), |
&(p->X86_IntelFeature_1), |
&(p->X86_IntelFeature_2), |
&(p->X86_StandardFeature)); |
wrmsr(APIC_BASE_MSR, msr_original_low, msr_original_high); |
} |
#endif |
} |
} else { |
p->X86_cpu = 4; |
if (X86_isCyrix()) { |
p->X86_cpu = 11; |
} |
/* Need tests for AMD and others... */ |
} |
} |
/shark/trunk/arch/x86/fpu.c |
---|
0,0 → 1,90 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* |
FPU Context switch & management functions! |
Generic 32 bit module |
*/ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/tss-ctx.h> |
FILE(FPU); |
extern TSS main_tss; |
BYTE LL_FPU_savearea[FPU_CONTEXT_SIZE]; /* Global FPU scratch SaveArea */ |
#ifdef __FPU_DEBUG__ |
long int ndp_called = 0,ndp_switched = 0; |
#endif |
/* FPU context management */ |
static TSS *LL_has_FPU = &main_tss; |
/* As the 8086 does not have an hardware mechanism to support task */ |
/* switch, also the FPU context switch is implemented via software. */ |
/* When a preemption occurs, if the task is marked as a MATH task, the */ |
/* preemption routine will save/restore the FPU context. */ |
/* The hook is called whenever a FPU context switch is necessarty */ |
void ll_FPU_hook(void) |
{ |
CONTEXT current; |
TSS *base; |
current = get_TR(); |
base = (TSS *)GDT_read(current, NULL, NULL, NULL); |
clts(); |
#ifdef __FPU_DEBUG__ |
ndp_called++; |
#endif |
if (LL_has_FPU == base) return; |
#ifdef __FPU_DEBUG__ |
ndp_switched++; |
#endif |
#if 0 |
LL_FPU_save(); |
memcpy(TSS_table[LL_has_FPU].ctx_FPU,LL_FPU_savearea,FPU_CONTEXT_SIZE); |
#else |
save_fpu(LL_has_FPU); |
#endif |
LL_has_FPU = base; |
#if 1 |
memcpy(LL_FPU_savearea, base->ctx_FPU, FPU_CONTEXT_SIZE); |
LL_FPU_restore(); |
#else |
restore_fpu(&(TSS_table[LL_has_FPU])); |
#endif |
return; |
} |
TSS *LL_FPU_get_task(void) |
{ |
return(LL_has_FPU); |
} |
/shark/trunk/arch/x86/irq.c |
---|
0,0 → 1,121 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* PIC management code & data */ |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/pic.h> |
FILE(IRQ); |
#define ICW1_M 0x020 /* Master PIC (8259) register settings */ |
#define ICW2_M 0x021 |
#define ICW3_M 0x021 |
#define ICW4_M 0x021 |
#define OCW1_M 0x021 |
#define OCW2_M 0x020 |
#define OCW3_M 0x020 |
#define ICW1_S 0x0A0 /* Slave PIC register setting */ |
#define ICW2_S 0x0A1 |
#define ICW3_S 0x0A1 |
#define ICW4_S 0x0A1 |
#define OCW1_S 0x0A1 |
#define OCW2_S 0x0A0 |
#define OCW3_S 0x0A0 |
#define EOI 0x020 /* End Of Interrupt code for PIC! */ |
#define bit_on(v,b) ((v) |= (1 << (b))) |
#define bit_off(v,b) ((v) &= ~(1 << (b))) |
/* PIC interrupt mask */ |
BYTE ll_PIC_master_mask = 0xFF; |
BYTE ll_PIC_slave_mask = 0xFF; |
void PIC_init(void) |
{ |
outp(ICW1_M,0x11); |
outp(ICW2_M,PIC1_BASE); |
outp(ICW3_M,0x04); |
outp(ICW4_M,0x01); |
outp(OCW1_M,0xFF); |
outp(ICW1_S,0x11); |
outp(ICW2_S,PIC2_BASE); |
outp(ICW3_S,0x02); |
outp(ICW4_S,0x01); |
outp(OCW1_S,0xFF); |
} |
void PIC_end(void) |
{ |
outp(ICW1_M,0x11); |
outp(ICW2_M,0x08); |
outp(ICW3_M,0x04); |
outp(ICW4_M,0x01); |
outp(OCW1_M,0xFF); |
outp(ICW1_S,0x11); |
outp(ICW2_S,0x70); |
outp(ICW3_S,0x02); |
outp(ICW4_S,0x01); |
outp(OCW1_S,0xFF); |
} |
void irq_mask(WORD irqno) |
{ |
/* Interrupt is on master PIC */ |
if (irqno < 8) { |
bit_on(ll_PIC_master_mask,irqno); |
outp(0x21,ll_PIC_master_mask); |
} else if (irqno < 16) { |
/* Interrupt on slave PIC */ |
bit_on(ll_PIC_slave_mask,irqno-8); |
outp(0xA1,ll_PIC_slave_mask); |
/* If the slave PIC is completely off */ |
/* Then turn off cascading line (Irq #2)*/ |
if (ll_PIC_slave_mask == 0xFF && !(ll_PIC_master_mask & 0x04)) { |
bit_on(ll_PIC_master_mask,2); |
outp(0x21,ll_PIC_master_mask); |
} |
} |
} |
void irq_unmask(WORD irqno) |
{ |
/* Interrupt is on master PIC */ |
if (irqno < 8) { |
bit_off(ll_PIC_master_mask,irqno); |
outp(0x21,ll_PIC_master_mask); |
} else if (irqno < 16) { |
/* Interrupt on slave PIC */ |
bit_off(ll_PIC_slave_mask,irqno-8); |
outp(0xA1,ll_PIC_slave_mask); |
/* If the cascading irq line was off */ |
/* Then activate it also! */ |
if (ll_PIC_master_mask & 0x04) { |
bit_off(ll_PIC_master_mask,2); |
outp(0x21,ll_PIC_master_mask); |
} |
} |
} |
/shark/trunk/arch/x86/xconv.c |
---|
0,0 → 1,62 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The OSLib (flat space) <-> Phisical address conversion */ |
#include <ll/i386/hw-func.h> |
#include <ll/i386/mem.h> |
FILE(X-Conv); |
/* Conversion between PM address space & phisical address space */ |
/* If we do not support paging we need to relocate the .ELF executable */ |
/* using the segment register; however we also need to access all the */ |
/* phisical memory; for example if we allocate some memory (phisical) */ |
/* and we use a pointer to access that memory, the pointer will use */ |
/* the current DS to address the specified offset; but the phisical */ |
/* offset cannot be used because the base of DS is not zero as required */ |
/* to access phisical memory; the DS base is stored by X into the */ |
/* exec_base field of _X_info! This is the key to traslate ELF address */ |
/* into phisical address & viceversa */ |
/* |
DWORD appl2linear(void *p) |
{ |
unsigned long result; |
result = (DWORD)(p) + _X_info->exec_base; |
return(result); |
} |
void *linear2appl(DWORD a) |
{ |
void *p; |
if (a < _X_info->exec_base) p = NULL; |
else p = (void *)(a-_X_info->exec_base); |
return(p); |
} |
*/ |
LIN_ADDR addr2linear(unsigned short seg,unsigned long offset) |
{ |
LIN_ADDR flatbase; |
flatbase = (LIN_ADDR)GDT_read(seg,NULL,NULL,NULL); |
return(flatbase + offset); |
} |
/shark/trunk/arch/x86/time.c |
---|
0,0 → 1,151 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Time management code: ll_getttime() */ |
/* Added Advanced Timer Code |
* |
* Date: 8.4.2003 |
* Author: Giacomo Guidi <giacomo@gandalf.sssup.it> |
* |
*/ |
#include <arch/i386/stdlib.h> |
#include <ll/i386/pit.h> |
#include <ll/i386/error.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/advtimer.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/ll-func.h> |
#include <ll/sys/ll/time.h> |
/* These are for the EXECT and TICK modes */ |
extern DWORD ticksize; /* From init.c */ |
extern struct timespec actTime; /* From event.c */ |
extern WORD pit_time_const; /* From init.c */ |
extern DWORD timermode; /* From init.c */ |
/* These two are for the NEW algorithm */ |
extern WORD lastTime; /* From event.c */ |
extern struct pitspec globalCounter; /* From event.c */ |
extern BYTE frc; |
extern int activeEvent; |
extern unsigned char use_tsc; |
FILE(Time); |
TIME ll_gettime(int mode, struct timespec *tsres) |
{ |
if (!use_tsc) { |
DWORD res, tc; |
BYTE isr; |
struct timespec tmp; |
#if 1 |
if (activeEvent) { |
if (tsres != NULL) { |
PITSPEC2TIMESPEC(&globalCounter, tsres); |
} else { |
struct timespec tmp; |
PITSPEC2TIMESPEC(&globalCounter, &tmp); |
return TIMESPEC2USEC(&tmp); |
} |
return TIMESPEC2USEC(tsres); |
} |
#endif |
if (mode == TIME_PTICK) { |
if (timermode != LL_PERIODIC) { |
return 0; |
} |
res = TIMESPEC2USEC(&actTime); |
if (tsres != NULL) { |
memcpy(tsres, &actTime, sizeof(struct timespec)); |
} |
return res; |
} |
if (mode == TIME_NEW) { |
WORD tmp; |
tmp = pit_read(frc); |
ADDPITSPEC((WORD)(lastTime - tmp), &globalCounter); |
lastTime = tmp; |
if (tsres != NULL) { |
PITSPEC2TIMESPEC(&globalCounter, tsres); |
} |
return (PITSPEC2USEC(&globalCounter)); |
} |
if (mode == TIME_EXACT) { |
if (timermode == LL_PERIODIC) { |
memcpy(&tmp, &actTime, sizeof(struct timespec)); |
/* How much time has elapsed |
* from the last Tick Boundary? |
*/ |
tc = pit_read(0); |
if (tc > pit_time_const) { |
error("LL Time Panic!!!\n"); |
ll_abort(1); |
} |
res = pit_time_const - tc; |
res *= ticksize; |
res /= pit_time_const; |
/* Detect tick boundary and adjust the time... */ |
outp(0x20, 0x0A); |
isr = inp(0x20); |
if ((isr & 1) && res < ((8*ticksize)/10)){ |
/* |
res += ticksize; |
ADDNANO2TIMESPEC(ticksize * 1000, &tmp); |
*/ |
res = ticksize; |
} |
/* Sum the Tick time... */ |
ADDNANO2TIMESPEC(res * 1000, &tmp); |
res += TIMESPEC2USEC(&actTime); |
if (tsres != NULL) { |
memcpy(tsres, &tmp, sizeof(struct timespec)); |
} |
return res; |
} else { |
return 0; |
} |
} |
return 0; |
} else { |
if (tsres != NULL) { |
ll_read_timespec(tsres); |
return TIMESPEC2USEC(tsres); |
} else { |
struct timespec tmp; |
ll_read_timespec(&tmp); |
return TIMESPEC2USEC(&tmp); |
} |
} |
} |
/shark/trunk/arch/x86/exc.s |
---|
0,0 → 1,652 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Exc/IRQ handlers (asm part) */ |
/* TODO: Unify the Exc/Int Mechanism... */ |
#include <ll/i386/sel.h> |
#include <ll/i386/linkage.h> |
#include <ll/i386/int.h> |
#include <ll/i386/defs.h> |
.extern SYMBOL_NAME(GDT_base) |
.extern SYMBOL_NAME(global_regs) |
.extern SYMBOL_NAME(VM86_ret_ctx) |
.data |
ASMFILE(Exc) |
.globl SYMBOL_NAME(ll_irq_table) |
SYMBOL_NAME_LABEL(ll_irq_table) .space 1024, 0 |
.text |
.extern SYMBOL_NAME(ll_exc_hook) |
.extern SYMBOL_NAME(ll_FPU_hook) |
.globl SYMBOL_NAME(h13_bis) |
.globl SYMBOL_NAME(exc7) |
/* These are the hardware handlers; they all jump to ll_handler setting */ |
/* the interrupt number into EAX & save the registers on stack */ |
INT(0) |
INT(1) |
INT(2) |
INT(3) |
INT(4) |
INT(5) |
INT(6) |
INT(8) |
INT(9) |
INT(10) |
INT(11) |
INT(12) |
INT(13) |
INT(14) |
INT(15) |
NONE(16) |
INT(17) |
INT(18) |
INT(19) |
INT(20) |
INT(21) |
INT(22) |
INT(23) |
INT(24) |
INT(25) |
INT(26) |
INT(27) |
INT(28) |
INT(29) |
INT(30) |
INT(31) |
INT(32) |
INT(33) |
INT(34) |
INT(35) |
INT(36) |
INT(37) |
INT(38) |
INT(39) |
INT(40) |
INT(41) |
INT(42) |
INT(43) |
INT(44) |
INT(45) |
INT(46) |
INT(47) |
INT(48) |
INT(49) |
INT(50) |
INT(51) |
INT(52) |
INT(53) |
INT(54) |
INT(55) |
INT(56) |
INT(57) |
INT(58) |
INT(59) |
INT(60) |
INT(61) |
INT(62) |
INT(63) |
/* Master PIC... (int 0x40, see ll/i386/pic.h)*/ |
INT_1(64) |
INT_1(65) |
INT_1(66) |
INT_1(67) |
INT_1(68) |
INT_1(69) |
INT_1(70) |
INT_1(71) |
VM86(72) |
INT(73) |
INT(74) |
INT(75) |
INT(76) |
INT(77) |
INT(78) |
INT(79) |
INT(80) |
INT(81) |
INT(82) |
INT(83) |
INT(84) |
INT(85) |
INT(86) |
INT(87) |
INT(88) |
INT(89) |
INT(90) |
INT(91) |
INT(92) |
INT(93) |
INT(94) |
INT(95) |
INT(96) |
INT(97) |
INT(98) |
INT(99) |
INT(100) |
INT(101) |
INT(102) |
INT(103) |
INT(104) |
INT(105) |
INT(106) |
INT(107) |
INT(108) |
INT(109) |
INT(110) |
INT(111) |
/* Slave PIC... (int 0x70, see ll/i386/pic.h)*/ |
INT_2(112) |
INT_2(113) |
INT_2(114) |
INT_2(115) |
INT_2(116) |
INT_2(117) |
INT_2(118) |
INT_2(119) |
INT(120) |
INT(121) |
INT(122) |
INT(123) |
INT(124) |
INT(125) |
INT(126) |
INT(127) |
INT(128) |
INT(129) |
INT(130) |
INT(131) |
INT(132) |
INT(133) |
INT(134) |
INT(135) |
INT(136) |
INT(137) |
INT(138) |
INT(139) |
INT(140) |
INT(141) |
INT(142) |
INT(143) |
INT(144) |
INT(145) |
INT(146) |
INT(147) |
INT(148) |
INT(149) |
INT(150) |
INT(151) |
INT(152) |
INT(153) |
INT(154) |
INT(155) |
INT(156) |
INT(157) |
INT(158) |
INT(159) |
INT(160) |
INT(161) |
INT(162) |
INT(163) |
INT(164) |
INT(165) |
INT(166) |
INT(167) |
INT(168) |
INT(169) |
INT(170) |
INT(171) |
INT(172) |
INT(173) |
INT(174) |
INT(175) |
INT(176) |
INT(177) |
INT(178) |
INT(179) |
INT(180) |
INT(181) |
INT(182) |
INT(183) |
INT(184) |
INT(185) |
INT(186) |
INT(187) |
INT(188) |
INT(189) |
INT(190) |
INT(191) |
INT(192) |
INT(193) |
INT(194) |
INT(195) |
INT(196) |
INT(197) |
INT(198) |
INT(199) |
INT(200) |
INT(201) |
INT(202) |
INT(203) |
INT(204) |
INT(205) |
INT(206) |
INT(207) |
INT(208) |
INT(209) |
INT(210) |
INT(211) |
INT(212) |
INT(213) |
INT(214) |
INT(215) |
INT(216) |
INT(217) |
INT(218) |
INT(219) |
INT(220) |
INT(221) |
INT(222) |
INT(223) |
INT(224) |
INT(225) |
INT(226) |
INT(227) |
INT(228) |
INT(229) |
INT(230) |
INT(231) |
INT(232) |
INT(233) |
INT(234) |
INT(235) |
INT(236) |
INT(237) |
INT(238) |
INT(239) |
INT(240) |
INT(241) |
INT(242) |
INT(243) |
INT(244) |
INT(245) |
INT(246) |
INT(247) |
INT(248) |
INT(249) |
INT(250) |
INT(251) |
INT(252) |
INT(253) |
INT(254) |
INT(255) |
/* The ll_handler process the request using the kernel function act_int() */ |
/* Then sends EOI & schedules any eventual new task! */ |
ll_handler: |
/* We do not know what is the DS value */ |
/* Then we save it & set it correctly */ |
pushl %ds |
pushl %ss |
pushl %es |
pushl %fs |
pushl %gs |
/* But we first transfer to the _act_int */ |
/* the interrupt number which is required */ |
/* as second argument */ |
pushl %eax |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
mov %ax,%ds |
movw %ax, %fs |
movw %ax, %gs |
/* Now save the actual context on stack */ |
/* to pass it to _act_int (C caling convention) */ |
/* CLD is necessary when calling a C function */ |
cld |
/* The following could be optimized a little... */ |
popl %eax |
xorl %ebx, %ebx |
movw %ss, %bx |
/* We must switch to a ``safe stack'' */ |
/* |
* OK, this is the idea: in %esp we have the address of the |
* stack pointer in the APPLICATION address space... |
* We assume that address spaces are implemented through segments... |
* What we have to do is to add the segment base to %esp: |
* - Load the GDT base in a register |
* - Add DS * 8 to that value |
* - Read the corresponding GDT entry (the segment descriptor) |
* - Compute the base... |
* It is (*p & 0xFC) | (*(p +1) & 0x0F) << 16) | *(p + 2) |
*/ |
movl SYMBOL_NAME(GDT_base), %edi |
addl %ebx, %edi |
xorl %ebx, %ebx |
movb 7(%edi), %bh |
movb 4(%edi), %bl |
shl $16, %ebx |
movw 2(%edi), %bx |
/* Is it correct? I think so... Test it!!! */ |
addl %ebx, %esp |
/* Save EBX for returning to our stack... */ |
movw %ss, %dx |
movw %ds, %cx |
movw %cx, %ss |
pushl %ebx |
pushl %edx |
pushl %eax |
movl SYMBOL_NAME(ll_irq_table)(, %eax, 4), %ebx |
call *%ebx |
popl %ebx /* Store in EBX the Int number */ |
popl %eax |
popl %ecx /* We must subtract it from ESP...*/ |
subl %ecx, %esp |
movw %ax, %ss |
/* Resume the return value of _act_int */ |
/* & do the context switch if necessary! */ |
#ifdef __VIRCSW__ |
movw SYMBOL_NAME(currCtx), %ax |
cmpw JmpSel,%ax |
je NoPreempt3 |
movw %ax,JmpSel |
ljmp *JmpZone |
#endif |
NoPreempt3: popl %gs |
popl %fs |
popl %es |
popl %ss |
popl %ds |
popal |
iret |
ll_handler_master_pic: |
/* We do not know what is the DS value */ |
/* Then we save it & set it correctly */ |
pushl %ds |
pushl %ss |
pushl %es |
pushl %fs |
pushl %gs |
/* But we first transfer to the _act_int */ |
/* the interrupt number which is required */ |
/* as second argument */ |
pushl %eax |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
mov %ax,%ds |
movw %ax, %fs |
movw %ax, %gs |
/* Now save the actual context on stack */ |
/* to pass it to _act_int (C caling convention) */ |
/* CLD is necessary when calling a C function */ |
cld |
/* The following could be optimized a little... */ |
popl %eax |
xorl %ebx, %ebx |
movw %ss, %bx |
/* We must switch to a ``safe stack'' */ |
/* |
* OK, this is the idea: in %esp we have the address of the |
* stack pointer in the APPLICATION address space... |
* We assume that address spaces are implemented through segments... |
* What we have to do is to add the segment base to %esp: |
* - Load the GDT base in a register |
* - Add DS * 8 to that value |
* - Read the corresponding GDT entry (the segment descriptor) |
* - Compute the base... |
* It is (*p & 0xFC) | (*(p +1) & 0x0F) << 16) | *(p + 2) |
*/ |
movl SYMBOL_NAME(GDT_base), %edi |
addl %ebx, %edi |
xorl %ebx, %ebx |
movb 7(%edi), %bh |
movb 4(%edi), %bl |
shl $16, %ebx |
movw 2(%edi), %bx |
/* Is it correct? I think so... Test it!!! */ |
addl %ebx, %esp |
/* Save EBX for returning to our stack... */ |
movw %ss, %dx |
movw %ds, %cx |
movw %cx, %ss |
pushl %ebx |
pushl %edx |
pushl %eax |
movl SYMBOL_NAME(ll_irq_table)(, %eax, 4), %ebx |
call *%ebx |
popl %ebx /* Store in EBX the Int number */ |
popl %eax |
popl %ecx /* We must subtract it from ESP...*/ |
subl %ecx, %esp |
movw %ax, %ss |
/* Send EOI to master PIC */ |
movb $0x20,%al |
movl $0x20,%edx |
outb %al,%dx |
/* Resume the return value of _act_int */ |
/* & do the context switch if necessary! */ |
#ifdef __VIRCSW__ |
movw SYMBOL_NAME(currCtx), %ax |
cmpw JmpSel,%ax |
je NoPreempt4 |
movw %ax,JmpSel |
ljmp *JmpZone |
#endif |
NoPreempt4: popl %gs |
popl %fs |
popl %es |
popl %ss |
popl %ds |
popal |
iret |
ll_handler_slave_pic: |
/* We do not know what is the DS value */ |
/* Then we save it & set it correctly */ |
pushl %ds |
pushl %ss |
pushl %es |
pushl %fs |
pushl %gs |
/* But we first transfer to the _act_int */ |
/* the interrupt number which is required */ |
/* as second argument */ |
pushl %eax |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
mov %ax,%ds |
movw %ax, %fs |
movw %ax, %gs |
/* Now save the actual context on stack */ |
/* to pass it to _act_int (C caling convention) */ |
/* CLD is necessary when calling a C function */ |
cld |
/* The following could be optimized a little... */ |
popl %eax |
xorl %ebx, %ebx |
movw %ss, %bx |
/* We must switch to a ``safe stack'' */ |
/* |
* OK, this is the idea: in %esp we have the address of the |
* stack pointer in the APPLICATION address space... |
* We assume that address spaces are implemented through segments... |
* What we have to do is to add the segment base to %esp: |
* - Load the GDT base in a register |
* - Add DS * 8 to that value |
* - Read the corresponding GDT entry (the segment descriptor) |
* - Compute the base... |
* It is (*p & 0xFC) | (*(p +1) & 0x0F) << 16) | *(p + 2) |
*/ |
movl SYMBOL_NAME(GDT_base), %edi |
addl %ebx, %edi |
xorl %ebx, %ebx |
movb 7(%edi), %bh |
movb 4(%edi), %bl |
shl $16, %ebx |
movw 2(%edi), %bx |
/* Is it correct? I think so... Test it!!! */ |
addl %ebx, %esp |
/* Save EBX for returning to our stack... */ |
movw %ss, %dx |
movw %ds, %cx |
movw %cx, %ss |
pushl %ebx |
pushl %edx |
pushl %eax |
movl SYMBOL_NAME(ll_irq_table)(, %eax, 4), %ebx |
call *%ebx |
popl %ebx /* Store in EBX the Int number */ |
popl %eax |
popl %ecx /* We must subtract it from ESP...*/ |
subl %ecx, %esp |
movw %ax, %ss |
/* Send EOI to master & slave PIC */ |
movb $0x20,%al |
movl $0xA0,%edx |
outb %al,%dx |
movl $0x20,%edx |
outb %al,%dx |
/* Resume the return value of _act_int */ |
/* & do the context switch if necessary! */ |
#ifdef __VIRCSW__ |
movw SYMBOL_NAME(currCtx), %ax |
cmpw JmpSel,%ax |
je NoPreempt5 |
movw %ax,JmpSel |
ljmp *JmpZone |
#endif |
NoPreempt5: popl %gs |
popl %fs |
popl %es |
popl %ss |
popl %ds |
popal |
iret |
ll_handler_vm86: |
pushl %ds |
pushl %ss |
pushl %es |
pushl %fs |
pushl %gs |
pushl %eax |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
movw %ax,%ds |
movw %ax,%fs |
movw %ax,%gs |
popl %eax |
pushl %ebx |
movl SYMBOL_NAME(global_regs),%ebx |
movl %eax,56(%ebx) |
movl %ecx,52(%ebx) |
movl %edx,48(%ebx) |
movl %edi,28(%ebx) |
movl %esi,32(%ebx) |
movl %ebx,%edi |
popl %ebx |
movl %ebx,44(%edi) |
pushfl |
popl %ebx |
movl %ebx,68(%edi) |
movw SYMBOL_NAME(VM86_ret_ctx), %ax |
movw %ax,SYMBOL_NAME(currCtx) |
movw %ax,JmpSel |
ljmp *JmpZone |
popl %gs |
popl %fs |
popl %es |
popl %ss |
popl %ds |
popal |
iret |
/* OK, this is Exception 7, and it is generated when an ESC or WAIT |
* intruction is reached, and the MP and TS bits are set... Basically, |
* it means that the FPU context must be switched |
*/ |
SYMBOL_NAME_LABEL(exc7) pushal |
pushl %ds |
pushl %ss |
pushl %es |
pushl %fs |
pushl %gs |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%es |
movw %ax,%ds |
cld |
call SYMBOL_NAME(ll_FPU_hook) |
popl %gs |
popl %fs |
popl %es |
popl %ss |
popl %ds |
popal |
iret |
/shark/trunk/arch/x86/vm86.c |
---|
0,0 → 1,336 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* File: Vm86.C |
* |
* VM86 mode switch routines! |
* This is basically an alternative way of invoking the |
* BIOS service routines; it is very useful to support |
* native VBE compliant Video card, without writing an explicit driver |
*/ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/x-bios.h> |
#include <ll/i386/x-dosmem.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/error.h> |
#include <ll/i386/apic.h> |
#include <ll/i386/advtimer.h> |
FILE(VM-86); |
/* |
#define __LL_DEBUG__ |
#define __DUMB_CODE__ |
#define __CHK_IO__ |
*/ |
//#define __LL_DEBUG__ |
#define VM86_STACK_SIZE 8192 |
extern DWORD ll_irq_table[256]; |
extern unsigned char use_apic, use_tsc; |
/* TSS optional section */ |
static BYTE vm86_stack0[VM86_STACK_SIZE]; |
static BYTE init = 0; |
static struct { |
TSS t; |
DWORD io_map[2048]; |
} vm86_TSS; |
static LIN_ADDR vm86_stack; |
static LIN_ADDR vm86_iretAddress; |
struct registers *global_regs; |
WORD VM86_ret_ctx; |
#ifdef __DUMB_CODE__ |
static LIN_ADDR vm86_code; |
static BYTE prova86[] = { |
0x1e, /* push ds */ |
0xb8,0x00,0xb8, /* mov ax,0xb800 */ |
0x8e,0xd8, /* mov ds,ax */ |
0xbf,0x9e,0x00, /* mov di,0x009e (158) */ |
0xb0,0x2a, /* mov ax,'*' */ |
0x88,0x05, /* mov ds:[di],al */ |
0x1f, /* pop ds */ |
0xcd, 0x40, /*???*/ |
#ifdef __CHK_IO__ |
0xb0, 0x00, /* movb $0x0,%al*/ |
0x66,0xba, 0x80, 0x00, /* movw $0x80,%dx */ |
0x66,0xef, /* outw %ax, (%dx) */ |
#endif |
0xcf, /* iret */ |
0xf4, /* hlt */ |
0}; |
#endif |
static BYTE vm86_retAddr[] = {0xcd, 0x48, /* int 48h */ |
0xf4, |
0}; |
TSS *vm86_get_tss(void) |
{ |
return &(vm86_TSS.t); |
} |
/* Just a debugging function; it dumps the status of the TSS */ |
void vm86_dump_TSS(void) |
{ |
BYTE acc,gran; |
DWORD base,lim; |
message("vm86_TSS.t dump\n"); |
message("Flag: %lx\n",vm86_TSS.t.eflags); |
message("SS: %hx SP:%lx\n", vm86_TSS.t.ss,vm86_TSS.t.esp); |
message("Stack0: %hx:%lx\n",vm86_TSS.t.ss0,vm86_TSS.t.esp0); |
message("Stack1: %hx:%lx\n",vm86_TSS.t.ss1,vm86_TSS.t.esp1); |
message("Stack2: %hx:%lx\n",vm86_TSS.t.ss2,vm86_TSS.t.esp2); |
message("CS: %hx IP: %lx",vm86_TSS.t.cs, vm86_TSS.t.eip); |
message("DS: %hx\n",vm86_TSS.t.ds); |
base = GDT_read(X_VM86_TSS,&lim,&acc,&gran); |
message("Base : %lx Lim : %lx Acc : %x Gran %x\n", |
base,lim,(unsigned)(acc),(unsigned)(gran)); |
} |
void vm86_init(void) |
{ |
int register i; |
if (init != 0) return; |
init = 1; |
/* First of all, we need to setup a GDT entries to |
* allow vm86 task execution. We just need a free 386 TSS, which |
* will be used to store the execution context of the virtual 8086 |
* task |
*/ |
GDT_place(X_VM86_TSS,(DWORD)(&vm86_TSS), |
sizeof(vm86_TSS),FREE_TSS386,GRAN_16); |
/* Return Registers */ |
global_regs = DOS_alloc(sizeof(struct registers)); |
/* Prepare a real-mode stack, obtaining it from the |
* DOS memory allocator! |
* 8K should be OK! Stack top is vm86_stack + SIZE! |
*/ |
vm86_stack = DOS_alloc(VM86_STACK_SIZE*2); |
vm86_stack += VM86_STACK_SIZE/2; |
vm86_iretAddress = DOS_alloc(sizeof(vm86_retAddr)); |
memcpy(vm86_iretAddress,vm86_retAddr,sizeof(vm86_retAddr)); |
#ifdef __LL_DEBUG__ |
message("PM reentry linear address=0x%lx\n", (DWORD)vm86_iretAddress); |
#endif |
#ifdef __DUMB_CODE__ |
vm86_code = DOS_alloc(2048); |
lmemcpy(vm86_code,prova86,sizeof(prova86)); |
#endif |
/* Zero the PM/Ring[1,2] ss:esp; they're unused! */ |
vm86_TSS.t.esp1 = 0; |
vm86_TSS.t.esp2 = 0; |
vm86_TSS.t.ss1 = 0; |
vm86_TSS.t.ss2 = 0; |
/* Use only the GDT */ |
vm86_TSS.t.ldt = 0; |
/* No paging activated */ |
vm86_TSS.t.cr3 = 0; |
vm86_TSS.t.trap = 0; |
/* Yeah, free access to any I/O port; we trust BIOS anyway! */ |
/* Here is the explanation: we have 65536 I/O ports... each bit |
* in the io_map masks/unmasks the exception for the given I/O port |
* If the bit is set, an exception is generated; otherwise, if the bit |
* is clear, everythings works fine... |
* Because of alignment problem, we need to add an extra byte all set |
* to 1, according to Intel manuals |
*/ |
vm86_TSS.t.io_base = (DWORD)(&(vm86_TSS.io_map)) - |
(DWORD)(&(vm86_TSS)); |
for (i = 0; i < 2047; i++) vm86_TSS.io_map[i] = 0; |
vm86_TSS.io_map[2047] = 0xFF000000; |
} |
int vm86_callBIOS(int service,X_REGS16 *in,X_REGS16 *out,X_SREGS16 *s) |
{ |
DWORD vm86_tmpAddr; |
DWORD vm86_flags, vm86_cs,vm86_ip; |
LIN_ADDR vm86_stackPtr; |
DWORD *IRQTable_entry; |
BYTE p1,p2; |
DWORD msr1 = 0,msr2 = 0; |
SYS_FLAGS f; |
if (service < 0x10 || in == NULL) return -1; |
f = ll_fsave(); |
/* Setup the stack frame */ |
vm86_tmpAddr = (DWORD)(vm86_stack); |
vm86_TSS.t.ss = (vm86_tmpAddr & 0xFF000) >> 4; |
vm86_TSS.t.ebp = vm86_TSS.t.esp = (vm86_tmpAddr & 0x0FFF) |
+ VM86_STACK_SIZE - 6; |
/* Build an iret stack frame which returns to vm86_iretAddress */ |
vm86_tmpAddr = (DWORD)(vm86_iretAddress); |
vm86_cs = (vm86_tmpAddr & 0xFF000) >> 4; |
vm86_ip = (vm86_tmpAddr & 0xFFF); |
vm86_flags = 0; |
vm86_stackPtr = vm86_stack + VM86_STACK_SIZE; |
lmempokew(vm86_stackPtr-6,vm86_ip); |
lmempokew(vm86_stackPtr-4,vm86_cs); |
lmempokew(vm86_stackPtr-2,vm86_flags); |
#ifdef __LL_DEBUG__ |
message("Stack: %lx SS: %lx SP: %lx\n", |
vm86_tmpAddr + VM86_STACK_SIZE,(DWORD)vm86_TSS.t.ss,vm86_TSS.t.esp); |
#endif |
/* Wanted VM86 mode + IOPL = 3! */ |
vm86_TSS.t.eflags = CPU_FLAG_VM + CPU_FLAG_IOPL; |
/* Preload some standard values into the registers */ |
vm86_TSS.t.ss0 = X_FLATDATA_SEL; |
vm86_TSS.t.esp0 = (DWORD)&(vm86_stack0[VM86_STACK_SIZE-1]); |
#ifdef __DUMB_CODE__ |
vm86_TSS.t.cs = ((DWORD)(vm86_code) & 0xFFFF0) >> 4; |
vm86_TSS.t.eip = ((DWORD)(vm86_code) & 0x000F); |
#ifdef __LL_DEBUG_ |
message("(DUMB CODE) CS:%x IP:%x/%x\n", |
(DWORD)vm86_TSS.t.cs,vm86_TSS.t.eip,&prova86); |
message("(DUMB CODE) Go...\n"); |
#endif |
p1 = inp(0x21); |
p2 = inp(0xA1); |
outp(0x21,0xFF); |
outp(0xA1,0xFF); |
if (use_apic) { |
rdmsr(APIC_BASE_MSR,msr1,msr2); |
disable_APIC_timer(); |
} |
vm86_TSS.t.back_link = ll_context_save(); |
VM86_ret_ctx = vm86_TSS.t.back_link |
sti(); |
ll_context_load(X_VM86_TSS); |
cli(); |
if (use_apic) { |
wrmsr(APIC_BASE_MSR,msr1,msr2); |
enable_APIC_timer(); |
} |
outp(0x21,p1); |
outp(0xA1,p2); |
#ifdef __LL_DEBUG_ |
message("(DUMB CODE) I am back...\n"); |
#endif |
#else |
/* Copy the parms from the X_*REGS structures in the vm86 TSS */ |
vm86_TSS.t.eax = (DWORD)in->x.ax; |
vm86_TSS.t.ebx = (DWORD)in->x.bx; |
vm86_TSS.t.ecx = (DWORD)in->x.cx; |
vm86_TSS.t.edx = (DWORD)in->x.dx; |
vm86_TSS.t.esi = (DWORD)in->x.si; |
vm86_TSS.t.edi = (DWORD)in->x.di; |
/* IF Segment registers are required, copy them... */ |
if (s != NULL) { |
vm86_TSS.t.es = (WORD)s->es; |
vm86_TSS.t.ds = (WORD)s->ds; |
} else { |
vm86_TSS.t.ds = vm86_TSS.t.ss; |
vm86_TSS.t.es = vm86_TSS.t.ss; |
} |
vm86_TSS.t.gs = vm86_TSS.t.ss; |
vm86_TSS.t.fs = vm86_TSS.t.ss; |
/* Execute the BIOS call, fetching the CS:IP of the real interrupt |
* handler from 0:0 (DOS irq table!) |
*/ |
IRQTable_entry = (void *)(0L); |
vm86_TSS.t.cs= ((IRQTable_entry[service]) & 0xFFFF0000) >> 16; |
vm86_TSS.t.eip = ((IRQTable_entry[service]) & 0x0000FFFF); |
#ifdef __LL_DEBUG__ |
message("CS:%x IP:%lx\n", vm86_TSS.t.cs, vm86_TSS.t.eip); |
#endif |
/* Let's use the ll standard call... */ |
p1 = inp(0x21); |
p2 = inp(0xA1); |
outp(0x21,0xFF); |
outp(0xA1,0xFF); |
if (use_apic) { |
rdmsr(APIC_BASE_MSR,msr1,msr2); |
disable_APIC_timer(); |
} |
vm86_TSS.t.back_link = ll_context_save(); |
VM86_ret_ctx = vm86_TSS.t.back_link; |
sti(); |
ll_context_load(X_VM86_TSS); |
cli(); |
if (use_apic) { |
wrmsr(APIC_BASE_MSR,msr1,msr2); |
enable_APIC_timer(); |
} |
outp(0x21,p1); |
outp(0xA1,p2); |
#ifdef __LL_DEBUG__ |
message("I am back...\n"); |
message("TSS CS=%hx IP=%lx\n", vm86_TSS.t.cs, vm86_TSS.t.eip); |
#endif |
/* Send back in the X_*REGS structure the value obtained with |
* the real-mode interrupt call |
*/ |
if (out != NULL) { |
out->x.ax = global_regs->eax; |
out->x.bx = global_regs->ebx; |
out->x.cx = global_regs->ecx; |
out->x.dx = global_regs->edx; |
out->x.si = global_regs->esi; |
out->x.di = global_regs->edi; |
out->x.cflag = global_regs->flags; |
//message("ax = %d bx = %d cx = %d dx = %d\n",out->x.ax,out->x.bx,out->x.cx,out->x.dx); |
//message("si = %d di = %d\n",out->x.si,out->x.di); |
} |
if (s != NULL) { |
s->es = vm86_TSS.t.es; |
s->ds = vm86_TSS.t.ds; |
} |
#endif |
ll_frestore(f); |
return 1; |
} |
/shark/trunk/arch/x86/event1.c |
---|
0,0 → 1,300 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Added Advanced Timer Code |
* |
* Date: 8.4.2003 |
* Author: Giacomo Guidi <giacomo@gandalf.sssup.it> |
* |
*/ |
/* Time Event routines (one shot mode) */ |
#include <arch/i386/stdlib.h> |
#include <arch/i386/limits.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/pit.h> |
#include <ll/i386/apic.h> |
#include <ll/i386/advtimer.h> |
#include <ll/i386/error.h> |
#include <ll/i386/64bit.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/ll-func.h> |
#include <ll/sys/ll/time.h> |
#include <ll/sys/ll/event.h> |
#include <tracer.h> |
extern unsigned short int currCtx; |
FILE(EventOneShot); |
extern int activeInt; |
int activeEvent; |
extern BYTE frc; |
extern struct event eventlist[MAX_EVENT]; |
extern WORD lastTime; |
extern struct pitspec globalCounter; |
extern struct event *freeevents; |
extern struct event *firstevent; |
extern void (*evt_prol) (void); |
extern void (*evt_epil) (void); |
extern unsigned int apic_clk_per_msec; |
extern unsigned char use_tsc, use_apic; |
/* Switched to timespec */ |
int oneshot_event_post(struct timespec time, void (*handler) (void *p), void *par) |
{ |
struct event *p; |
struct event *p1, *t; |
struct timespec now, tmp; |
int done; |
DWORD tnext; |
TRACER_LOGEVENT(FTrace_EVT_timer_post, 0, 0); |
if (!freeevents) { |
message("NO FREE EVENTS !\n"); |
ll_abort(20); |
return -1; |
} |
/* Extract from the ``free events'' queue */ |
p = freeevents; |
freeevents = p->next; |
/* Fill the event fields */ |
p->handler = handler; |
TIMESPEC_ASSIGN(&(p->time), &time); |
p->par = par; |
/* ...And insert it in the event queue!!! */ |
t = NULL; |
done = 0; |
/* walk through list, finding spot, adjusting ticks parameter */ |
for (p1 = firstevent; p1; p1 = t->next) { |
if (TIMESPEC_A_GT_B((&time), (&p1->time))) { |
t = p1; |
} else |
break; |
} |
/* adjust next entry */ |
if (t) { |
t->next = p; |
} else { |
firstevent = p; |
if (!activeEvent) { |
if (!use_tsc) { |
ll_gettime(TIME_NEW, &now); |
} else { |
ll_read_timespec(&now); |
} |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&tmp); |
} else { |
SUBTIMESPEC(&(firstevent->time), &now, &tmp); |
} |
tnext = TIMESPEC2USEC(&tmp); |
if (!use_apic) { |
mul32div32to32(tnext,1193182,1000000,tnext); |
pit_setconstant(0, tnext); |
} else { |
mul32div32to32(tnext,apic_clk_per_msec,1000,tnext); |
set_APIC_timer(tnext); |
} |
} |
} |
p->next = p1; |
return p->index; |
} |
void oneshot_wake_up(void) |
{ |
/* CHANGE the NAME, please... */ |
struct event *p = NULL, *pp; |
struct timespec now, ttmp; |
WORD tmp; |
DWORD tnext; |
DWORD max_tnext; |
TRACER_LOGEVENT(FTrace_EVT_timer_wakeup_start, 0, 0); |
if (!use_tsc) { |
tmp = pit_read(frc); |
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter); |
lastTime = tmp; |
PITSPEC2TIMESPEC(&globalCounter, &now); |
} else { |
ll_read_timespec(&now); |
} |
if (firstevent != NULL) { |
activeEvent = 1; |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
if (!activeInt && evt_prol != NULL) { |
evt_prol(); |
} |
activeInt++; |
for (p = firstevent; p != NULL; p = pp) { |
if ((p->time.tv_sec > now.tv_sec) || |
((p->time.tv_sec == now.tv_sec) |
&& (p->time.tv_nsec > now.tv_nsec))) { |
break; |
} |
pp = p->next; |
p->next = freeevents; |
freeevents = p; |
firstevent = pp; |
p->handler(p->par); |
} |
if (activeInt == 1 && evt_epil != NULL) { |
evt_epil(); |
} |
activeInt--; |
} |
if (!use_tsc) { |
tmp = pit_read(frc); |
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter); |
lastTime = tmp; |
PITSPEC2TIMESPEC(&globalCounter, &now); |
} else { |
ll_read_timespec(&now); |
} |
if (firstevent) { |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&ttmp); |
} else { |
SUBTIMESPEC(&(firstevent->time), &now, &ttmp); |
} |
/* SUBTIMESPEC(&(firstevent->time), &now, &ttmp); */ |
tnext = TIMESPEC2USEC(&ttmp); |
if (!use_apic) { |
mul32div32to32(INT_MAX,1000000,1193182,max_tnext); |
} else { |
mul32div32to32(INT_MAX,1000,apic_clk_per_msec,max_tnext); |
} |
if (tnext>max_tnext) { |
message("(************TIME IN THE FUTURE************)"); |
} |
if (!use_apic) { |
mul32div32to32(tnext,1193182,1000000,tnext); |
pit_setconstant(0, tnext); |
} else { |
mul32div32to32(tnext,apic_clk_per_msec,1000,tnext); |
set_APIC_timer(tnext); |
} |
} else { |
if (!use_apic) |
pit_setconstant(0, 0xFFFF); |
else |
set_APIC_timer(0xFFFFFFFF); |
} |
activeEvent = 0; |
} else { |
if (!use_apic) |
pit_setconstant(0, 0xFFFF); |
else |
set_APIC_timer(0xFFFFFFFF); |
} |
TRACER_LOGEVENT(FTrace_EVT_timer_wakeup_end, (unsigned short int)currCtx, 0); |
} |
int oneshot_event_delete(int index) |
{ |
struct event *p1, *t; |
struct timespec tmp, now; |
DWORD tnext; |
int firstdeleted = FALSE; |
TRACER_LOGEVENT(FTrace_EVT_timer_delete, 0, 0); |
if (index == -1) |
return -1; |
t = NULL; |
/* walk through list, finding spot, adjusting ticks parameter */ |
for (p1 = firstevent; (p1) && (index != p1->index); p1 = t->next) { |
t = p1; |
} |
if (p1 == NULL) { |
return -1; |
} |
if (t == NULL) { |
firstevent = p1->next; |
firstdeleted = TRUE; |
} else { |
t->next = p1->next; |
} |
p1->next = freeevents; |
freeevents = p1; |
if (!activeEvent) { |
if (firstevent == NULL) { |
if (!use_apic) |
pit_setconstant(0, 0xFFFF); |
else |
set_APIC_timer(0xFFFFFFFF); |
} else { |
if (firstdeleted) { |
if (!use_tsc) |
ll_gettime(TIME_NEW, &now); |
else |
ll_read_timespec(&now); |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&tmp); |
} else { |
SUBTIMESPEC(&(firstevent->time), &now, &tmp); |
} |
/*SUBTIMESPEC(&now, &(firstevent->time), &tmp); */ |
tnext = TIMESPEC2USEC(&tmp); |
if (!use_apic) { |
mul32div32to32(tnext,1193182,1000000,tnext); |
pit_setconstant(0, tnext); |
} else { |
mul32div32to32(tnext,apic_clk_per_msec,1000,tnext); |
set_APIC_timer(tnext); |
} |
} |
} |
} |
return 1; |
} |
/shark/trunk/arch/x86/include/arch/ll/i386/x-bios.h |
---|
0,0 → 1,83 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* For accessing BIOS calls returning in Real Mode, or using VM86 */ |
#ifndef __LL_I386_X_BIOS_H__ |
#define __LL_I386_X_BIOS_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#define DOS_OFF(x) ((DWORD)(x) & 0x000F) |
#define DOS_SEG(x) (((DWORD)(x) & 0xFFFF0) >> 4) |
typedef union x_regs16 { |
struct { |
WORD ax; |
WORD bx; |
WORD cx; |
WORD dx; |
WORD si; |
WORD di; |
WORD cflag; |
WORD _pad; |
} x; |
struct { |
BYTE al,ah; |
BYTE bl,bh; |
BYTE cl,ch; |
BYTE dl,dh; |
} h; |
} X_REGS16; |
typedef struct x_sregs16 { |
WORD es; |
WORD cs; |
WORD ss; |
WORD ds; |
} X_SREGS16; |
typedef struct { |
/* The GDT linear address inheritable from X */ |
DWORD _GDT_base; |
/* These are used for BIOS calling */ |
X_REGS16 _ir; |
X_REGS16 _or; |
X_SREGS16 _sr; |
DWORD _irqno; |
/* This is the X version */ |
DWORD _ver; |
} X_CALLBIOS; |
X_CALLBIOS * x_bios_address(void); |
void X_meminfo(LIN_ADDR *b1,DWORD *s1,LIN_ADDR *b2,DWORD *s2); |
void X_callBIOS(int service,X_REGS16 *in,X_REGS16 *out,X_SREGS16 *s); |
void vm86_init(); |
TSS *vm86_get_tss(void); |
int vm86_callBIOS(int service,X_REGS16 *in,X_REGS16 *out,X_SREGS16 *s); |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/hw-data.h |
---|
0,0 → 1,233 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* As the name says... All the hardware-dependent data structures... */ |
#ifndef __LL_I386_HW_DATA_H__ |
#define __LL_I386_HW_DATA_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* DO WE NEED A SEPARATE INCL FILE FOR THIS? */ |
#if defined(__GNU__) |
#define __LL_ARCH__ "32/DJGPP C/COFF" |
#elif defined(__LINUX__) |
#define __LL_ARCH__ "32/LINUX CrossCompiled/ELF" |
#else |
#error Architecture Undefined! |
#endif |
#include <ll/i386/sel.h> |
/* Useful basic types */ |
#ifndef __BASIC_DATA__ |
#define __BASIC_DATA__ |
typedef void *LIN_ADDR; |
typedef unsigned long long QWORD; |
typedef unsigned long DWORD; |
typedef unsigned short WORD; |
typedef unsigned char BYTE; |
typedef unsigned long TIME; |
typedef unsigned long SYS_FLAGS; |
#define TRUE 1 |
#define FALSE 0 |
#define MAX_DWORD 0xFFFFFFFF |
#define MAX_WORD 0xFFFF |
#define MAX_BYTE 0xFF |
#define MAX_TIME MAX_DWORD |
#endif |
typedef short CONTEXT; |
/* Hardware based types (Self explanatory) */ |
typedef struct gate { |
WORD offset_lo; |
WORD sel; |
BYTE dword_cnt; |
BYTE access; |
WORD offset_hi; |
} GATE; |
typedef struct descriptor { |
WORD lim_lo; |
WORD base_lo; |
BYTE base_med; |
BYTE access; |
BYTE gran; |
BYTE base_hi; |
} DESCRIPTOR; |
/* A LDT/GDT entry could be a gate or a selector */ |
/* An IDT entry could be a gate only */ |
union gdt_entry { |
DESCRIPTOR d; |
GATE g; |
}; |
struct registers { |
DWORD dummy1; |
DWORD dummy2; |
DWORD egs; |
DWORD efs; |
DWORD ees; |
DWORD ess; |
DWORD eds; |
DWORD edi; |
DWORD esi; |
DWORD ebp; |
DWORD esp; |
DWORD ebx; |
DWORD edx; |
DWORD ecx; |
DWORD eax; |
DWORD eip; |
DWORD ecs; |
DWORD flags; |
}; |
#define STACK_ACCESS 0x92 /* Basic Access bytes */ |
#define DATA_ACCESS 0x92 |
#define CODE_ACCESS 0x9A |
/* At this level we just need to set up 2 gates to enter/exit PM */ |
/* The entry gate is a 386 32 bit call gate */ |
/* The exit (Back To Real Mode) gate is a 286 16 bit gate */ |
#define CALL_GATE286 0x84 /* Call & Int Gate Access bytes */ |
#define CALL_GATE386 0x8C |
#define TASK_GATE 0x85 |
#define INT_GATE286 0x86 |
#define INT_GATE386 0x8E |
#define TRAP_GATE286 0x87 |
#define TRAP_GATE386 0x8F |
/* TSS selectors */ |
#define FREE_TSS386 0x89 |
#define BUSY_TSS386 0x8B |
#define FREE_TSS286 0x81 |
#define BUSY_TSS286 0x83 |
#define GRAN_32B 0xC0 /* Granularity settings */ |
#define GRAN_32 0x40 |
#define GRAN_16 0x00 |
/* This is the TSS image for a 386 hardware task */ |
/* I added two other fields to the basic structure: */ |
/* 1) The CONTROL field which is used by system software to detect */ |
/* particular conditions; in this the first phase it is mainly used */ |
/* to mark the unused TSS & TSS which use math, altough thanks to */ |
/* the automatic FPU preemption supported in 386 this would be not */ |
/* necessary. */ |
/* 2) The ctx_FPU field used to store the FPU context if necessaary */ |
#define TSS_USED 0x8000 |
#define FPU_USED 0x4000 |
#define FPU_CONTEXT_SIZE 108 |
/* CPU flags definitions */ |
#define CPU_FLAG_TF 0x00000100 |
#define CPU_FLAG_IF 0x00000200 |
#define CPU_FLAG_IOPL 0x00003000 |
#define CPU_FLAG_NT 0x00004000 |
#define CPU_FLAG_VM 0x00020000 |
#define CPU_FLAG_AC 0x00040000 |
#define CPU_FLAG_VIF 0x00080000 |
#define CPU_FLAG_VIP 0x00100000 |
#define CPU_FLAG_ID 0x00200000 |
typedef struct tss { |
WORD back_link; |
WORD _fill0; |
DWORD esp0; |
WORD ss0; |
WORD _fill1; |
DWORD esp1; |
WORD ss1; |
WORD _fill2; |
DWORD esp2; |
WORD ss2; |
WORD _fill3; |
DWORD cr3; |
DWORD eip; |
DWORD eflags; |
DWORD eax; |
DWORD ecx; |
DWORD edx; |
DWORD ebx; |
DWORD esp; |
DWORD ebp; |
DWORD esi; |
DWORD edi; |
WORD es; |
WORD _fill5; |
WORD cs; |
WORD _fill6; |
WORD ss; |
WORD _fill7; |
WORD ds; |
WORD _fill8; |
WORD fs; |
WORD _fill9; |
WORD gs; |
WORD _fill10; |
WORD ldt; |
WORD _fill11; |
WORD trap; |
WORD io_base; |
DWORD control; |
BYTE ctx_FPU[FPU_CONTEXT_SIZE]; |
} TSS; |
/* Irq services specifications */ |
#define TIMER_IRQ 0 |
#define KEYB_IRQ 1 |
#define COM2_IRQ 3 |
#define COM1_IRQ 4 |
#define COM4_IRQ 3 |
#define COM3_IRQ 4 |
#define SB_IRQ 5 |
#define FDC_IRQ 6 |
#define SB2_IRQ 7 |
#define RTC_IRQ 8 |
#define PS2MOUSE_IRQ 12 |
#define COPROC_IRQ 13 |
#define IDE0_IRQ 14 |
#define IDE1_IRQ 15 |
typedef void (*INTERRUPT)(void); |
/* Any Kernel primitive is declared with the SYSCALL() modifier */ |
/* This is useful to add special purposes meaning to the function */ |
/* defclaration */ |
#define SYSCALL(x) x |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/int.h |
---|
0,0 → 1,64 |
/* |
* This program 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 2 of the License, or |
* (at your option) any later version. |
* |
* This program 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. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
#ifndef __LL_I386_INT__ |
#define __LL_I386_INT__ |
#include <ll/i386/linkage.h> |
#define INT(n) \ |
.globl SYMBOL_NAME(h##n) ; \ |
SYMBOL_NAME_LABEL(h##n) ; \ |
call debug_info ; \ |
pushal ; \ |
movl $##n, %eax ; \ |
jmp ll_handler |
#define INT_1(n) \ |
.globl SYMBOL_NAME(h##n) ; \ |
SYMBOL_NAME_LABEL(h##n) ; \ |
pushal ; \ |
movl $##n, %eax ; \ |
jmp ll_handler_master_pic |
#define INT_2(n) \ |
.globl SYMBOL_NAME(h##n) ; \ |
SYMBOL_NAME_LABEL(h##n) ; \ |
pushal ; \ |
movl $##n, %eax ; \ |
jmp ll_handler_slave_pic |
#define VM86(n) \ |
.globl SYMBOL_NAME(h##n) ; \ |
SYMBOL_NAME_LABEL(h##n) ; \ |
pushal ; \ |
jmp ll_handler_vm86 |
#define EXC(n) \ |
.globl SYMBOL_NAME(exc##n) ; \ |
SYMBOL_NAME_LABEL(exc##n) ; \ |
movl $##n, %eax ; \ |
jmp ll_handler2 |
#endif |
#define NONE(n) \ |
.globl SYMBOL_NAME(h##n) ; \ |
SYMBOL_NAME_LABEL(h##n) ; \ |
iret ; \ |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/apic.h |
---|
0,0 → 1,173 |
/* |
* This program 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 2 of the License, or |
* (at your option) any later version. |
* |
* This program 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. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* |
*/ |
#ifndef __APIC_H__ |
#define __APIC_H__ |
#define APIC_DEFAULT_PHYS_BASE 0xfee00000 |
#define APIC_ID 0x20 |
#define APIC_ID_MASK (0x0F<<24) |
#define GET_APIC_ID(x) (((x)>>24)&0x0F) |
#define APIC_LVR 0x30 |
#define APIC_LVR_MASK 0xFF00FF |
#define GET_APIC_VERSION(x) ((x)&0xFF) |
#define GET_APIC_MAXLVT(x) (((x)>>16)&0xFF) |
#define APIC_INTEGRATED(x) ((x)&0xF0) |
#define APIC_TASKPRI 0x80 |
#define APIC_TPRI_MASK 0xFF |
#define APIC_ARBPRI 0x90 |
#define APIC_ARBPRI_MASK 0xFF |
#define APIC_PROCPRI 0xA0 |
#define APIC_EOI 0xB0 |
#define APIC_EIO_ACK 0x0 /* Write this to the EOI register */ |
#define APIC_RRR 0xC0 |
#define APIC_LDR 0xD0 |
#define APIC_LDR_MASK (0xFF<<24) |
#define GET_APIC_LOGICAL_ID(x) (((x)>>24)&0xFF) |
#define SET_APIC_LOGICAL_ID(x) (((x)<<24)) |
#define APIC_ALL_CPUS 0xFF |
#define APIC_DFR 0xE0 |
#define APIC_DFR_CLUSTER 0x0FFFFFFFul /* Clustered */ |
#define APIC_DFR_FLAT 0xFFFFFFFFul /* Flat mode */ |
#define APIC_SPIV 0xF0 |
#define APIC_SPIV_FOCUS_DISABLED (1<<9) |
#define APIC_SPIV_APIC_ENABLED (1<<8) |
#define APIC_ISR 0x100 |
#define APIC_TMR 0x180 |
#define APIC_IRR 0x200 |
#define APIC_ESR 0x280 |
#define APIC_ESR_SEND_CS 0x00001 |
#define APIC_ESR_RECV_CS 0x00002 |
#define APIC_ESR_SEND_ACC 0x00004 |
#define APIC_ESR_RECV_ACC 0x00008 |
#define APIC_ESR_SENDILL 0x00020 |
#define APIC_ESR_RECVILL 0x00040 |
#define APIC_ESR_ILLREGA 0x00080 |
#define APIC_ICR 0x300 |
#define APIC_DEST_SELF 0x40000 |
#define APIC_DEST_ALLINC 0x80000 |
#define APIC_DEST_ALLBUT 0xC0000 |
#define APIC_ICR_RR_MASK 0x30000 |
#define APIC_ICR_RR_INVALID 0x00000 |
#define APIC_ICR_RR_INPROG 0x10000 |
#define APIC_ICR_RR_VALID 0x20000 |
#define APIC_INT_LEVELTRIG 0x08000 |
#define APIC_INT_ASSERT 0x04000 |
#define APIC_ICR_BUSY 0x01000 |
#define APIC_DEST_PHYSICAL 0x00000 |
#define APIC_DEST_LOGICAL 0x00800 |
#define APIC_DM_FIXED 0x00000 |
#define APIC_DM_LOWEST 0x00100 |
#define APIC_DM_SMI 0x00200 |
#define APIC_DM_REMRD 0x00300 |
#define APIC_DM_NMI 0x00400 |
#define APIC_DM_INIT 0x00500 |
#define APIC_DM_STARTUP 0x00600 |
#define APIC_DM_EXTINT 0x00700 |
#define APIC_VECTOR_MASK 0x000FF |
#define APIC_ICR2 0x310 |
#define GET_APIC_DEST_FIELD(x) (((x)>>24)&0xFF) |
#define SET_APIC_DEST_FIELD(x) ((x)<<24) |
#define APIC_LVTT 0x320 |
#define APIC_LVTPC 0x340 |
#define APIC_LVT0 0x350 |
#define APIC_LVT_TIMER_BASE_MASK (0x3<<18) |
#define GET_APIC_TIMER_BASE(x) (((x)>>18)&0x3) |
#define SET_APIC_TIMER_BASE(x) (((x)<<18)) |
#define APIC_TIMER_BASE_CLKIN 0x0 |
#define APIC_TIMER_BASE_TMBASE 0x1 |
#define APIC_TIMER_BASE_DIV 0x2 |
#define APIC_LVT_TIMER_PERIODIC (1<<17) |
#define APIC_LVT_MASKED (1<<16) |
#define APIC_LVT_LEVEL_TRIGGER (1<<15) |
#define APIC_LVT_REMOTE_IRR (1<<14) |
#define APIC_INPUT_POLARITY (1<<13) |
#define APIC_SEND_PENDING (1<<12) |
#define GET_APIC_DELIVERY_MODE(x) (((x)>>8)&0x7) |
#define SET_APIC_DELIVERY_MODE(x,y) (((x)&~0x700)|((y)<<8)) |
#define APIC_MODE_FIXED 0x0 |
#define APIC_MODE_NMI 0x4 |
#define APIC_MODE_EXINT 0x7 |
#define APIC_LVT1 0x360 |
#define APIC_LVTERR 0x370 |
#define APIC_TMICT 0x380 |
#define APIC_TMCCT 0x390 |
#define APIC_TDCR 0x3E0 |
#define APIC_TDR_DIV_TMBASE (1<<2) |
#define APIC_TDR_DIV_1 0xB |
#define APIC_TDR_DIV_2 0x0 |
#define APIC_TDR_DIV_4 0x1 |
#define APIC_TDR_DIV_8 0x2 |
#define APIC_TDR_DIV_16 0x3 |
#define APIC_TDR_DIV_32 0x8 |
#define APIC_TDR_DIV_64 0x9 |
#define APIC_TDR_DIV_128 0xA |
#define APIC_BASE APIC_DEFAULT_PHYS_BASE |
#define APIC_BASE_MSR 0x1B |
/* |
* Basic functions accessing APICs. |
*/ |
static __inline__ void apic_write(unsigned long reg, unsigned long v) |
{ |
*((volatile unsigned long *)(APIC_BASE+reg)) = v; |
} |
static __inline__ unsigned long apic_read(unsigned long reg) |
{ |
return *((volatile unsigned long *)(APIC_BASE+reg)); |
} |
static __inline__ void apic_wait_icr_idle(void) |
{ |
do { } while ( apic_read( APIC_ICR ) & APIC_ICR_BUSY ); |
} |
#define apic_read_around(x) |
#define apic_write_around(x,y) apic_write((x),(y)) |
static __inline__ void set_APIC_timer(unsigned int clocks) |
{ |
extern unsigned int apic_set_limit; |
if (clocks < apic_set_limit) clocks = apic_set_limit; |
apic_write_around(APIC_TMICT, clocks); |
} |
static __inline__ void ack_APIC_irq(void) |
{ |
/* |
* ack_APIC_irq() actually gets compiled as a single instruction: |
* - a single rmw on Pentium/82489DX |
* - a single write on P6+ cores (CONFIG_X86_GOOD_APIC) |
* ... yummie. |
*/ |
/* Docs say use 0 for future compatibility */ |
apic_write_around(APIC_EOI, 0); |
} |
extern void enable_APIC_timer(void); |
extern void disable_APIC_timer (void); |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/mem.h |
---|
0,0 → 1,355 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Memory manipulation functions... |
Some of them are derived from Linux */ |
#ifndef __LL_I386_MEM_H__ |
#define __LL_I386_MEM_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* Various string manipulation functions */ |
/* Assembler low level routines */ |
/* File: Mem.S */ |
#ifndef NULL |
#define NULL 0L |
#endif |
#include <ll/sys/types.h> |
#include <ll/i386/hw-data.h> |
/* |
#ifndef __HW_DEP_H__ |
#include "hw_dep.h" |
#endif |
*/ |
extern inline void * __memcpy(void * to, const void * from, size_t n) |
{ |
int d0, d1, d2; |
__asm__ __volatile__( |
"cld\n\t" |
"rep ; movsl\n\t" |
"testb $2,%b4\n\t" |
"je 1f\n\t" |
"movsw\n" |
"1:\ttestb $1,%b4\n\t" |
"je 2f\n\t" |
"movsb\n" |
"2:" |
: "=&c" (d0), "=&D" (d1), "=&S" (d2) |
:"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from) |
: "memory"); |
return (to); |
} |
/* |
* This looks horribly ugly, but the compiler can optimize it totally, |
* as the count is constant. |
*/ |
extern inline void * __constant_memcpy(void * to, const void * from, size_t n) |
{ |
switch (n) { |
case 0: |
return to; |
case 1: |
*(unsigned char *)to = *(const unsigned char *)from; |
return to; |
case 2: |
*(unsigned short *)to = *(const unsigned short *)from; |
return to; |
case 3: |
*(unsigned short *)to = *(const unsigned short *)from; |
*(2+(unsigned char *)to) = *(2+(const unsigned char *)from); |
return to; |
case 4: |
*(unsigned long *)to = *(const unsigned long *)from; |
return to; |
case 6: /* for Ethernet addresses */ |
*(unsigned long *)to = *(const unsigned long *)from; |
*(2+(unsigned short *)to) = *(2+(const unsigned short *)from); |
return to; |
case 8: |
*(unsigned long *)to = *(const unsigned long *)from; |
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from); |
return to; |
case 12: |
*(unsigned long *)to = *(const unsigned long *)from; |
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from); |
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from); |
return to; |
case 16: |
*(unsigned long *)to = *(const unsigned long *)from; |
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from); |
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from); |
*(3+(unsigned long *)to) = *(3+(const unsigned long *)from); |
return to; |
case 20: |
*(unsigned long *)to = *(const unsigned long *)from; |
*(1+(unsigned long *)to) = *(1+(const unsigned long *)from); |
*(2+(unsigned long *)to) = *(2+(const unsigned long *)from); |
*(3+(unsigned long *)to) = *(3+(const unsigned long *)from); |
*(4+(unsigned long *)to) = *(4+(const unsigned long *)from); |
return to; |
} |
#define COMMON(x) \ |
__asm__ __volatile__( \ |
"cld\n\t" \ |
"rep ; movsl" \ |
x \ |
: "=&c" (d0), "=&D" (d1), "=&S" (d2) \ |
: "0" (n/4),"1" ((long) to),"2" ((long) from) \ |
: "memory"); |
{ |
int d0, d1, d2; |
switch (n % 4) { |
case 0: COMMON(""); return to; |
case 1: COMMON("\n\tmovsb"); return to; |
case 2: COMMON("\n\tmovsw"); return to; |
default: COMMON("\n\tmovsw\n\tmovsb"); return to; |
} |
} |
#undef COMMON |
} |
#define __HAVE_ARCH_MEMCPY |
#define memcpy(t, f, n) \ |
(__builtin_constant_p(n) ? \ |
__constant_memcpy((t),(f),(n)) : \ |
__memcpy((t),(f),(n))) |
extern inline void *lmemcpy(LIN_ADDR t, LIN_ADDR f, size_t n) |
{ |
void *p1; |
void *p2; |
p1 = (void *)(t); |
p2 = (void *)(f); |
return memcpy(p1, p2, n); |
} |
#define __HAVE_ARCH_MEMMOVE |
extern inline void * memmove(void * dest,const void * src, size_t n) |
{ |
int d0, d1, d2; |
if (dest<src) |
__asm__ __volatile__( |
"cld\n\t" |
"rep\n\t" |
"movsb" |
: "=&c" (d0), "=&S" (d1), "=&D" (d2) |
:"0" (n),"1" (src),"2" (dest) |
: "memory"); |
else |
__asm__ __volatile__( |
"std\n\t" |
"rep\n\t" |
"movsb\n\t" |
"cld" |
: "=&c" (d0), "=&S" (d1), "=&D" (d2) |
:"0" (n), |
"1" (n-1+(const char *)src), |
"2" (n-1+(char *)dest) |
:"memory"); |
return dest; |
} |
#define memcmp __builtin_memcmp |
#define __HAVE_ARCH_MEMCHR |
extern inline void * memchr(const void * cs,int c,size_t count) |
{ |
int d0; |
register void * __res; |
if (!count) |
return NULL; |
__asm__ __volatile__( |
"cld\n\t" |
"repne\n\t" |
"scasb\n\t" |
"je 1f\n\t" |
"movl $1,%0\n" |
"1:\tdecl %0" |
:"=D" (__res), "=&c" (d0) : "a" (c),"0" (cs),"1" (count)); |
return __res; |
} |
extern inline void * __memset_generic(void * s, char c,size_t count) |
{ |
int d0, d1; |
__asm__ __volatile__( |
"cld\n\t" |
"rep\n\t" |
"stosb" |
: "=&c" (d0), "=&D" (d1) |
:"a" (c),"1" (s),"0" (count) |
:"memory"); |
return s; |
} |
/* we might want to write optimized versions of these later */ |
#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count)) |
/* |
* memset(x,0,y) is a reasonably common thing to do, so we want to fill |
* things 32 bits at a time even when we don't know the size of the |
* area at compile-time.. |
*/ |
extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count) |
{ |
int d0, d1; |
__asm__ __volatile__( |
"cld\n\t" |
"rep ; stosl\n\t" |
"testb $2,%b3\n\t" |
"je 1f\n\t" |
"stosw\n" |
"1:\ttestb $1,%b3\n\t" |
"je 2f\n\t" |
"stosb\n" |
"2:" |
: "=&c" (d0), "=&D" (d1) |
:"a" (c), "q" (count), "0" (count/4), "1" ((long) s) |
:"memory"); |
return (s); |
} |
/* |
* This looks horribly ugly, but the compiler can optimize it totally, |
* as we by now know that both pattern and count is constant.. |
*/ |
extern inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count) |
{ |
switch (count) { |
case 0: |
return s; |
case 1: |
*(unsigned char *)s = pattern; |
return s; |
case 2: |
*(unsigned short *)s = pattern; |
return s; |
case 3: |
*(unsigned short *)s = pattern; |
*(2+(unsigned char *)s) = pattern; |
return s; |
case 4: |
*(unsigned long *)s = pattern; |
return s; |
} |
#define COMMON(x) \ |
__asm__ __volatile__("cld\n\t" \ |
"rep ; stosl" \ |
x \ |
: "=&c" (d0), "=&D" (d1) \ |
: "a" (pattern),"0" (count/4),"1" ((long) s) \ |
: "memory") |
{ |
int d0, d1; |
switch (count % 4) { |
case 0: COMMON(""); return s; |
case 1: COMMON("\n\tstosb"); return s; |
case 2: COMMON("\n\tstosw"); return s; |
default: COMMON("\n\tstosw\n\tstosb"); return s; |
} |
} |
#undef COMMON |
} |
#define __constant_c_x_memset(s, c, count) \ |
(__builtin_constant_p(count) ? \ |
__constant_c_and_count_memset((s),(c),(count)) : \ |
__constant_c_memset((s),(c),(count))) |
#define __memset(s, c, count) \ |
(__builtin_constant_p(count) ? \ |
__constant_count_memset((s),(c),(count)) : \ |
__memset_generic((s),(c),(count))) |
#define __HAVE_ARCH_MEMSET |
#define memset(s, c, count) \ |
(__builtin_constant_p(c) ? \ |
__constant_c_x_memset((s),(0x01010101UL*(unsigned char)c),(count)) : \ |
__memset((s),(c),(count))) |
/* |
* find the first occurrence of byte 'c', or 1 past the area if none |
*/ |
#define __HAVE_ARCH_MEMSCAN |
extern inline void * memscan(void * addr, int c, size_t size) |
{ |
if (!size) |
return addr; |
__asm__("cld\n\t" |
"repnz; scasb\n\t" |
"jnz 1f\n\t" |
"dec %%edi\n\t" |
"1:\n\t" |
: "=D" (addr), "=c" (size) |
: "0" (addr), "1" (size), "a" (c)); |
return addr; |
} |
void fmemcpy(unsigned short ds,unsigned long dof,unsigned short ss,unsigned long sof,unsigned n); |
#if 0 |
extern inline void fmemcpy(unsigned short ds,unsigned long dof,unsigned short ss,unsigned long sof,unsigned n) |
{ |
/* Build the standard stack frame */ |
__asm__ __volatile__( |
/* Get parms into register */ |
movl 8(%ebp),%eax |
movw %ax,%es |
movl 12(%ebp),%edi |
movl 16(%ebp),%eax |
movw %ax,%ds |
movl 20(%ebp),%esi |
movl 24(%ebp),%ecx |
cld |
rep |
"movsb" |
"2:" |
: "=&c" (d0), "=&D" (d1), "=&S" (d2) |
:"0" (n), "q" (n),"1" ((long) to),"2" ((long) from) |
: "memory"); |
); |
popw %es |
popw %ds |
popl %edi |
popl %esi |
leave |
ret |
#endif |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/hw-arch.h |
---|
0,0 → 1,103 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Code & data fot CPU identification */ |
#ifndef __LL_I386_HW_ARCH_H__ |
#define __LL_I386_HW_ARCH_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
/* The following structure is filled up by the ll_init() and can be */ |
/* read by the kernel modules to know about the architecture */ |
/* Each time a new hardware CPU is added to the ll layer, you have to */ |
/* define a new XXX_ARCH structure, whose first field is a char *arch */ |
/* This is used to identify the architecture, then subsequent field */ |
/* can be decoded!! */ |
/* WARNING: I tried to use bitfields, but this caused am INTO error?!? */ |
/* only when using GNU-C!! So i preferred to use standard DWORD flags */ |
/* Capabilities */ |
#define LL_X86_HAS_INVLPG 0x01 |
#define LL_X86_HAS_CPUID 0x02 |
#define LL_X86_HAS_FPU 0x04 |
#define LL_X86_INTERNAL_FPU 0x08 |
#define LL_X86_HAS_TSTAMP 0x10 |
/* Bugs */ |
#define LL_X86_FDIV_BUG 0x01 |
#define LL_X86_F00F_BUG 0x02 |
typedef struct { |
char *arch; |
int cpu; /* 0,1,2,3,4,5,6 -> |
8086/8,80186,80286,80386,80486,P5,PII o Overdrive */ |
int fpu; /* 0,1,2,3 -> None,8087,80287,80387 */ |
char *model; /* Dx, Dx2, ... */ |
char vendor[12]; /* Intel, Cyrix, AMD or unknown */ |
DWORD capabilities; |
DWORD bugs; |
/* BUGs!! Warning: Currently, no workaround is available! |
*/ |
int f00f_bug; |
int fdiv_bug; |
} X86_ARCH; |
struct ll_cpuInfo { |
DWORD X86_cpu; |
DWORD X86_cpuIdFlag; |
DWORD X86_vendor_1; |
DWORD X86_vendor_2; |
DWORD X86_vendor_3; |
DWORD X86_signature; |
DWORD X86_IntelFeature_1; |
DWORD X86_IntelFeature_2; |
DWORD X86_StandardFeature; |
}; |
typedef struct { |
char *arch; |
/* Tonino, fill up this stuff! */ |
} AXP_ARCH; |
typedef union { |
char *arch; |
X86_ARCH x86; |
AXP_ARCH axp; |
} LL_ARCH; |
void X86_get_CPU(struct ll_cpuInfo *p); |
void X86_get_FPU(void); |
int X86_is386(void); |
int X86_isCyrix(void); |
int X86_hasCPUID(void); |
void X86_enable_cyrix_cpuid(void); |
extern LL_ARCH ll_arch; |
END_DEF |
#endif /* __LL_I386_HW_ARCH_H__ */ |
/shark/trunk/arch/x86/include/arch/ll/i386/advtimer.h |
---|
0,0 → 1,235 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Advanced Timer |
* Date: 8.4.2003 |
* Author: Giacomo Guidi <giacomo@gandalf.sssup.it> |
* |
*/ |
#ifndef __ADVTIMER_H__ |
#define __ADVTIMER_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/sys/ll/time.h> |
/* TSC */ |
#define rdtsc(low,high) \ |
__asm__ __volatile__("xorl %%eax,%%eax\n\t" \ |
"cpuid\n\t" \ |
"rdtsc\n\t" \ |
: "=a" (low), "=d" (high) \ |
:: "ebx", "ecx") |
#define rdtscll(val) \ |
__asm__ __volatile__("xorl %%eax,%%eax\n\t" \ |
"cpuid\n\t" \ |
"rdtsc\n\t" \ |
: "=A" (val) \ |
:: "ebx","ecx") |
#ifdef __O1000__ |
#define ll_read_timespec ll_read_timespec_1000 |
#else |
#ifdef __02000__ |
#define ll_read_timespec ll_read_timespec_2000 |
#else |
#ifdef __O4000__ |
#define ll_read_timespec ll_read_timespec_4000 |
#else |
#define ll_read_timespec ll_read_timespec_8000 |
#endif |
#endif |
#endif |
//Low level time read function: Optimized for CPU < 1 GHz |
extern __inline__ void ll_read_timespec_1000(struct timespec *tspec) |
{ |
extern unsigned int clk_opt_1,clk_opt_2; |
extern unsigned long long *ptr_init_tsc; |
extern struct timespec init_time; |
if (clk_opt_1 == 0) { |
NULL_TIMESPEC(tspec); |
return; |
} |
__asm__("rdtsc\n\t" |
"subl (%%edi),%%eax\n\t" |
"sbbl 4(%%edi),%%edx\n\t" |
"divl %%ebx\n\t" |
"movl %%eax,%%ebx\n\t" |
"xorl %%eax,%%eax\n\t" |
"divl %%ecx\n\t" |
: "=a" (tspec->tv_nsec), "=b" (tspec->tv_sec) |
: "D" (ptr_init_tsc) , "b" (clk_opt_1), "c" (clk_opt_2) |
: "edx" ); |
if (init_time.tv_sec != 0 || init_time.tv_nsec != 0) { |
__asm__("divl %%ecx\n\t" |
"addl %%ebx,%%eax\n\t" |
:"=a" (tspec->tv_sec), "=d" (tspec->tv_nsec) |
:"a" (init_time.tv_nsec+tspec->tv_nsec), "b" (tspec->tv_sec+init_time.tv_sec), "c" (1000000000), "d" (0)); |
}; |
} |
//Low level time read function: Optimized for CPU < 2 GHz |
extern __inline__ void ll_read_timespec_2000(struct timespec *tspec) |
{ |
extern unsigned int clk_opt_1,clk_opt_3; |
extern unsigned long long *ptr_init_tsc; |
extern struct timespec init_time; |
if (clk_opt_1 == 0) { |
NULL_TIMESPEC(tspec); |
return; |
} |
__asm__("rdtsc\n\t" |
"subl (%%edi),%%eax\n\t" |
"sbbl 4(%%edi),%%edx\n\t" |
"divl %%ebx\n\t" |
"movl %%eax,%%ebx\n\t" |
"xorl %%eax,%%eax\n\t" |
"shrdl $1,%%edx,%%eax\n\t" |
"shrl %%edx\n\t" |
"divl %%ecx\n\t" |
: "=a" (tspec->tv_nsec), "=b" (tspec->tv_sec) |
: "D" (ptr_init_tsc) , "b" (clk_opt_1), "c" (clk_opt_3) |
: "edx" ); |
if (init_time.tv_sec != 0 || init_time.tv_nsec != 0) { |
__asm__("divl %%ecx\n\t" |
"addl %%ebx,%%eax\n\t" |
:"=a" (tspec->tv_sec), "=d" (tspec->tv_nsec) |
:"a" (init_time.tv_nsec+tspec->tv_nsec), "b" (tspec->tv_sec+init_time.tv_sec), "c" (1000000000), "d" (0)); |
}; |
} |
//Low level time read function: Optimized for CPU < 4 GHz |
extern __inline__ void ll_read_timespec_4000(struct timespec *tspec) |
{ |
extern unsigned int clk_opt_1,clk_opt_4; |
extern unsigned long long *ptr_init_tsc; |
extern struct timespec init_time; |
if (clk_opt_1 == 0) { |
NULL_TIMESPEC(tspec); |
return; |
} |
__asm__("rdtsc\n\t" |
"subl (%%edi),%%eax\n\t" |
"sbbl 4(%%edi),%%edx\n\t" |
"divl %%ebx\n\t" |
"movl %%eax,%%ebx\n\t" |
"xorl %%eax,%%eax\n\t" |
"shrdl $2,%%edx,%%eax\n\t" |
"shrl $2,%%edx\n\t" |
"divl %%ecx\n\t" |
: "=a" (tspec->tv_nsec), "=b" (tspec->tv_sec) |
: "D" (ptr_init_tsc) , "b" (clk_opt_1), "c" (clk_opt_4) |
: "edx" ); |
if (init_time.tv_sec != 0 || init_time.tv_nsec != 0) { |
__asm__("divl %%ecx\n\t" |
"addl %%ebx,%%eax\n\t" |
:"=a" (tspec->tv_sec), "=d" (tspec->tv_nsec) |
:"a" (init_time.tv_nsec+tspec->tv_nsec), "b" (tspec->tv_sec+init_time.tv_sec), "c" (1000000000), "d" (0)); |
}; |
} |
//Low level time read function |
extern __inline__ void ll_read_timespec_8000(struct timespec *tspec) |
{ |
extern unsigned int clk_opt_0,clk_opt_5; |
extern unsigned long long *ptr_init_tsc; |
extern struct timespec init_time; |
if (clk_opt_0 == 0) { |
NULL_TIMESPEC(tspec); |
return; |
} |
__asm__("rdtsc\n\t" |
"subl (%%edi),%%eax\n\t" |
"sbbl 4(%%edi),%%edx\n\t" |
"shrdl $1,%%edx,%%eax\n\t" |
"shrl %%edx\n\t" |
"divl %%ebx\n\t" |
"movl %%eax,%%ebx\n\t" |
"xorl %%eax,%%eax\n\t" |
"shrdl $2,%%edx,%%eax\n\t" |
"shrl $2,%%edx\n\t" |
"divl %%ecx\n\t" |
: "=b" (tspec->tv_sec), "=a" (tspec->tv_nsec) |
: "D" (ptr_init_tsc), "b" (clk_opt_0), "c" (clk_opt_5) |
: "edx"); |
if (init_time.tv_sec != 0 || init_time.tv_nsec != 0) { |
__asm__("divl %%ecx\n\t" |
"addl %%ebx,%%eax\n\t" |
:"=a" (tspec->tv_sec), "=d" (tspec->tv_nsec) |
:"a" (init_time.tv_nsec+tspec->tv_nsec), "b" (tspec->tv_sec+init_time.tv_sec), "c" (1000000000), "d" (0)); |
}; |
} |
#define rdmsr(msr,val1,val2) \ |
__asm__ __volatile__("rdmsr" \ |
: "=a" (val1), "=d" (val2) \ |
: "c" (msr)) |
#define wrmsr(msr,val1,val2) \ |
__asm__ __volatile__("wrmsr" \ |
: /* no outputs */ \ |
: "c" (msr), "a" (val1), "d" (val2)) |
/* RTC */ |
#define RTC_PORT(x) (0x70 + (x)) |
#define CMOS_READ(addr,val) \ |
{ \ |
outp(RTC_PORT(0),(addr)); \ |
val = inp(RTC_PORT(1)); \ |
} |
#define CMOS_WRITE(addr,val) \ |
{ \ |
outp(RTC_PORT(0),(addr)); \ |
outp(RTC_PORT(1),(val)); \ |
} |
#define RTC_IRQ 8 |
void ll_init_advtimer(void); |
void ll_restore_adv(void); |
void ll_scale_advtimer(unsigned int old_f, unsigned int new_f); |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/64bit.h |
---|
0,0 → 1,39 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* 64 bit arithmetic */ |
#ifndef __LL_I386_64BIT__ |
#define __LL_I386_64BIT__ |
#define mul32div32to32(a,b,c,res) \ |
__asm__ __volatile__("mull %%ebx\n\t" \ |
"divl %%ecx\n\t" \ |
: "=a" ((res)) \ |
: "a" ((a)), "b" ((b)), "c" ((c)), "d" (0)) |
#define smul32div32to32(a,b,c,res) \ |
__asm__ __volatile__("imull %%ebx\n\t" \ |
"idivl %%ecx\n\t" \ |
: "=a" ((res)) \ |
: "a" ((a)), "b" ((b)), "c" ((c)), "d" (0)) |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/hw-instr.h |
---|
0,0 → 1,235 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* As the name says... All the hardware-dependent instructions |
there is a 1->1 corrispondence with ASM instructions */ |
#ifndef __LL_I386_HW_INSTR_H__ |
#define __LL_I386_HW_INSTR_H__ |
#include <ll/i386/defs.h> |
#define INLINE_OP __inline__ static |
#include <ll/i386/hw-data.h> |
/* Low Level I/O funcs are in a separate file (by Luca) */ |
#include <ll/i386/hw-io.h> |
BEGIN_DEF |
INLINE_OP WORD get_CS(void) |
{WORD r; __asm__ __volatile__ ("movw %%cs,%0" : "=q" (r)); return(r);} |
INLINE_OP WORD get_DS(void) |
{WORD r; __asm__ __volatile__ ("movw %%ds,%0" : "=q" (r)); return(r);} |
INLINE_OP WORD get_FS(void) |
{WORD r; __asm__ __volatile__ ("movw %%fs,%0" : "=q" (r)); return(r);} |
/*INLINE_OP DWORD get_SP(void) |
{DWORD r; __asm__ __volatile__ ("movw %%esp,%0" : "=q" (r)); return(r);}*/ |
INLINE_OP DWORD get_SP(void) |
{ |
DWORD rv; |
__asm__ __volatile__ ("movl %%esp, %0" |
: "=a" (rv)); |
return(rv); |
} |
INLINE_OP DWORD get_BP(void) |
{ |
DWORD rv; |
__asm__ __volatile__ ("movl %%ebp, %0" |
: "=a" (rv)); |
return(rv); |
} |
INLINE_OP WORD get_TR(void) |
{WORD r; __asm__ __volatile__ ("strw %0" : "=q" (r)); return(r); } |
INLINE_OP void set_TR(WORD n) |
{__asm__ __volatile__("ltr %%ax": /* no output */ :"a" (n)); } |
INLINE_OP void set_LDTR(WORD addr) |
{ __asm__ __volatile__("lldt %%ax": /* no output */ :"a" (addr)); } |
/* Clear Task Switched Flag! Used for FPU preemtion */ |
INLINE_OP void clts(void) |
{__asm__ __volatile__ ("clts"); } |
/* Halt the processor! */ |
INLINE_OP void hlt(void) |
{__asm__ __volatile__ ("hlt"); } |
/* These functions are used to mask/unmask interrupts */ |
INLINE_OP void sti(void) {__asm__ __volatile__ ("sti"); } |
INLINE_OP void cli(void) {__asm__ __volatile__ ("cli"); } |
INLINE_OP SYS_FLAGS ll_fsave(void) |
{ |
SYS_FLAGS result; |
__asm__ __volatile__ ("pushfl"); |
__asm__ __volatile__ ("cli"); |
__asm__ __volatile__ ("popl %eax"); |
__asm__ __volatile__ ("movl %%eax,%0" |
: "=r" (result) |
: |
: "eax" ); |
return(result); |
} |
INLINE_OP void ll_frestore(SYS_FLAGS f) |
{ |
__asm__ __volatile__ ("mov %0,%%eax" |
: |
: "r" (f) |
: "eax"); |
__asm__ __volatile__ ("pushl %eax"); |
__asm__ __volatile__ ("popfl"); |
} |
/* |
FPU context switch management functions! |
FPU management exported at kernel layer to allow the use |
of floating point in kernel primitives; this turns to be |
useful for bandwidth reservation or guarantee! |
*/ |
/* FPU lazy state save handling.. */ |
INLINE_OP void save_fpu(TSS *t) |
{ |
__asm__ __volatile__("fnsave %0\n\tfwait":"=m" (t->ctx_FPU)); |
} |
INLINE_OP void restore_fpu(TSS *t) |
{ |
#if 1 |
__asm__ __volatile__("frstor %0": :"p" (t->ctx_FPU)); |
#else |
__asm__ __volatile__("frstor %0\n\tfwait": :"p" (t->ctx_FPU)); |
#endif |
/* __asm__ __volatile__("frstor _LL_FPU_savearea"); */ |
} |
INLINE_OP void smartsave_fpu(TSS *t) |
{ |
if (t->control & FPU_USED) save_fpu(t); |
} |
INLINE_OP void reset_fpu(void) { __asm__ __volatile__ ("fninit"); } |
#if 0 |
/* OK, now everything is clear... We test the NE bit to see if the |
* CPU is using the internal mechanism for reporting FPU errors or not... |
*/ |
INLINE_OP int check_fpu(void) |
{ |
int result; |
__asm__ __volatile__ ("movl %cr0,%eax"); |
__asm__ __volatile__ ("movl %eax,%edi"); |
__asm__ __volatile__ ("andl $0x0FFFFFFEF,%eax"); |
__asm__ __volatile__ ("movl %eax,%cr0"); |
__asm__ __volatile__ ("movl %cr0,%eax"); |
__asm__ __volatile__ ("xchgl %edi,%eax"); |
__asm__ __volatile__ ("movl %eax,%cr0"); |
#if 0 |
__asm__ __volatile__ ("xorl %eax,%eax"); |
__asm__ __volatile__ ("movb %bl,%al"); |
#else |
__asm__ __volatile__ ("movl %edi,%eax"); |
__asm__ __volatile__ ("andl $0x10,%eax"); |
#endif |
__asm__ __volatile__ ("shrb $4,%al"); |
__asm__ __volatile__ ("movl %%eax,%0" |
: "=r" (result) |
: |
: "eax" ); |
return(result); |
} |
#endif |
INLINE_OP void init_fpu(void) |
{ |
__asm__ __volatile__ ("movl %cr0,%eax"); |
__asm__ __volatile__ ("orl $34,%eax"); |
__asm__ __volatile__ ("movl %eax,%cr0"); |
__asm__ __volatile__ ("fninit"); |
} |
extern BYTE LL_FPU_savearea[]; |
extern __inline__ void LL_FPU_save(void) |
{ |
#ifdef __LINUX__ |
__asm__ __volatile__ ("fsave LL_FPU_savearea"); |
#else |
__asm__ __volatile__ ("fsave _LL_FPU_savearea"); |
#endif |
} |
extern __inline__ void LL_FPU_restore(void) |
{ |
#ifdef __LINUX__ |
__asm__ __volatile__ ("frstor LL_FPU_savearea"); |
#else |
__asm__ __volatile__ ("frstor _LL_FPU_savearea"); |
#endif |
} |
INLINE_OP void lmempokeb(LIN_ADDR a, BYTE v) |
{ |
*((BYTE *)a) = v; |
} |
INLINE_OP void lmempokew(LIN_ADDR a, WORD v) |
{ |
*((WORD *)a) = v; |
} |
INLINE_OP void lmempoked(LIN_ADDR a, DWORD v) |
{ |
*((DWORD *)a) = v; |
} |
INLINE_OP BYTE lmempeekb(LIN_ADDR a) |
{ |
return *((BYTE *)a); |
} |
INLINE_OP WORD lmempeekw(LIN_ADDR a) |
{ |
return *((WORD *)a); |
} |
INLINE_OP DWORD lmempeekd(LIN_ADDR a) |
{ |
return *((DWORD *)a); |
} |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/pit.h |
---|
0,0 → 1,188 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The Programmable Interrupt Timer management code */ |
#ifndef __PIT_H__ |
#define __PIT_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#define MIN_INT 100 |
#define TMR_CTRL 0x43 /* PIT Control port*/ |
#define TMR_CNT0 0x40 /* Counter 0 port */ |
#define TMR_CNT1 0x41 /* Counter 1 port */ |
#define TMR_CNT2 0x42 /* Counter 2 port */ |
#define TMR_SC0 0x00 /* Select Channel 0 */ |
#define TMR_SC1 0x40 /* Select Channel 1 */ |
#define TMR_SC2 0x80 /* Select Channel 2 */ |
#define TMR_LSB 0x10 /* R/W Least Significative Byte */ |
#define TMR_MSB 0x20 /* R/W Most Significative Byte */ |
#define TMR_BOTH 0x30 /* R/W Both Bytes */ |
#define TMR_LATCH 0x00 /* Latch Command */ |
#define TMR_READ 0xF0 /* Read Command */ |
#define TMR_CNT 0x20 /* Read Counter */ |
#define TMR_STAT 0x10 /* Read Status */ |
#define TMR_CH2 0x08 /* Read Channel 2 Counter/Status */ |
#define TMR_CH1 0x04 /* Read Channel 1 Counter/Status */ |
#define TMR_CH0 0x02 /* Read Channel 0 Counter/Status */ |
#define TMR_MD0 0x00 /* Mode 0 */ |
#define TMR_MD1 0x02 /* Mode 1 */ |
#define TMR_MD2 0x04 /* Mode 2 */ |
#define TMR_MD3 0x06 /* Mode 3 */ |
#define TMR_MD4 0x08 /* Mode 4 */ |
#define TMR_MD5 0x0A /* Mode 5 */ |
INLINE_OP int pit_init(BYTE channel, BYTE mode, WORD tconst) |
{ |
BYTE v, ch; |
WORD cnt; |
switch (channel) { |
case 0: |
cnt = TMR_CNT0; |
ch = TMR_SC0; |
break; |
case 1: |
cnt = TMR_CNT1; |
ch = TMR_SC1; |
break; |
case 2: |
cnt = TMR_CNT2; |
ch = TMR_SC2; |
break; |
default: |
return -1; |
} |
/* VM_out(TMR_CTRL, 0x34); */ |
outp(TMR_CTRL, ch | TMR_BOTH | mode); |
/* Load Time_const with 2 access to CTR */ |
v = (BYTE)(tconst); |
outp(cnt, v); |
v = (BYTE)(tconst >> 8); |
outp(cnt, v); |
return 1; |
} |
INLINE_OP int pit_setconstant(BYTE channel, DWORD c) |
{ |
BYTE v; |
WORD cnt; |
WORD tconst; |
if (c > 0xF000) { |
tconst = 0xF000; |
} else { |
if (c < MIN_INT) { |
tconst = MIN_INT; |
} else { |
tconst = c; |
} |
} |
switch (channel) { |
case 0: |
cnt = TMR_CNT0; |
break; |
case 1: |
cnt = TMR_CNT1; |
break; |
case 2: |
cnt = TMR_CNT2; |
break; |
default: |
return -1; |
} |
/* Load Time_const with 2 access to CTR */ |
v = (BYTE)(tconst); |
outp(cnt, v); |
v = (BYTE)(tconst >> 8); |
outp(cnt, v); |
return 1; |
} |
INLINE_OP WORD pit_read(BYTE channel) |
{ |
WORD result; |
WORD cnt; |
BYTE ch; |
BYTE str_msb, str_lsb; |
switch (channel) { |
case 0: |
cnt = TMR_CNT0; |
ch = TMR_CH0; |
break; |
case 1: |
cnt = TMR_CNT1; |
ch = TMR_CH1; |
break; |
case 2: |
cnt = TMR_CNT2; |
ch = TMR_CH2; |
break; |
default: |
return 0; |
} |
/* Read Back Command on counter 0 */ |
#if 0 |
outp(TMR_CTRL, ch | TMR_LATCH | TMR_BOTH); |
#else |
outp(TMR_CTRL, TMR_READ - TMR_CNT + ch /*0xD2*/); |
#endif |
/* Read the latched value from STR */ |
str_lsb = inp(cnt); |
str_msb = inp(cnt); |
/* Combine the byte values to obtain a word */ |
result = ((WORD)str_msb << 8) | (WORD)str_lsb; |
return result; |
} |
struct pitspec { |
long units; |
long gigas; |
}; |
#define ADDPITSPEC(n, t) ((t)->units += (n), \ |
(t)->gigas += (t)->units / 1423249, \ |
(t)->units %= 1423249) |
#define NULLPITSPEC(t) (t)->units = 0, (t)->gigas = 0 |
#define PITSPEC2USEC(t) ((((t)->units * 1000) / 1193) \ |
+ (((t)->gigas * 1000) * 1193)) |
#define CPPITSPEC(a, b) (b)->units = (a)->units, (b)->gigas = (a)->gigas |
#endif /* __PIT_H__ */ |
/shark/trunk/arch/x86/include/arch/ll/i386/pic.h |
---|
0,0 → 1,64 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The Programmable Interrupt Controller management code */ |
#ifndef __PIC_H__ |
#define __PIC_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
#define PIC1_BASE 0x040 /* Interrupt base for each PIC */ |
#define PIC2_BASE 0x070 |
void PIC_init(void); |
void PIC_end(void); |
void irq_mask(WORD irqno); |
void irq_unmask(WORD irqno); |
INLINE_OP void l1_exc_bind(int i, void (*f)(int n)) |
{ |
l1_int_bind(i, f); |
} |
INLINE_OP int l1_irq_bind(int irq, void *f) |
{ |
int i; |
if (irq < 8) { |
i = irq + PIC1_BASE; |
} else if (irq < 16) { |
i = irq + PIC2_BASE - 8; |
} else { |
return -1; |
} |
l1_int_bind(i, f); |
return 1; |
} |
END_DEF |
#endif /* __PIC_H__ */ |
/shark/trunk/arch/x86/include/arch/ll/i386/x-dosmem.h |
---|
0,0 → 1,37 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Management functions for memory in the first MegaByte */ |
#ifndef __LL_I386_X_DOSMEM_H__ |
#define __LL_I386_X_DOSMEM_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
void DOS_dump_mem(void); |
void DOS_mem_init(void); |
LIN_ADDR DOS_alloc(DWORD s); |
int DOS_free(LIN_ADDR p,DWORD s); |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/error.h |
---|
0,0 → 1,38 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The LL error dump function */ |
#ifndef __LL_I386_ERROR_H__ |
#define __LL_I386_ERROR_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/cons.h> |
int message(char *fmt,...) __attribute__((format(printf,1,2))); |
#define error(msg) \ |
message("Error! File:%s Line:%d %s", __FILE__, __LINE__, msg) |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/x-dos.h |
---|
0,0 → 1,49 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Accessing a DOS filesystem from OSLib/X */ |
#ifndef __LL_I386_X_DOS_H__ |
#define __LL_I386_X_DOS_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/x-bios.h> |
typedef struct { |
LIN_ADDR buf; |
LIN_ADDR n1; |
char n2[80]; |
BYTE mode,index; |
DWORD handle,offset; |
} DOS_FILE; |
int DOS_init(void); |
DOS_FILE *DOS_fopen(char *name, char *mode); |
void DOS_fclose(DOS_FILE *f); |
DWORD DOS_fread(void *buf,DWORD size,DWORD num,DOS_FILE *f); |
DWORD DOS_fwrite(void *buf,DWORD size,DWORD num,DOS_FILE *f); |
unsigned DOS_error(void); |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/farptr.h |
---|
0,0 → 1,246 |
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
/* Copyright (c) 1995 DJ Delorie. Permission granted to use for any |
purpose, provided this copyright remains attached and unmodified. |
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. |
ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» |
º Far Pointer Simulation Functions º |
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ |
This file attempts to make up for the lack of a "far" keyword in GCC. |
Although it doesn't provide access to far call APIs (like Windows), it |
does allow you to do far pointer data access without the overhead of |
movedata() or dosmemget/dosmemput(). |
You should *always* include this file when using these functions and |
compile with optimization enabled. They don't exist as normal functions |
in any library, and they compile down to only a few opcodes when used |
this way. They are almost as fast as native pointer operations, and |
about as fast as far pointers can get. |
If you don't use optimization, this file becomes prototypes for |
farptr.c, which generates real functions for these when not optimizing. |
When optimizing, farptr.c compiles to nothing. |
There are two types of functions here - standalone and invariant. The |
standalone functions take a selector and offset. These are used when |
you need only a few accesses, time isn't critical, or you don't know |
what's in the %fs register. The invariant ones don't take a selector, |
they only take an offset. These are used inside loops and in |
time-critical accesses where the selector doesn't change. To specify |
the selector, use the farsetsel() function. That selector is used for |
all farns*() functions until changed. You can use _fargetsel() if you |
want to temporary change the selector with _farsetsel() and restore |
it afterwards. |
The farpoke* and farpeek* take selectors. |
The farnspoke* and farnspeek* don't (note the `ns' for `no selector'). |
Warning: These routines all use the %fs register for their accesses. |
GCC normally uses only %ds and %es, and libc functions (movedata, |
dosmemget, dosmemput) use %gs. Still, you should be careful about |
assumptions concerning whether or not the value you put in %fs will be |
preserved across calls to other functions. If you guess wrong, your |
program will crash. Better safe than sorry. |
*/ |
#ifndef __dj_include_sys_farptr_h_ |
#define __dj_include_sys_farptr_h_ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#ifndef __dj_ENFORCE_ANSI_FREESTANDING |
#ifndef __STRICT_ANSI__ |
#ifndef _POSIX_SOURCE |
void _farpokeb(unsigned short, unsigned long, unsigned char); |
void _farpokew(unsigned short, unsigned long, unsigned short); |
void _farpokel(unsigned short, unsigned long, unsigned long); |
unsigned char _farpeekb(unsigned short, unsigned long); |
unsigned short _farpeekw(unsigned short, unsigned long); |
unsigned long _farpeekl(unsigned short, unsigned long); |
void _farsetsel(unsigned short); |
unsigned short _fargetsel(void); |
void _farnspokeb(unsigned long, unsigned char); |
void _farnspokew(unsigned long, unsigned short); |
void _farnspokel(unsigned long, unsigned long); |
unsigned char _farnspeekb(unsigned long); |
unsigned short _farnspeekw(unsigned long); |
unsigned long _farnspeekl(unsigned long); |
extern __inline__ void |
_farpokeb(unsigned short selector, |
unsigned long offset, |
unsigned char value) |
{ |
__asm__ __volatile__ ("movw %w0,%%fs\n" |
" .byte 0x64 \n" |
" movb %b1,%%fs:(%k2)" |
: |
: "rm" (selector), "qi" (value), "r" (offset)); |
} |
extern __inline__ void |
_farpokew(unsigned short selector, |
unsigned long offset, |
unsigned short value) |
{ |
__asm__ __volatile__ ("movw %w0,%%fs \n" |
" .byte 0x64 \n" |
" movw %w1,(%k2)" |
: |
: "rm" (selector), "ri" (value), "r" (offset)); |
} |
extern __inline__ void |
_farpokel(unsigned short selector, |
unsigned long offset, |
unsigned long value) |
{ |
__asm__ __volatile__ ("movw %w0,%%fs \n" |
" .byte 0x64 \n" |
" movl %k1,(%k2)" |
: |
: "rm" (selector), "ri" (value), "r" (offset)); |
} |
extern __inline__ unsigned char |
_farpeekb(unsigned short selector, |
unsigned long offset) |
{ |
unsigned char result; |
__asm__ __volatile__ ("movw %w1,%%fs \n" |
" .byte 0x64 \n" |
" movb (%k2),%b0" |
: "=q" (result) |
: "rm" (selector), "r" (offset)); |
return result; |
} |
extern __inline__ unsigned short |
_farpeekw(unsigned short selector, |
unsigned long offset) |
{ |
unsigned short result; |
__asm__ __volatile__ ("movw %w1, %%fs \n" |
" .byte 0x64 \n" |
" movw (%k2),%w0 \n" |
: "=r" (result) |
: "rm" (selector), "r" (offset)); |
return result; |
} |
extern __inline__ unsigned long |
_farpeekl(unsigned short selector, |
unsigned long offset) |
{ |
unsigned long result; |
__asm__ __volatile__ ("movw %w1,%%fs\n" |
" .byte 0x64\n" |
" movl (%k2),%k0" |
: "=r" (result) |
: "rm" (selector), "r" (offset)); |
return result; |
} |
extern __inline__ void |
_farsetsel(unsigned short selector) |
{ |
__asm__ __volatile__ ("movw %w0,%%fs" |
: |
: "rm" (selector)); |
} |
extern __inline__ unsigned short |
_fargetsel(void) |
{ |
unsigned short selector; |
__asm__ __volatile__ ("movw %%fs,%w0 \n" |
: "=r" (selector) |
: ); |
return selector; |
} |
extern __inline__ void |
_farnspokeb(unsigned long offset, |
unsigned char value) |
{ |
__asm__ __volatile__ (".byte 0x64\n" |
" movb %b0,(%k1)" |
: |
: "qi" (value), "r" (offset)); |
} |
extern __inline__ void |
_farnspokew(unsigned long offset, |
unsigned short value) |
{ |
__asm__ __volatile__ (".byte 0x64\n" |
" movw %w0,(%k1)" |
: |
: "ri" (value), "r" (offset)); |
} |
extern __inline__ void |
_farnspokel(unsigned long offset, |
unsigned long value) |
{ |
__asm__ __volatile__ (".byte 0x64\n" |
" movl %k0,(%k1)" |
: |
: "ri" (value), "r" (offset)); |
} |
extern __inline__ unsigned char |
_farnspeekb(unsigned long offset) |
{ |
unsigned char result; |
__asm__ __volatile__ (".byte 0x64\n" |
" movb (%k1),%b0" |
: "=q" (result) |
: "r" (offset)); |
return result; |
} |
extern __inline__ unsigned short |
_farnspeekw(unsigned long offset) |
{ |
unsigned short result; |
__asm__ __volatile__ (".byte 0x64\n" |
" movw (%k1),%w0" |
: "=r" (result) |
: "r" (offset)); |
return result; |
} |
extern __inline__ unsigned long |
_farnspeekl(unsigned long offset) |
{ |
unsigned long result; |
__asm__ __volatile__ (".byte 0x64\n" |
" movl (%k1),%k0" |
: "=r" (result) |
: "r" (offset)); |
return result; |
} |
#endif /* !_POSIX_SOURCE */ |
#endif /* !__STRICT_ANSI__ */ |
#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ |
#ifndef __dj_ENFORCE_FUNCTION_CALLS |
#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ |
#ifdef __cplusplus |
} |
#endif |
#endif /* !__dj_include_sys_farptr_h_ */ |
/shark/trunk/arch/x86/include/arch/ll/i386/cons.h |
---|
0,0 → 1,97 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Console output functions */ |
#ifndef __LL_I386_CONS_H__ |
#define __LL_I386_CONS_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* for reference only */ |
extern int cons_columns; /* number of screen columns */ |
extern int cons_rows; /* number of screen rows */ |
/* X-dependent Console Output functions */ |
/* Rememeber that console functions are NOT REENTRANT */ |
/* The console must be considered a preemtable resource */ |
/* File : Cons.C */ |
void set_visual_page(int page); |
void set_active_page(int page); |
int get_visual_page(void); |
int get_active_page(void); |
void place(int x,int y); |
void getcursorxy(int *x, int *y); |
int get_attr(void); |
void cursor(int start,int end); |
void _clear(char c,char attr,int x1,int y1,int x2,int y2); |
void clear(void); |
void _scroll(char attr,int x1,int y1,int x2,int y2); |
void scroll(void); |
void bios_save(void); |
void bios_restore(void); |
void cputc(char c); |
void cputs(char *s); |
int cprintf(char *fmt,...) __attribute__((format(printf,1,2))); |
/* These functions allow direct access to video RAM */ |
/* Hence you can use it without the explicit use of */ |
/* a resource manager */ |
/* File : Cons.C */ |
void putc_xy(int x,int y,char attr,char c); |
char getc_xy(int x,int y,char *attr,char *c); |
void puts_xy(int x,int y,char attr,char *s); |
int printf_xy(int x,int y,char attr, char *fmt,...) __attribute__((format(printf,4,5))); |
/* These are simple useful macro! */ |
#define HOME() place(0,0); |
#define CRSR_BLOB() cursor(0,15); |
#define CRSR_OFF() cursor(16,16); |
#define CRSR_STD() cursor(14,15); |
#define NL() cputc('\n'); |
/* Text mode color definitions */ |
#define BLACK 0 |
#define BLUE 1 |
#define GREEN 2 |
#define CYAN 3 |
#define RED 4 |
#define MAGENTA 5 |
#define BROWN 6 |
#define LIGHTGRAY 7 |
#define DARKGRAY 8 |
#define LIGHTBLUE 9 |
#define LIGHTGREEN 10 |
#define LIGHTCYAN 11 |
#define LIGHTRED 12 |
#define LIGHTMAGENTA 13 |
#define YELLOW 14 |
#define WHITE 15 |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/tss-ctx.h |
---|
0,0 → 1,34 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Macros for CONTEXT <-> TSS Translation */ |
#ifndef __LL_I386_TSS_CTX_H__ |
#define __LL_I386_TSS_CTX_H__ |
#define TSSMax 155 |
#define TSSMain (TSSMax-1) |
#define MAIN_SEL 0xF8 |
#define TSSBase 0x100 |
#define TSSsel2index(sel) ((sel-TSSBase)/8) |
#define TSSindex2sel(i) (TSSBase + i*8) |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/hw-func.h |
---|
0,0 → 1,82 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* As the name says... |
All the hardware-dependent functions |
IDT/GDT management |
context switch |
IRQ/Exc handling... */ |
#ifndef __LL_I386_HW_FUNC_H__ |
#define __LL_I386_HW_FUNC_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-instr.h> |
/* Low level exit functions! It will halt, reboot or |
* give back the control to X, depending on how YAMME started... |
*/ |
void __exit(int code) __attribute__((noreturn)); |
void halt(void); |
/* Functions to reboot the machine */ |
void cold_reboot(void); |
void warm_reboot(void); |
void reboot(int mode); |
/* System tables management functions */ |
void IDT_place(BYTE num,void (*handler)(void)); |
void GDT_place(WORD sel,DWORD base,DWORD lim,BYTE acc,BYTE gran); |
DWORD GDT_read(WORD sel,DWORD *lim,BYTE *acc,BYTE *gran); |
LIN_ADDR addr2linear(unsigned short sel,unsigned long offset); |
/* These 3 function realize the context switching. The context_save has */ |
/* to be the first call of a kernel primitive, and the context_change has */ |
/* to be the last call. */ |
/* The context_save disables the interrupt (a kernel primitive must be */ |
/* atomic) and return the context of the running task. */ |
/* The context_change take the context of the new task (or of the */ |
/* same task), switch to the new context and return restoring the flag */ |
/* register. */ |
/* The context_load is used when the task is going to be killed; then its */ |
/* context does not need to be saved; we only need to load the context of */ |
/* the new task; the effective implementation of this functions can vary */ |
/* greatly throughout different implementations as some of them are */ |
/* mapped to empty functions or mapped one onto another */ |
CONTEXT ll_context_save(void); |
void ll_context_change(CONTEXT c); |
void ll_context_load(CONTEXT c); |
CONTEXT ll_context_from(void); |
void ll_context_to(CONTEXT c); |
void *l1_init(void); |
void IDT_init(void); |
void l1_end(void); |
void l1_int_bind(int i, void *f); |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/mb-hdr.h |
---|
0,0 → 1,80 |
/* |
* GRUB -- GRand Unified Bootloader |
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org> |
* |
* This program 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 2 of the License, or |
* (at your option) any later version. |
* |
* This program 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. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
*/ |
/* |
* MultiBoot Header description |
* |
* |
* struct multiboot_header |
* { |
* Must be MULTIBOOT_MAGIC - see below. |
* unsigned magic; |
* |
* Feature flags - see below. |
* unsigned flags; |
* |
* |
* Checksum |
* |
* The above fields plus this one must equal 0 mod 2^32. |
* |
* unsigned checksum; |
* |
* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. |
* unsigned header_addr; |
* unsigned load_addr; |
* unsigned load_end_addr; |
* unsigned bss_end_addr; |
* unsigned entry_addr; |
* }; |
*/ |
/* |
* The entire multiboot_header must be contained |
* within the first MULTIBOOT_SEARCH bytes of the kernel image. |
* #define MULTIBOOT_SEARCH 8192 |
* #define MULTIBOOT_FOUND(addr, len) \ |
* (!((addr) & 0x3) && ((len) >= 12) && (*((int *)(addr)) == MULTIBOOT_MAGIC) \ |
* && !(*((unsigned *)(addr)) + *((unsigned *)(addr+4)) \ |
* + *((unsigned *)(addr+8))) \ |
* && (!(MULTIBOOT_AOUT_KLUDGE & *((int *)(addr+4))) || ((len) >= 32))) |
*/ |
/* Magic value identifying the multiboot_header. */ |
#define MULTIBOOT_MAGIC 0x1BADB002 |
/* |
* Features flags for 'flags'. |
* If a boot loader sees a flag in MULTIBOOT_MUSTKNOW set |
* and it doesn't understand it, it must fail. |
*/ |
#define MULTIBOOT_MUSTKNOW 0x0000FFFF |
/* currently unsupported flags... this is a kind of version number. */ |
#define MULTIBOOT_UNSUPPORTED 0x0000FFFC |
/* Align all boot modules on i386 page (4KB) boundaries. */ |
#define MULTIBOOT_PAGE_ALIGN 0x00000001 |
/* Must pass memory information to OS. */ |
#define MULTIBOOT_MEMORY_INFO 0x00000002 |
/* This flag indicates the use of the other fields in the header. */ |
#define MULTIBOOT_AOUT_KLUDGE 0x00010000 |
/shark/trunk/arch/x86/include/arch/ll/i386/linkage.h |
---|
0,0 → 1,44 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* This file derives from linux/linkage.h. It allows a transparent naming |
* between COFF and ELF executable models. We use ELF when we cross-compile |
* OSLib from Linux with Linux GCC |
*/ |
#ifdef __LINUX__ |
#define SYMBOL_NAME_STR(X) #X |
#define SYMBOL_NAME(X) X |
#ifdef __STDC__ |
#define SYMBOL_NAME_LABEL(X) X##: |
#else |
#define SYMBOL_NAME_LABEL(X) X/**/: |
#endif |
#else |
#define SYMBOL_NAME_STR(X) "_"#X |
#ifdef __STDC__ |
#define SYMBOL_NAME(X) _##X |
#define SYMBOL_NAME_LABEL(X) _##X##: |
#else |
#define SYMBOL_NAME(X) _/**/X |
#define SYMBOL_NAME_LABEL(X) _/**/X/**/: |
#endif |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/defs.h |
---|
0,0 → 1,46 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Definitions to be used in all .h and .c files */ |
#ifndef __LL_I386_DEFS_H__ |
#define __LL_I386_DEFS_H__ |
#ifdef __cplusplus |
#define BEGIN_DEF extern "C" { |
#else |
#define BEGIN_DEF |
#endif |
#ifdef __cplusplus |
#define END_DEF } |
#else |
#define END_DEF |
#endif |
#ifdef PROFILE |
#define FILE(a) static char FileName[] = "Profile:"#a |
#define ASMFILE(a) FileName: .string "Profile:"#a |
#else |
#define FILE(a) |
#define ASMFILE(a) |
#endif |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/sel.h |
---|
0,0 → 1,43 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Hardware selectors used by OSLib */ |
#ifndef __LL_I386_SEL_H__ |
#define __LL_I386_SEL_H__ |
#define NULL_SEL 0x00 |
#define X_DATA16_SEL 0x08 |
#define X_CODE16_SEL 0x10 |
#define X_CODE32_SEL 0x18 |
#define X_RM_BACK_GATE 0x20 |
#define X_PM_ENTRY_GATE 0x28 |
#define X_FLATDATA_SEL 0x30 |
#define X_FLATCODE_SEL 0x38 |
#define X_CALLBIOS_SEL 0x40 |
#define X_CALLBIOS_GATE 0x48 |
#define X_VM86_TSS 0x50 |
#define X_MAIN_TSS 0x58 |
#define X_FLATDATA3_SEL 0x60 |
#define X_FLATCODE3_SEL 0x68 |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/hw-io.h |
---|
0,0 → 1,94 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The hw I/O instructions |
Never include this file!!! Include hw-instr.h instead!!! */ |
#ifndef __LL_I386_HW_IO_H__ |
#define __LL_I386_HW_IO_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* |
The code for inp, outp, inpw, outpw, inpd & outpd is from |
standard GNU C distribution! |
The full source code for the GNU-C distribution is available |
from www.delorie.com |
The following code is ... |
copyright (C) 1995 DJ Delorie, see COPYING.DJ for details |
*/ |
INLINE_OP unsigned char inp(unsigned short _port) |
{ |
unsigned char rv; |
__asm__ __volatile__ ("inb %1, %0" |
: "=a" (rv) |
: "d" (_port)); |
return(rv); |
} |
INLINE_OP unsigned short inpw (unsigned short _port) |
{ |
unsigned short rv; |
__asm__ __volatile__ ("inw %1, %0" |
: "=a" (rv) |
: "d" (_port)); |
return(rv); |
} |
INLINE_OP unsigned long inpd(unsigned short _port) |
{ |
unsigned long rv; |
__asm__ __volatile__ ("inl %1, %0" |
: "=a" (rv) |
: "d" (_port)); |
return(rv); |
} |
INLINE_OP void outp(unsigned short _port, unsigned char _data) |
{ |
__asm__ __volatile__ ("outb %1, %0" |
: |
: "d" (_port), |
"a" (_data)); |
} |
INLINE_OP void outpw(unsigned short _port, unsigned short _data) |
{ |
__asm__ __volatile__ ("outw %1, %0" |
: |
: "d" (_port), |
"a" (_data)); |
} |
INLINE_OP void outpd(unsigned short _port, unsigned long _data) |
{ |
__asm__ __volatile__ ("outl %1, %0" |
: |
: "d" (_port), |
"a" (_data)); |
} |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/i386/mb-info.h |
---|
0,0 → 1,228 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* |
* GRUB -- GRand Unified Bootloader |
* Copyright (C) 1996 Erich Boleyn <erich@uruk.org> |
* |
* This program 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 2 of the License, or |
* (at your option) any later version. |
* |
* This program 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. |
* |
* You should have received a copy of the GNU General Public License |
* along with this program; if not, write to the Free Software |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
*/ |
#ifndef __LL_I386_MB_INFO_H__ |
#define __LL_I386_MB_INFO_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* |
* The structure type "mod_list" is used by the "multiboot_info" structure. |
*/ |
struct mod_list |
{ |
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ |
unsigned long mod_start; |
unsigned long mod_end; |
/* Module command line */ |
unsigned long cmdline; |
/* padding to take it to 16 bytes (must be zero) */ |
unsigned long pad; |
}; |
/* |
* INT-15, AX=E820 style "AddressRangeDescriptor" |
* ...with a "size" parameter on the front which is the structure size - 4, |
* pointing to the next one, up until the full buffer length of the memory |
* map has been reached. |
*/ |
struct AddrRangeDesc |
{ |
unsigned long size; |
unsigned long BaseAddrLow; |
unsigned long BaseAddrHigh; |
unsigned long LengthLow; |
unsigned long LengthHigh; |
unsigned long Type; |
/* unspecified optional padding... */ |
}; |
/* usable memory "Type", all others are reserved. */ |
#define MB_ARD_MEMORY 1 |
/* |
* MultiBoot Info description |
* |
* This is the struct passed to the boot image. This is done by placing |
* its address in the EAX register. |
*/ |
struct multiboot_info |
{ |
/* MultiBoot info version number */ |
unsigned long flags; |
/* Available memory from BIOS */ |
unsigned long mem_lower; |
unsigned long mem_upper; |
/* "root" partition */ |
unsigned long boot_device; |
/* Kernel command line */ |
unsigned long cmdline; |
/* Boot-Module list */ |
unsigned long mods_count; |
unsigned long mods_addr; |
union |
{ |
struct |
{ |
/* (a.out) Kernel symbol table info */ |
unsigned long tabsize; |
unsigned long strsize; |
unsigned long addr; |
unsigned long pad; |
} a; |
struct |
{ |
/* (ELF) Kernel section header table */ |
unsigned long num; |
unsigned long size; |
unsigned long addr; |
unsigned long shndx; |
} e; |
} syms; |
/* Memory Mapping buffer */ |
unsigned long mmap_length; |
unsigned long mmap_addr; |
/* Drive Info buffer */ |
unsigned long drives_length; |
unsigned long drives_addr; |
/* ROM configuration table */ |
unsigned long config_table; |
/* Boot Loader Name */ |
unsigned long boot_loader_name; |
/* APM table */ |
unsigned long apm_table; |
/* Video */ |
unsigned long vbe_control_info; |
unsigned long vbe_mode_info; |
unsigned short vbe_mode; |
unsigned short vbe_interface_seg; |
unsigned short vbe_interface_off; |
unsigned short vbe_interface_len; |
#ifndef __OLD_MB__ |
/* |
Gerardo: I need to add also the phisical address base for |
both low ( < 1MB) & upper ( > 1MB) memory, as X starts from DOS |
which could have preallocated some of this memory... |
For example, GRUB assumes that mem_lowbase = 0x0 & |
mem_upbase = 0x100000 |
*/ |
unsigned long mem_lowbase; |
unsigned long mem_upbase; |
#endif /* __OLD_MB__ */ |
}; |
/* |
* Flags to be set in the 'flags' parameter above |
*/ |
/* is there basic lower/upper memory information? */ |
#define MB_INFO_MEMORY 0x1 |
/* is there a boot device set? */ |
#define MB_INFO_BOOTDEV 0x2 |
/* is the command-line defined? */ |
#define MB_INFO_CMDLINE 0x4 |
/* are there modules to do something with? */ |
#define MB_INFO_MODS 0x8 |
/* These next two are mutually exclusive */ |
/* is there a symbol table loaded? */ |
#define MB_INFO_AOUT_SYMS 0x10 |
/* is there an ELF section header table? */ |
#define MB_INFO_ELF_SHDR 0x20 |
/* is there a full memory map? */ |
#define MB_INFO_MEM_MAP 0x40 |
/* Is there drive info? */ |
#define MB_INFO_DRIVE_INFO 0x00000080 |
/* Is there a config table? */ |
#define MB_INFO_CONFIG_TABLE 0x00000100 |
/* Is there a boot loader name? */ |
#define MB_INFO_BOOT_LOADER_NAME 0x00000200 |
/* Is there a APM table? */ |
#define MB_INFO_APM_TABLE 0x00000400 |
/* Is there video information? */ |
#define MB_INFO_VIDEO_INFO 0x00000800 |
#if 0 |
/* Gerardo: Added this! |
-------------------- |
The idea is that the BootLoader provides an interface |
to return back to it; this is useful to implement a DOS |
boot-loader, in order to use DOS as development environment. |
*/ |
#define MB_INFO_USEGDT 0x80 |
#endif |
/* |
* The following value must be present in the EAX register. |
*/ |
#define MULTIBOOT_VALID 0x2BADB002 |
struct multiboot_info * mbi_address(void); |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/sys/ll/time.h |
---|
0,0 → 1,162 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Inline functions for managing timespec structures. |
All timespec values are pointers!!! |
This file defines these functions: |
TIMESPEC2NANOSEC(t) |
converts a timespec value to a nanosec value, and return |
it, no checks |
TIMESPEC2USEC(t) |
converts a timespec value to a nanosec value, and return |
it, no checks |
NULL_TIMESPEC(t) |
the timespec value is set to the Epoch (=0) |
ADDNANO2TIMESPEC(n, t) |
t = t + n |
ADDUSEC2TIMESPEC(m, t) |
t = t + m |
SUBTIMESPEC(s1, s2, d) Works well only if s1 >= s2 |
d = s1 - s2 |
ADDTIMESPEC(s1, s2, d) |
d = s1 + s2 |
TIMESPEC_A_LT_B(a,b) |
a < b |
TIMESPEC_A_GT_B(a,b) |
a > b |
TIMESPEC_A_EQ_B(a,b) |
a == b |
TIMESPEC_A_NEQ_B(a,b) |
a != b |
TIMESPEC_ASSIGN(t1,t2) |
t1 = t2 */ |
#ifndef __LL_SYS_LL_TIME_H__ |
#define __LL_SYS_LL_TIME_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#ifndef _STRUCT_TIMESPEC |
#define _STRUCT_TIMESPEC |
struct timespec { |
long tv_sec; /* Seconds */ |
long tv_nsec; /* Nanoseconds */ |
}; |
#endif |
/* |
* these macros come from the Utah Flux oskit... |
*/ |
#define TIMESPEC2NANOSEC(t) ((t)->tv_sec * 1000000000 + (t)->tv_nsec) |
#define TIMESPEC2USEC(t) ((t)->tv_sec * 1000000 + (t)->tv_nsec / 1000) |
#define NULL_TIMESPEC(t) ((t)->tv_sec = (t)->tv_nsec = 0) |
#define ADDNANO2TIMESPEC(n, t) ((t)->tv_nsec += (n), \ |
(t)->tv_sec += (t)->tv_nsec / 1000000000, \ |
(t)->tv_nsec %= 1000000000) |
#define SUBTIMESPEC(s1, s2, d) \ |
((d)->tv_nsec = ((s1)->tv_nsec >= (s2)->tv_nsec) ? \ |
(((d)->tv_sec = (s1)->tv_sec - (s2)->tv_sec), \ |
(s1)->tv_nsec - (s2)->tv_nsec) \ |
: \ |
(((d)->tv_sec = (s1)->tv_sec - (s2)->tv_sec - 1), \ |
(1000000000 + (s1)->tv_nsec - (s2)->tv_nsec))) |
/* |
* ...and these not! |
*/ |
extern __inline__ void ADDTIMESPEC(const struct timespec *s1, |
const struct timespec *s2, |
struct timespec *d) |
{ |
d->tv_sec = s1->tv_sec + s2->tv_sec; |
d->tv_nsec = s1->tv_nsec + s2->tv_nsec; |
if (d->tv_nsec < 0) { |
d->tv_sec--; |
d->tv_nsec += 1000000000; |
} else if (d->tv_nsec >= 1000000000) { |
d->tv_sec++; |
d->tv_nsec -= 1000000000; |
} |
} |
#define ADDUSEC2TIMESPEC(m, t) ((t)->tv_nsec += (m%1000000)*1000, \ |
(t)->tv_sec += ((t)->tv_nsec / 1000000000) + (m/1000000), \ |
(t)->tv_nsec %= 1000000000) |
#define TIMESPEC_A_LT_B(a,b) \ |
( \ |
((a)->tv_sec < (b)->tv_sec) || \ |
((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec < (b)->tv_nsec) \ |
) |
#define TIMESPEC_A_GT_B(a,b) \ |
( \ |
((a)->tv_sec > (b)->tv_sec) || \ |
((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec > (b)->tv_nsec) \ |
) |
#define TIMESPEC_A_EQ_B(a,b) \ |
((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec == (b)->tv_nsec) |
#define TIMESPEC_A_NEQ_B(a,b) \ |
((a)->tv_sec != (b)->tv_sec || (a)->tv_nsec != (b)->tv_nsec) |
#define TIMESPEC_ASSIGN(t1,t2) \ |
((t1)->tv_sec = (t2)->tv_sec, (t1)->tv_nsec = (t2)->tv_nsec) |
#if 0 |
#define PITSPEC2TIMESPEC(a,b) \ |
((b)->tv_nsec = (((DWORD)((a)->units) * 1000) / 1197) * 1000, \ |
(b)->tv_sec = ((a)->gigas * 1197) / 1000) /*, \ |
(b)->tv_sec += (b)->tv_nsec / 1000000000, \ |
(b)->tv_nsec %= 1000000000) */ |
#else |
/*#define PITSPEC2TIMESPEC(a,b) \ |
((b)->tv_nsec = (((DWORD)((a)->units) * 1000) / 1197) * 1000, \ |
(b)->tv_nsec += (((a)->gigas * 1197) % 1000) * 1000000, \ |
(b)->tv_sec = ((a)->gigas * 1197) / 1000 , \ |
(b)->tv_sec += (b)->tv_nsec / 1000000000, \ |
(b)->tv_nsec %= 1000000000)*/ |
#define PITSPEC2TIMESPEC(a,b) \ |
((b)->tv_nsec = (((DWORD)((a)->units) * 1000) / 1193), \ |
(b)->tv_nsec += (((a)->gigas * 1193) % 1000) * 1000, \ |
(b)->tv_sec = ((a)->gigas * 1193) / 1000 , \ |
(b)->tv_sec += (b)->tv_nsec / 1000000, \ |
(b)->tv_nsec %= 1000000, \ |
(b)->tv_nsec *= 1000) |
#endif |
TIME ll_gettime(int mode, struct timespec *tsres); |
#define TIME_PTICK 1 |
#define TIME_EXACT 2 |
#define TIME_NEW 3 |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/sys/ll/event.h |
---|
0,0 → 1,85 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Time event management functions */ |
#ifndef __LL_SYS_LL_EVENT_H__ |
#define __LL_SYS_LL_EVENT_H__ |
#include <ll/i386/defs.h> |
#include <ll/sys/ll/time.h> |
#include <ll/sys/ll/ll-data.h> |
BEGIN_DEF |
#define MAX_EVENT 250 |
struct event { |
struct event *next; /* Next event in an event queue */ |
void *par; /* Handler's parameter */ |
void (*handler)(void *p); /* Event Handler */ |
struct timespec time; /* Time at which the event |
will raise */ |
int index; /* Event ID */ |
}; |
/* Event management functions... */ |
void event_setprologue(void *p); |
void event_setepilogue(void *p); |
void event_setlasthandler(void *p); |
int (*event_post)(struct timespec time, void (*handler)(void *p), void *par); |
int (*event_delete)(int index); |
int oneshot_event_post(struct timespec time, void (*handler)(void *p), void *par); |
int oneshot_event_delete(int index); |
int periodic_event_post(struct timespec time, void (*handler)(void *p), void *par); |
int periodic_event_delete(int index); |
void event_init(struct ll_initparms *l); |
/* Interrupt handler entry */ |
struct intentry { |
void *par; /* Handler's parameter */ |
void (*handler)(void *p); /* Interrupt Handler */ |
int index; /* Interrupt number */ |
DWORD status; /* Interrupt status |
no handler --> FREE |
handler --> ASSIGNED |
being served --> BUSY |
*/ |
DWORD flags; |
}; |
#define INT_PREEMPTABLE 1 |
#define INT_FORCE 2 |
#define INTSTAT_FREE 1 |
#define INTSTAT_ASSIGNED 2 |
#define INTSTAT_BUSY 3 |
void irq_init(void); |
int irq_bind(int irq, void (*handler)(void *p), DWORD flags); |
int ll_ActiveInt(); |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/sys/ll/aspace.h |
---|
0,0 → 1,66 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Address spaces code & data */ |
#ifndef __LL_SYS_LL_ASPACE_H__ |
#define __LL_SYS_LL_ASPACE_H__ |
#include <ll/i386/defs.h> |
/* I dont't know if we really need all these things... */ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/tss-ctx.h> |
BEGIN_DEF |
struct as { |
DWORD base; |
DWORD limit; |
WORD status; |
}; |
/* An Address Space descriptor is a Segment descriptor... so it is a WORD... */ |
#define AS WORD |
#define AS_FREE 0 |
#define AS_BUSY 1 |
#define ASMax 60 |
#if 0 |
#define ASBase 0x300 /* Is it correct? TSSBase + 64 *8... */ |
#endif |
#define ASBase (TSSBase + TSSMax * 8) |
#define ASsel2index(sel) ((sel-ASBase) / 16) |
#define ASindex2sel(i) (ASBase + i * 16) |
void as_init(void); |
AS as_create(void); |
int as_bind(AS as, DWORD ph_addr, DWORD l_addr, DWORD size); |
END_DEF |
#endif /* __LL_SYS_LL_ASPACE_H__ */ |
/shark/trunk/arch/x86/include/arch/ll/sys/ll/ll-func.h |
---|
0,0 → 1,56 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Kernel Library functions interfaces */ |
#ifndef __LL_SYS_LL_LL_FUNC_H_ |
#define __LL_SYS_LL_LL_FUNC_H_ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
#include <ll/sys/ll/ll-data.h> |
void ll_context_setspace(CONTEXT c, WORD as); |
CONTEXT ll_context_create(void (*task)(void *p),BYTE *stack, |
void *parm,void (*killer)(void),WORD ctrl); |
/* Release a used task context */ |
void ll_context_delete(CONTEXT c); |
/* Put the context value into human readable form; used for debug! */ |
char *ll_context_sprintf(char *str,CONTEXT c); |
/* These functions start-up & close the ll layer */ |
void *ll_init(void); |
void ll_end(void); |
/* This functions acts as safety place where to go when any error */ |
/* occurs and we do not know what context is active */ |
void ll_abort(int code); |
END_DEF |
#endif /* __LL_SYS_LL_LL_MEM_H_ */ |
/shark/trunk/arch/x86/include/arch/ll/sys/ll/ll-data.h |
---|
0,0 → 1,44 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Kernel Library data structures definitions */ |
#ifndef __LL_SYS_LL_LL_DATA_H__ |
#define __LL_SYS_LL_LL_DATA_H__ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
/* These are used by the ll_init function... */ |
#define LL_PERIODIC 0 |
#define LL_ONESHOT 1 |
struct ll_initparms { |
DWORD mode; |
TIME tick; |
}; |
END_DEF |
#endif /* __LL_SYS_LL_LL_DATA_H__ */ |
/shark/trunk/arch/x86/include/arch/ll/sys/ll/exc.h |
---|
0,0 → 1,40 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Hardware exceptions */ |
#ifndef __LL_SYS_LL_HW_EXC_H__ |
#define __LL_SYS_LL_HW_EXC_H__ |
#define DIV_BY_0 0 /* These are the ll... exceptions */ |
#define MATH_EXC 1 |
#define NMI_EXC 2 |
#define DEBUG_EXC 3 |
#define BREAKPOINT_EXC 4 |
#define HW_FAULT 5 |
#define NO_MORE_HW_DESC 6 |
#define VM86_PANIC 7 |
/* Please, do not confuse them with the HW exception!!! */ |
#define CLOCK_OVERRUN 64 /* Warning this is used in vm1.asm */ |
#endif /* __LL_SYS_LL_HW_EXC_H__ */ |
/shark/trunk/arch/x86/include/arch/ll/sys/ll/ll-mem.h |
---|
0,0 → 1,38 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Some memory management code */ |
#ifndef __LL_SYS_LL_LL_MEM_H_ |
#define __LL_SYS_LL_LL_MEM_H_ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
/* These function are used to manage memory at ll layer */ |
void * ll_alloc(DWORD size); |
WORD ll_free(void *ptr,DWORD size); |
void ll_mem_init(void *base,DWORD size); |
void ll_mem_dump(void); |
END_DEF |
#endif /* __LL_SYS_LL_LL_MEM_H_ */ |
/shark/trunk/arch/x86/include/arch/ll/sys/ll/ll-instr.h |
---|
0,0 → 1,57 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#ifndef __LL_SYS_LL_LL_INSTR_H_ |
#define __LL_SYS_LL_LL_INSTR_H_ |
#include <ll/i386/defs.h> |
BEGIN_DEF |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-func.h> |
/* |
Well, these are simple macros... to map the HARTIK names |
onto the standard names! |
*/ |
#define ll_in(port) inp(port) |
#define ll_out(port,v) outp(port,v) |
#define ll_inw(port) inpw(port) |
#define ll_outw(port,v) outpw(port,v) |
#define ll_ind(port) inpd(port) |
#define ll_outd(port,v) outpd(port,v) |
/* These functions are used to mask/unmask selectively interrupts */ |
/* The irq services are also #defined to allow more generic inteface */ |
/* This is done into hw... files! */ |
void ll_irq_mask(WORD irqno); |
void ll_irq_unmask(WORD irqno); |
/* These functions provide direct access to interrupt table */ |
/* We can write the HARTIK interrupt table but only read */ |
/* the host OS interrupt table! */ |
void ll_irq_set(WORD irqno,INTERRUPT handler); |
INTERRUPT ll_irq_get(WORD irqno); |
END_DEF |
#endif |
/shark/trunk/arch/x86/include/arch/ll/sys/types.h |
---|
0,0 → 1,45 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#ifndef __LL_SYS_TYPES_H__ |
#define __LL_SYS_TYPES_H__ |
#include <ll/i386/hw-data.h> |
#define size_t DWORD |
#define ssize_t long int |
#define va_list void* |
#define u_int unsigned int |
#define u_char BYTE |
#define u_short WORD |
#define u_long DWORD |
/* unsigned integers */ |
typedef BYTE u_int8_t; |
typedef WORD u_int16_t; |
typedef DWORD u_int32_t; |
/* signed integers */ |
typedef signed char int8_t; |
typedef short int int16_t; |
typedef int int32_t; |
#endif |
/shark/trunk/arch/x86/include/arch/ll/ll.h |
---|
0,0 → 1,51 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* The abominious: an ``include all'' header!!! */ |
#ifndef __LL_LL_H__ |
#define __LL_LL_H__ |
#include <ll/sys/ll/aspace.h> |
#include <ll/sys/ll/event.h> |
#include <ll/sys/ll/exc.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/ll-func.h> |
#include <ll/sys/ll/time.h> |
#include <ll/sys/ll/ll-instr.h> |
#include <ll/sys/ll/ll-mem.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/error.h> |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/hw-io.h> |
#include <ll/i386/linkage.h> |
#include <ll/i386/mb-hdr.h> |
#include <ll/i386/mb-info.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/sel.h> |
#include <ll/i386/tss-ctx.h> |
#include <ll/i386/x-bios.h> |
#include <ll/i386/x-dos.h> |
#endif |
/shark/trunk/arch/x86/xsys0.s |
---|
0,0 → 1,102 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Provides the _exit function for escaping from PM!!! */ |
#include <ll/i386/linkage.h> |
#include <ll/i386/defs.h> |
#include <ll/i386/sel.h> |
#include <ll/i386/defs.h> |
.data |
ASMFILE(X0-Sys) |
.text |
.globl SYMBOL_NAME(_x_callBIOS) |
#ifdef __NO_INLINE_PORT__ |
.globl SYMBOL_NAME(outp) |
.globl SYMBOL_NAME(inp) |
.globl SYMBOL_NAME(outpw) |
.globl SYMBOL_NAME(inpw) |
.globl SYMBOL_NAME(outpd) |
.globl SYMBOL_NAME(inpd) |
#endif |
/* Invoke 16 bit BIOS function from PM application */ |
/* void _x_callBIOS(void) */ |
SYMBOL_NAME_LABEL(_x_callBIOS) |
.byte 0x09a /* Direct gate call */ |
.long 0 |
.word X_CALLBIOS_GATE |
ret |
#ifdef __NO_INLINE_PORT__ |
/* void outp(int port,char value) */ |
SYMBOL_NAME_LABEL(outp) |
movl 4(%esp),%edx |
movl 8(%esp),%eax |
outb %al,%dx |
ret |
/* char inp(int port) */ |
SYMBOL_NAME_LABEL(inp) |
movl 4(%esp),%edx |
inb %dx,%al |
movzb %al,%eax |
ret |
/* void outpw(int port,unsigned short value) */ |
SYMBOL_NAME_LABEL(outpw) |
movl 4(%esp),%edx |
movl 8(%esp),%eax |
outw %ax,%dx |
ret |
/* unsigned short inpw(int port) */ |
SYMBOL_NAME_LABEL(inpw) |
movl 4(%esp),%edx |
inw %dx,%ax |
movzwl %ax,%eax |
ret |
/* void outpd(int port,unsigned long value) */ |
SYMBOL_NAME_LABEL(outpd) |
movl 4(%esp),%edx |
movl 8(%esp),%eax |
outl %eax,%dx |
ret |
/* unsigned long inpd(int port) */ |
SYMBOL_NAME_LABEL(inpd) |
movl 4(%esp),%edx |
inl %dx,%eax |
ret |
#endif /* __NO_INLINE_PORTS__ */ |
/shark/trunk/arch/x86/ctxsw.c |
---|
0,0 → 1,71 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Context switch code */ |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-func.h> |
#include <ll/i386/tss-ctx.h> |
#include <tracer.h> |
FILE(Context-Switch); |
extern unsigned short int currCtx; |
#ifdef __VIRCSW__ |
extern int activeInt; |
#endif |
extern void context_load(CONTEXT c); |
void ll_context_to(CONTEXT c) |
{ |
#ifdef __VIRCSW__ |
currCtx = c; |
if (activeInt == 0) { |
TRACER_LOGEVENT(FTrace_EVT_context_switch, (unsigned short int)c, 0); |
context_load(c); |
} |
#else |
currCtx = c; |
context_load(c); |
#endif |
} |
CONTEXT ll_context_from(void) |
{ |
#ifdef __VIRCSW__ |
return currCtx; |
#else |
return context_save(); |
#endif |
} |
CONTEXT ll_context_save(void) |
{ |
return currCtx; |
} |
void ll_context_load(CONTEXT c) |
{ |
currCtx = c; |
TRACER_LOGEVENT(FTrace_EVT_context_switch, (unsigned short int)c, 0); |
context_load(c); |
} |
/shark/trunk/arch/x86/ctx.s |
---|
0,0 → 1,94 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Context switch code */ |
#include <ll/i386/sel.h> |
#include <ll/i386/linkage.h> |
#include <ll/i386/defs.h> |
.data |
ASMFILE(Context) |
.globl SYMBOL_NAME(currCtx) |
.globl JmpSel |
.globl JmpZone |
SYMBOL_NAME_LABEL(currCtx) .word 0 |
JmpZone: |
JmpOffset: |
.word 0 |
.word 0 |
JmpSel: |
.word 0 |
.text |
.globl SYMBOL_NAME(context_save) |
.globl SYMBOL_NAME(context_change) |
.globl SYMBOL_NAME(context_load) |
.globl SYMBOL_NAME(init_TR) |
/* This function assign a value to the TASK register of 386 architecture */ |
/* We MUST do this BEFORE we use the HW multitask */ |
SYMBOL_NAME_LABEL(init_TR) |
pushl %ebp |
movl %esp,%ebp |
movl 8(%ebp),%eax |
ltrw %ax |
movw %ax,JmpSel |
movw %ax,SYMBOL_NAME(currCtx) |
popl %ebp |
ret |
/* CONTEXT __cdecl context_save(void); */ |
/* The context is returned into AX; Interrupts are also cleared as we are */ |
/* entering into kernel primitives */ |
SYMBOL_NAME_LABEL(context_save) |
xorl %eax,%eax |
strw %ax |
ret |
/* void __cdecl context_change(CONTEXT c) */ |
/* Use 386 task switch ability. This is the last call of any preemption */ |
/* generating primitive; when the original task is re-activated the */ |
/* interrupt flag is restored with STI */ |
/* In 32 bit systems, context_load is an alias for context_change!*/ |
SYMBOL_NAME_LABEL(context_load) |
SYMBOL_NAME_LABEL(context_change) |
pushl %ebp |
movl %esp,%ebp |
movw $(X_FLATDATA_SEL),%ax |
movw %ax,%ds |
movw %ax,%es |
movl 8(%ebp),%eax |
cmpw JmpSel,%ax |
je NoPreempt |
movw %ax,JmpSel |
ljmp *JmpZone |
NoPreempt: popl %ebp |
ret |
/shark/trunk/arch/x86/event.c |
---|
0,0 → 1,330 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Added Advanced Timer Code |
* |
* Date: 8.4.2003 |
* Author: Giacomo Guidi <giacomo@gandalf.sssup.it> |
* |
*/ |
/* Time Event routines */ |
#include <arch/i386/stdlib.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/error.h> |
#include <ll/i386/hw-arch.h> |
#include <ll/i386/pic.h> |
#include <ll/i386/pit.h> |
#include <ll/i386/apic.h> |
#include <ll/i386/advtimer.h> |
#include <ll/i386/64bit.h> |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/ll-instr.h> |
#include <ll/sys/ll/ll-func.h> |
#include <ll/sys/ll/time.h> |
#include <ll/sys/ll/event.h> |
#include <tracer.h> |
extern unsigned short int currCtx; |
FILE(Event); |
extern LL_ARCH ll_arch; |
BYTE frc; |
/* Timer 0 usec base tick */ |
DWORD ticksize; |
/* Timer 0 loaded time constant (= ticksize * 1.197) */ |
WORD pit_time_const; |
DWORD timermode; |
static DWORD nts; /* System tick in nanoSeconds... */ |
struct timespec actTime; /* Time (in nanosecs)... */ |
extern int activeInt; |
WORD lastTime; |
struct pitspec globalCounter; |
struct event eventlist[MAX_EVENT]; |
struct event *freeevents; |
struct event *firstevent; |
extern void *last_handler; |
extern void (*evt_prol) (void); |
extern void (*evt_epil) (void); |
extern unsigned int apic_clk_per_msec; |
extern unsigned char use_apic, use_tsc; |
void event_setlasthandler(void *p) |
{ |
last_handler = p; |
} |
void event_setprologue(void *p) |
{ |
evt_prol = p; |
} |
void event_setepilogue(void *p) |
{ |
evt_epil = p; |
} |
/* Switched to timespec */ |
int periodic_event_post(struct timespec time, void (*handler) (void *p), void *par) |
{ |
struct event *p; |
struct event *p1, *t; |
TRACER_LOGEVENT(FTrace_EVT_timer_post, 0, 0); |
if (!freeevents) { |
message("NO FREE EVENTS !\n"); |
ll_abort(20); |
return -1; |
} |
/* Extract from the ``free events'' queue */ |
p = freeevents; |
freeevents = p->next; |
/* Fill the event fields */ |
p->handler = handler; |
TIMESPEC_ASSIGN(&(p->time), &time); |
p->par = par; |
/* ...And insert it in the event queue!!! */ |
t = NULL; |
/* walk through list, finding spot, adjusting ticks parameter */ |
for (p1 = firstevent; p1; p1 = t->next) { |
/* |
SUBTIMESPEC(&time, &(p1->time), &tmp); |
if ((tmp.tv_sec > 0) && (tmp.tv_nsec > 0)) { |
*/ |
if (TIMESPEC_A_GT_B(&time, &p1->time)) |
t = p1; |
else |
break; |
} |
/* adjust next entry */ |
if (t) { |
t->next = p; |
} else { |
firstevent = p; |
} |
p->next = p1; |
return p->index; |
} |
int periodic_event_delete(int index) |
{ |
struct event *p1, *t; |
TRACER_LOGEVENT(FTrace_EVT_timer_delete, 0, 0); |
if (index == -1) |
return -1; |
t = NULL; |
/* walk through list, finding spot, adjusting ticks parameter */ |
for (p1 = firstevent; (p1) && (index != p1->index); p1 = t->next) { |
t = p1; |
} |
if (p1 == NULL) { |
return -1; |
} |
if (t == NULL) { |
firstevent = p1->next; |
} else { |
t->next = p1->next; |
} |
p1->next = freeevents; |
freeevents = p1; |
return 1; |
} |
void periodic_wake_up(void) |
{ |
/* CHANGE the NAME, please... */ |
struct event *p, *pp; |
WORD tmp; |
TRACER_LOGEVENT(FTrace_EVT_timer_wakeup_start, 0, 0); |
if (!use_tsc) { |
tmp = pit_read(frc); |
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter); |
lastTime = tmp; |
} |
activeInt++; |
if (activeInt == 1 && evt_prol != NULL) { |
evt_prol(); |
} |
if (use_tsc) |
ll_read_timespec(&actTime); |
else |
ADDNANO2TIMESPEC(nts, &actTime); |
for (p = firstevent; p != NULL; p = pp) { |
/* |
SUBTIMESPEC(&(p->time), &actTime, &tmp); |
if ((tmp.tv_sec > 0) && (tmp.tv_nsec > 0)) { |
break; |
} */ |
if ((p->time.tv_sec > actTime.tv_sec) || |
((p->time.tv_sec == actTime.tv_sec) |
&& (p->time.tv_nsec > actTime.tv_nsec))) { |
break; |
} |
pp = p->next; |
p->next = freeevents; |
freeevents = p; |
firstevent = pp; |
p->handler(p->par); |
} |
if (activeInt == 1 && evt_epil != NULL) { |
evt_epil(); |
} |
activeInt--; |
TRACER_LOGEVENT(FTrace_EVT_timer_wakeup_end, (unsigned short int)currCtx, 0); |
} |
void event_init(struct ll_initparms *l) |
{ |
extern void ll_timer(void); |
extern void ll_apic_timer(void); |
int i; |
BYTE mask; |
TIME t; |
DWORD apic_clk; |
ll_init_advtimer(); |
if (use_apic) |
IDT_place(0x39,ll_apic_timer); |
else |
IDT_place(0x40,ll_timer); |
if (l->mode != LL_PERIODIC) { |
message("One-shot mode\n"); |
t = 0; |
if (use_apic) { |
set_APIC_timer(0xFFFFFFFF); |
enable_APIC_timer(); |
} else { |
/* Mode: Binary/Mode 4/16 bit Time_const/Counter 0 */ |
pit_init(0, TMR_MD4, 0xFFFF); /* Timer 0, Mode 4, constant 0xFFFF */ |
} |
} else { |
t = l->tick; |
/* Translate the tick value in usec into a suitable time constant */ |
/* for 8254 timer chip; the chip is driven with a 1.19718 MHz */ |
/* frequency; then the effective frequency is given by the base */ |
/* frequency divided for the time constant; the tick is the inverse */ |
/* of this effective frequency (in usec!) */ |
/* Time-Constant = f_base (MHz) * tick (usec) */ |
/* If T-C == 0 -> T-C = 65536 (Max available) */ |
ticksize = t; |
if (use_apic) { |
mul32div32to32(t,apic_clk_per_msec,1000,apic_clk); |
set_APIC_timer(apic_clk); |
enable_APIC_timer(); |
} else { |
mul32div32to32(t,1193182,1000000,t); |
/* Only for security! This should cause timer overrun */ |
/* While 0 would set maximum period on timer */ |
if (t == 0) |
t = 1; |
pit_time_const = (WORD) (t & 0xFFFF); |
/* Mode: Binary/Mode 2/16 bit Time_const/Counter 0 */ |
pit_init(0, TMR_MD2, t); /* Timer 0, Mode 2, Time constant t */ |
} |
} |
timermode = l->mode; |
if (!use_apic) { |
if (ll_arch.x86.cpu > 4) { |
/* Timer1: mode 0, time const 0... */ |
pit_init(1, TMR_MD0, 0); |
frc = 1; |
} else { |
frc = 2; |
pit_init(2, TMR_MD0, 0); |
outp(0x61, 3); |
} |
} |
mask = ll_in(0x21); |
mask &= 0xFE; /* 0xFE = ~0x01 */ |
ll_out(0x21, mask); |
/* Init the event list... */ |
for (i = 0; i < MAX_EVENT; i++) { |
if (i < MAX_EVENT - 1) { |
eventlist[i].next = &(eventlist[i + 1]); |
} |
eventlist[i].index = i; |
} |
eventlist[MAX_EVENT - 1].next = NULL; |
freeevents = &(eventlist[0]); |
evt_prol = NULL; |
evt_epil = NULL; |
/* Initialization of the time variables for periodic mode */ |
nts = ticksize * 1000; |
NULL_TIMESPEC(&actTime); |
/* Initialization of the general time variables */ |
NULLPITSPEC(&globalCounter); |
lastTime = 0; |
if (timermode == LL_PERIODIC) { |
event_post = periodic_event_post; |
event_delete = periodic_event_delete; |
} else { |
event_post = oneshot_event_post; |
event_delete = oneshot_event_delete; |
} |
/* Last but not least... */ |
if (!use_apic) |
irq_unmask(0); |
} |
/shark/trunk/arch/x86/estub.c |
---|
0,0 → 1,108 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
#include <stdlib.h> |
#include <stdio.h> |
#include <hw-data.h> |
#include "event.h" |
FILE(Event-Stub); |
extern struct event *freeevents; |
extern struct event *firstevent; |
extern TIME actTime; |
void called(void) |
{ |
printf("Called...\n"); |
} |
void event_printqueue(struct event *q) |
{ |
struct event *p; |
for (p = q; p; p = p->next) { |
printf("Entry %d: Time %d...\n", p->index, p->time); |
} |
} |
main() |
{ |
int i, rem; |
event_init(); |
printf("Free event queue:\n"); |
event_printqueue(freeevents); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
i = event_post(10, called, NULL); |
printf("Inserted Event %d\n", i); |
printf("Free event queue:\n"); |
event_printqueue(freeevents); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
i = event_post(100, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(5, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(50, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(1, called, NULL); |
printf("Inserted Event %d\n", i); |
i = event_post(110, called, NULL); |
printf("Inserted Event %d\n", i); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
printf("Now, Wakin' up...\n"); |
actTime = 1; |
wake_up(10); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
actTime = 70; |
wake_up(10); |
i = event_post(45, called, NULL); |
i = event_post(80, called, NULL); |
i = event_post(20, called, NULL); |
rem = event_post(90, called, NULL); |
i = event_post(105, called, NULL); |
i = event_post(150, called, NULL); |
printf("Pending events queue:\n"); |
event_printqueue(firstevent); |
i = event_delete(rem); |
printf("EVT %d removed...OK=%d Pending events queue:\n", rem, i); |
event_printqueue(firstevent); |
i = event_delete(6); |
printf("EVT 6 removed...OK=%d Pending events queue:\n", i); |
i = event_delete(2); |
printf("EVT 2 removed...OK=%d Pending events queue:\n", i); |
i = event_delete(8); |
printf("EVT 8 removed...OK=%d Pending events queue:\n", i); |
event_printqueue(firstevent); |
} |
/shark/trunk/arch/x86/abort.s |
---|
0,0 → 1,61 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Safe abort routine & timer asm handler */ |
.title "Abort.S" |
#include <ll/i386/sel.h> |
#include <ll/i386/linkage.h> |
#include <ll/i386/defs.h> |
#include <ll/sys/ll/exc.h> |
.data |
ASMFILE(Abort) |
#define SAFESTACKSIZE 4096 |
.bss |
/* Safe stack area for aborts */ |
.space 4096,0 |
SafeStack: |
.extern SYMBOL_NAME(act_int) |
.extern SYMBOL_NAME(abort_tail) |
.text |
.globl SYMBOL_NAME(ll_abort) |
SYMBOL_NAME_LABEL(ll_abort) |
/* As we are terminating we cannnot handle */ |
/* any other interrupt! */ |
cli |
/* Get argument */ |
movl 4(%esp),%eax |
/* Switch to safe stack */ |
movl $(SafeStack),%esp |
/* Push argument */ |
pushl %eax |
/* Call sys_abort(code) */ |
call SYMBOL_NAME(abort_tail) |
/shark/trunk/arch/x86/xinit.c |
---|
0,0 → 1,154 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Xlib initialization code */ |
#include <ll/i386/mem.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/mb-info.h> |
#include <ll/i386/error.h> |
#include <ll/i386/pit.h> |
#include <ll/i386/pic.h> |
#include <ll/i386/tss-ctx.h> |
#include <ll/i386/hw-arch.h> |
FILE(X-Init); |
extern DWORD ll_irq_table[256]; |
#ifdef __VIRCSW__ |
int activeInt = 0; |
#endif |
/* Assembly external routines! */ |
/* Setup the TR register of the 80386, to initialize context switch */ |
extern void init_TR(WORD v); |
TSS main_tss; |
/* Architecture definition */ |
LL_ARCH ll_arch; |
/* The following stuff is in llCxA.Asm/S */ |
static void dummyfun(int i) |
{ |
#if 0 |
if (i < 32) { |
cputs("Unhandled Exc occured!!!\n"); |
} else { |
cputs("Unhandled Int occured!!!\n"); |
} |
#else |
message("Unhandled Exc or Int %d occured!!!\n", i); |
#endif |
halt(); |
} |
void l1_int_bind(int i, void *f) |
{ |
ll_irq_table[i] = (DWORD)f; |
} |
void *l1_init(void) |
{ |
register int i; |
struct ll_cpuInfo cpuInfo; |
extern unsigned char X86_apic; |
extern unsigned char X86_tsc; |
extern BYTE X86_fpu; |
LIN_ADDR b; |
for(i = 0; i < 256; i++) { |
ll_irq_table[i] = (DWORD)dummyfun; |
} |
X86_get_CPU(&cpuInfo); |
X86_get_FPU(); |
ll_arch.x86.arch = __LL_ARCH__; |
ll_arch.x86.cpu = cpuInfo.X86_cpu; |
ll_arch.x86.fpu = X86_fpu; |
memcpy(&(ll_arch.x86.vendor), &(cpuInfo.X86_vendor_1), 12); |
X86_apic = (cpuInfo.X86_StandardFeature>>9) & 1; |
X86_tsc = (cpuInfo.X86_StandardFeature>>4) & 1; |
/* TODO! Need to map featuresXXX & Signature onto ll_arch! */ |
/* TODO! Need to check for CPU bugs!! */ |
#ifdef __LL_DEBUG__ |
message("LL Architecture: %s\n", __LL_ARCH__); |
message("CPU : %u\nFPU : %u\n", cpuInfo.X86_cpu, X86_fpu); |
message("Signature : 0x%lx\nVendor: %s\n", cpuInfo.X86_signature, |
ll_arch.x86.vendor); |
message("Features #1: 0x%lx\n", cpuInfo.X86_IntelFeature_1); |
message("Features #2: 0x%lx\n", cpuInfo.X86_IntelFeature_2); |
message("Features #3: 0x%lx\n", cpuInfo.X86_StandardFeature); |
message("Has APIC: %s\n", X86_apic); |
message("Has TSC: %s\n", X86_tsc); |
#endif /* __LL_DEBUG__ */ |
IDT_init(); |
/* Init coprocessor & assign it to main() */ |
/* OK... Now I know the sense of all this... : |
We need a initial value for the FPU context (to be used for creating |
new FPU contexts, as init value)... |
... And we get it in this strange way!!!! |
*/ |
reset_fpu(); |
init_fpu(); |
/* Init PIC controllers & unmask timer */ |
PIC_init(); |
/* Set the TR initial value */ |
b = (LIN_ADDR)(&main_tss); |
GDT_place(MAIN_SEL, (DWORD)b, sizeof(TSS), FREE_TSS386, GRAN_16); |
init_TR(MAIN_SEL); |
return mbi_address(); |
} |
void l1_end(void) |
{ |
outp(0x21,0xFF); |
outp(0xA1,0xFF); |
/* Back to DOS settings */ |
PIC_end(); |
/* Reset the timer chip according DOS specification */ |
/* Mode: Binary/Mode 3/16 bit Time_const/Counter 0 */ |
#if 0 |
outp(0x43,0x36); |
/* Time_const = 65536; write 0 in CTR */ |
outp(0x40,0); |
outp(0x40,0); |
#endif |
pit_init(0, TMR_MD3, 0); /* Timer 0, Mode 3, Time constant 0 */ |
if(ll_arch.x86.cpu > 4) { |
pit_init(1, TMR_MD2, 18); |
} else { |
pit_init(2, TMR_MD0, 0); |
outp(0x61, 0); /* Stop channel 2 */ |
} |
} |
/shark/trunk/arch/x86/aspace.c |
---|
0,0 → 1,84 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* Routines to create address spaces and bind physical memory to them */ |
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/aspace.h> |
FILE(Address-Space); |
struct as AS_table[ASMax]; |
void as_init(void) |
{ |
int i; |
for (i = 0; i < ASMax; i++) { |
AS_table[i].status = AS_FREE; |
} |
} |
AS as_create(void) |
{ |
int i; |
i = 0; |
while((i < ASMax) && (AS_table[i].status & AS_BUSY)) { |
i++; |
} |
if (i == ASMax) { |
return 0; |
} |
AS_table[i].status = AS_BUSY; /* Empty address space... */ |
AS_table[i].base = 0; |
AS_table[i].limit= 0; |
GDT_place(ASindex2sel(i), AS_table[i].base, AS_table[i].limit, |
DATA_ACCESS, GRAN_32B); |
GDT_place(ASindex2sel(i) + 8, AS_table[i].base, AS_table[i].limit, |
CODE_ACCESS, GRAN_32B); |
/* We also need a code segment... */ |
return ASindex2sel(i); |
} |
int as_bind(AS as, DWORD ph_addr, DWORD l_addr, DWORD size) |
{ |
int i = ASsel2index(as); |
/* We have not paging... So l_addr must be 0 */ |
if (l_addr != 0) |
return -1; |
AS_table[i].base = ph_addr; |
AS_table[i].limit= size; |
GDT_place(as, AS_table[i].base, AS_table[i].limit, |
DATA_ACCESS, GRAN_32B); |
GDT_place(as + 8, AS_table[i].base, AS_table[i].limit, |
CODE_ACCESS, GRAN_32B); |
/* We also need a code segment... */ |
return 1; |
} |
/shark/trunk/arch/x86/xsystab.c |
---|
0,0 → 1,92 |
/* Project: OSLib |
* Description: The OS Construction Kit |
* Date: 1.6.2000 |
* Idea by: Luca Abeni & Gerardo Lamastra |
* |
* OSLib is an SO project aimed at developing a common, easy-to-use |
* low-level infrastructure for developing OS kernels and Embedded |
* Applications; it partially derives from the HARTIK project but it |
* currently is independently developed. |
* |
* OSLib is distributed under GPL License, and some of its code has |
* been derived from the Linux kernel source; also some important |
* ideas come from studying the DJGPP go32 extender. |
* |
* We acknowledge the Linux Community, Free Software Foundation, |
* D.J. Delorie and all the other developers who believe in the |
* freedom of software and ideas. |
* |
* For legalese, check out the included GPL license. |
*/ |
/* These function provide access to hardware structutes GDT/IDT */ |
#include <ll/i386/cons.h> |
#include <ll/i386/mem.h> |
FILE(X-SysTab); |
extern GATE IDT[256]; |
/* We usually need to set-up an interrupt handler; to do this we have */ |
/* to fill a GATE structure & copy it into the Interrupt Descriptor */ |
/* Table or IDT; its phisical address is given by IDT_base */ |
void IDT_place(BYTE num,void (*handler)(void)) |
{ |
DWORD offset = (DWORD)(handler); |
IDT[num].sel = X_FLATCODE_SEL; |
/* Set DPL = 3, to allow execution of the gate from any ring */ |
IDT[num].access = INT_GATE386 | 0x60; |
IDT[num].dword_cnt = 0; |
IDT[num].offset_lo = offset & 0xFFFF; |
offset >>= 16; |
IDT[num].offset_hi = offset & 0xFFFF; |
} |
/* Ok; the GDT is managed in the same way as the IDT */ |
/* When a descriptor is cleared using it will cause a SEGMENT FAULT */ |
/* to refer such descriptor */ |
void GDT_place(WORD sel,DWORD base,DWORD lim,BYTE acc,BYTE gran) |
{ |
union gdt_entry x; |
/* This is declared in [wc32/gnu]\x0.[asm/s] */ |
extern LIN_ADDR GDT_base; |
/* DWORD offset = appl2linear(&x); */ |
x.d.base_lo = (base & 0x0000FFFF); |
x.d.base_med = ((base & 0x00FF0000) >> 16); |
x.d.base_hi = ((base & 0xFF000000) >> 24); |
x.d.access = acc; |
x.d.lim_lo = (lim & 0xFFFF); |
x.d.gran = (gran | ((lim >> 16) & 0x0F) | 0x40); |
memcpy(GDT_base+(sel & ~3),&x,sizeof(union gdt_entry)); |
} |
/* This function is used to read & format the descriptor data */ |
/* Anyway is better to use the hw 386 instruction to modify */ |
/* a descriptor rather than reading,modifying & updating with */ |
/* this high level functions! */ |
DWORD GDT_read(WORD sel,DWORD *lim,BYTE *acc,BYTE *gran) |
{ |
union gdt_entry x; |
/* This is declared in [wc32/gnu]\x0.[asm/s] */ |
extern LIN_ADDR GDT_base; |
/*DWORD offset = appl2linear(&x);*/ |
DWORD base; |
memcpy(&x,GDT_base+sel,sizeof(union gdt_entry)); |
base = x.d.base_hi; |
base <<= 8; |
base |= x.d.base_med; |
base <<= 16; |
base |= x.d.base_lo; |
if (lim != NULL) { |
*lim = (x.d.gran & 0x0F); |
*lim <<= 16; |
*lim |= x.d.lim_lo; |
} |
if (acc != NULL) *acc = x.d.access; |
if (gran != NULL) *gran = x.d.gran & 0xF0; |
return(base); |
} |
/shark/trunk/Makefile |
---|
0,0 → 1,533 |
# Copyright (c) 2007 Fabio Checconi <fabio@gandalf.sssup.it> |
# |
# This is a non-recursive makefile that supports a Kbuild-like syntax |
# for input/output specification. |
# Handle the V=0|1 option. We use both a long and a short form. In |
# the short one we use the $(Q) variable prepended to shell commands |
# (e.g., $(Q)mkdir) that in quiet mode expands to @, and in verbose |
# mode expands to nothing. In the long one we have a couple of strings |
# per command, one named quiet_cmd, the other cmd, and we always echo |
# $(QS)cmd, so if $(QS) expands to quiet_ the first string is printed. |
# The first string is the quiet version of the command, the second one |
# holds the whole command. |
ifneq ($(V),1) |
Q:=@ |
QS:=quiet_ |
endif |
# Handle the make -s flag: produce no output at all... |
ifneq ($(findstring s,$(MAKEFLAGS)),) |
Q:=@ |
QS:=nothing_ |
endif |
# The variables used to generate the rules to build targets. Use |
# CROSS_COMPILE to specify the prefix to be used for the toolchain. |
ar:= $(CROSS_COMPILE)$(AR) |
as:= $(CROSS_COMPILE)$(CC) |
cc:= $(CROSS_COMPILE)$(CC) |
ld:= $(CROSS_COMPILE)$(LD) |
rm:= $(if $(RM),$(RM),rm) |
install:= $(if $(INSTALL),$(INSTALL),install) |
# As in the rules we cannot use the variables we use in the makefile, |
# because we reassign them for every directory we visit, we just try |
# to recover the information from the targets being built. Another |
# way could have been to expand the variables when generating the |
# rules, but it would have made rule generation unreadable. |
in-local:= $$(subst $$(srctree)/,,$$<) |
out-local:= $$(subst install-,,$$(subst $$(objtree)/,,$$@)) |
in-objs:= $$(filter %.o,$$^) |
# The rule patterns, in quiet and in verbose form. The verbose form is |
# used also for the actual command. |
quiet_ar_cmd := ' AR\\t$(out-local)' |
ar_cmd := $(ar) cr $$@ $(in-objs) |
quiet_cc_cmd := ' CC\\t$(in-local)' |
cc_cmd := $(cc) $$(cflags-$$(<:.c=.o)) $$(cppflags-$$(<:.c=.o))\ |
-c $$< -o $$@ |
quiet_as_cmd := ' AS\\t$(in-local)' |
as_cmd := $(as) $$(aflags-$$(<:.s=.o)) -c $$< -o $$@ |
quiet_dep_cmd := ' DEP\\t$(in-local)' |
dep_cmd := $(cc) $$(cflags-$$(<:.c=.o)) $$(cppflags-$$(<:.c=.o))\ |
-M -MT \ |
"$$(subst $$(srctree),$$(objtree),$$(<:.c=.o))\ |
$$@" $$< > $$@ 2>/dev/null |
quiet_ld-r_cmd := ' LD [R]\\t$(out-local)' |
ld-r_cmd := $(ld) $$(ldflags-$$(dir $$@)) $$(ldflags-$$@)\ |
-r $(in-objs) -o $$@ |
quiet_ld_cmd := ' LD\\t$(out-local)' |
ld_cmd := $(ld) $$(ldflags-$$(dir $$@)) $$(startup-$$@) $(in-objs)\ |
$$(ldflags-$$@) -o $$@ |
quiet_rm_cmd := ' RM\\t$$(subst clean-,,$$(subst distclean-,,$(out-local)))' |
rm_cmd := -$(rm) $$(subst clean-,,$$(subst distclean-,,$$@)) |
quiet_install_cmd := ' INSTALL $(out-local)' |
install_cmd := -$(install) $$(subst install-,,$$@) $$(installdir) |
# Generate the requested rule for the requested directory. First echo |
# the command according to the requested verbosity (suppress all the |
# output if $(QS)$(1)_cmd is not defined, i.e., in the silent make case,) |
# and then emit the actual command. |
define cmd |
$(if $($(QS)$(1)_cmd),@echo -e '$($(QS)$(1)_cmd)') |
@$($(1)_cmd) |
endef |
# Remove duplicate slashes, ../'s, trailing slashes and so on from paths. |
clean-path=$(dir $(abspath $(1)))$(notdir $(abspath $(1))) |
# Canonicalize a path, converting .. and . $(1) is the current directory, |
# and $(2) are the paths to be converted. |
to-local-path=$(subst $(1)/,,$(abspath $(addprefix $(1)/,$(2)))) |
# Keep only paths in $(1) that start with ./ (i.e., that are relative to the |
# current directory.) |
keep-local=$(foreach p, $(1),$(if $(subst ./,,$(dir $(p))),,$(p))) |
# Adjust the paths for all the prerequisites of a target. Given a list |
# of objects, with relative or absolute path, figure out the right paths |
# in the build directory. Leave the output in $(target-objs). |
define all-prerequisites-templ |
target-obj-list:=$(1) |
# Filter absolute paths. |
target-objs:=$$(filter $(srctree)/%,$$(target-obj-list)) |
target-obj-list:=$$(filter-out $$(target-objs),$$(target-obj-list)) |
# Add all the other objects, and convert the path to the $(objtree) |
# root and with a reasonable path. |
target-objs+=$$(addprefix $$(curdir)/,$$(target-obj-list)) |
target-objs:=$$(foreach dir,$$(subst $(srctree),$(objtree),$$(target-objs)),\ |
$$(call clean-path,$$(dir))) |
endef |
# Produce targets for a given library/application. |
define libapp-templ |
libapp:=$(1) |
is-app:=$(strip $(2)) |
libapp-target:=$$(objdir)/$$(libapp) |
# Get a list of all the prerequisites needed to build the library/application. |
$$(eval $$(call all-prerequisites-templ,\ |
$$(patsubst %/,%/obj.o,$$($$(libapp)-objs)))) |
$$(foreach flag,$(flags),$$(eval $$(call flags-per-target,$$(flag),$$(libapp)))) |
$$(foreach obj,$$(target-objs),\ |
$$(eval $$(call flags-per-objects,$$(obj),$$(libapp)))) |
# Produce the real target, in $(objtree), and the user-friendly target, |
# with a relative path to $(srctree). Note that even when the two trees |
# are equal we define two targets; a possible optimization could be to |
# use relative paths for the object tree in this case, but the code can |
# become even less readable than it is now... |
ifeq ($$(is-app),true) |
startup-$$(libapp-target):= $$($$(libapp)-startup) |
$$(libapp-target): $$(target-objs) |
$(call cmd,ld) |
else |
$$(libapp-target): $$(target-objs) |
$(call cmd,ar) |
endif |
short-libapp-taget:=$$(subst $$(srctree)/,,$$(curdir)/$$(libapp)) |
.PHONY: $$(short-libapp-target) |
$$(short-libapp-target): $$(libapp-target) |
# Update the $(subdirs) for $(curdir) and its target list. |
subdirs+=$$(filter %/,$$($$(libapp)-objs)) |
curdir-targets+=$$(libapp-target) |
.PHONY: clean-$$(libapp-target) |
clean-$$(libapp-target): |
$(call cmd,rm) |
curdir-clean-targets+= clean-$$(libapp-target) |
ifneq ($$(is-app),true) |
.PHONY: install-$$(libapp-target) |
install-$$(libapp-target): $$(libapp-target) |
$(call cmd,install) |
curdir-install-targets+= install-$$(libapp-target) |
endif |
endef |
# Produce the needed code for a given object. |
define obj-templ |
obj:=$(1) |
obj-target:=$$(objdir)/$$(obj) |
obj-dep:=$$(objdir)/.$$(obj:.o=.c).deps |
# Handle dependencies. |
ifeq ($(goals-have-clean),) |
$$(obj-dep): $$(objdir-prereq) |
-include $$(obj-dep) |
endif |
# Produce the user shortcut for the real target (that does not need to |
# be produced, as it is handled by implicit rules.) |
short-obj-target:= $$(subst $$(srctree)/,,$$(curdir)/$$(obj)) |
.PHONY: $$(short-obj-target) |
$$(short-obj-target): $$(obj-target) |
curdir-targets+=$$(obj-target) |
.PHONY: clean-$$(obj-target) distclean-$$(obj-dep) |
clean-$$(obj-target): |
$(call cmd,rm) |
distclean-$$(obj-dep): |
$(call cmd,rm) |
curdir-clean-targets+= clean-$$(obj-target) |
curdir-distclean-targets+= distclean-$$(obj-dep) |
ifneq ($$(filter $$(obj),$$(install-objs)),) |
.PHONY: install-$$(obj-target) |
install-$$(obj-target): $$(obj-target) |
$(call cmd,install) |
curdir-install-targets+= install-$$(obj-target) |
endif |
endef |
# Handle the flags for the current directory. for each *FLAGS variable |
# used by the implicit rules there are two variants: |
# o the local one, e.g., cflags:=-I. or cflags+=-I. changing the |
# flags used only by the current directory. |
# o The global one, e.g., exported-cflags:=-I$(srctree) changing the |
# flags for the current directory and all its subdirs. |
# The flag handling is split in three parts, one to be inserted before |
# including the current directory makefile, one before recurring into |
# subdirs, the other one after the recursion. |
define flags-save-templ |
flag:=$(1) |
# Flags on input to this dir; they must be preserved for our sibling |
# directories. |
saved-$$(flag)-$$(curdir):= $$($$(flag)) |
endef |
define flags-pre-templ |
flag:=$(1) |
# For the current directory, use the user-specified flags (that may |
# come from our parent directory.) Extra flags are used to specify |
# library-specific flags. |
$$(flag)-$$(curdir):=$$($$(flag)) $$(exported-$$(flag)) |
#to-print+= [ $$(flag)-$$(curdir) = $$($$(flag)-$$(curdir)) ] RET |
# Export to our children also the user exported flags. |
$$(flag):= $$(saved-$$(flag)-$$(curdir)) $$(exported-$$(flag)) |
exported-$$(flag):= |
endef |
define flags-post-templ |
flag:=$(1) |
# Restore the flags that our parent specified. |
$$(flag):= $$(saved-$$(flag)-$$(curdir)) |
endef |
# Allow redefinition of flags on the basis of a single target. Each |
# target gets its own version of the flags, based on the ones of the |
# current directory and its own ones. |
define flags-per-target |
flag:=$(1) |
target:=$(2) |
$$(flag)-$$(curdir)/$$(target):=$$($$(flag)-$$(curdir)) \ |
$$($$(target)-$$(flag)) $$(extra-$$(flag)-$$(curdir)/$$(target)) |
ifneq ($$(target),install-objs) |
# Those are the flags coming from the upper directories, they are set for |
# obj.o targets, we must export them to our children, so we leave them here. |
exported-$$(flag)-$$(curdir)/$$(target):= $$($$(target)-$$(flag)) \ |
$$(extra-$$(flag)-$$(curdir)/$$(target)) |
endif |
$$(target)-$$(flag):= |
endef |
define flags-per-object |
# Generate flags only for objects in the current directory, as prerequisites |
# that come from ousdide are not compiled here. |
flag:=$(1) |
target:=$(3) |
ifeq ($(dir $(subst $(objtree),$(srctree),$(2))),$$(curdir)/) |
this-obj:=$(notdir $(2)) |
# The flags for a given object are the ones specified for its target |
# plus any specific one. |
$$(flag)-$$(curdir)/$$(this-obj):= $$($$(flag)-$$(curdir)/$$(target))\ |
$$($$(this-obj)-$$(flag)) |
$$(this-obj)-$$(flag):= |
ifeq ($(3),install-objs) |
to-print+= [ $(2) $(3) ] RET |
endif |
endif |
# Pass the right flags to the subdirs we use to build $(target). |
ifeq ($$(notdir $(2)),obj.o) |
extra-$$(flag)-$(2):= $$(exported-$$(flag)-$$(curdir)/$$(target)) |
endif |
endef |
# Allow the user to specify per-object flags |
define flags-per-objects |
$$(foreach flag,$$(flags),\ |
$$(eval $$(call flags-per-object,$$(flags),$(1),$(2)))) |
endef |
# Helper to define per-library flags. |
define flags-per-libs |
$$(foreach flag,$$(flags),\ |
$$(eval $$(call flags-per-lib,$$(flags),$(1),$(2)))) |
endef |
# Disable default implicit rules. |
.SUFFIXES: |
# The roots of our source and object trees. If an O=dir option is |
# passed to the toplevel makefile all the output of the building |
# process is in dir. |
srctree:=$(call clean-path,$(CURDIR)) |
objtree:=$(if $(O),$(call clean-path,$(O)),$(srctree)) |
ifeq ($(wildcard $(objtree)),) |
$(error Output directory $(objtree) does not exist) |
endif |
clean-targets:= |
distclean-targets:= |
install-targets:= |
goals-have-clean:=$(strip $(filter clean distclean,$(MAKECMDGOALS))) |
aflags:= $(AFLAGS) |
cflags:= $(CFLAGS) |
cppflags:= $(CPPFLAGS) |
ldflags:= $(LDFLAGS) |
flags:= aflags cflags cppflags ldflags |
# XXX debug only |
to-print:= |
# The following macro is used to do a standard set of operations |
# for every subdirectory we have to work on. It is instantiated |
# every time we change subdirectory, and generates a set of targets |
# specific to that directory. |
define recurse-templ |
# Remember where we are in the source and object tree. The clean-path |
# macro is used for user output and for generating targets independently |
# from directories being specified as dir or dir/ or with multiple slashes |
# and so on. |
curdir:=$$(call clean-path,$(1)) |
objdir:=$(objtree)$$(subst $(srctree),,$$(curdir)) |
# Save the flags our parent passed us. |
$$(foreach flag,$(flags),$$(eval $$(call flags-save-templ,$$(flag)))) |
# A list of all the targets defined for the current directory. It is |
# used to produce an user-reachable target for submakes into source tree |
# subdirectories, e.g., if src/utils is a source directory, make src/utils |
# will build all the targets defined inside it. Start with the short path |
# to all subdirs. |
curdir-targets:= |
curdir-clean-targets:= |
curdir-distclean-targets:= |
curdir-install-targets:= |
install-objs:= |
# If the output directory does not exist every target that actually |
# needs it will have to create it. |
ifneq ($(objtree),$(srctree)) |
ifeq ($$(wildcard $$(objdir)),) |
objdir-prereq:=$$(objdir)/.build |
$$(objdir)/.build: |
$(Q)if [ ! -d $$(dir $$@) ] ; then \ |
mkdir -p $$(dir $$@) ; touch $$@ ; fi |
endif |
endif |
# Include the next subdirectory. Don't include the root makefile, |
# if we are at the first step of the recursion. |
include $$(subst $(srctree)/Makefile,,$$(curdir)/Makefile) |
# Figure out all the targets. We support three kind of targets: |
# - subdirectories |
# - libraries |
# - objects |
# |
# Subdirectories are recursively processed, libraries are built using |
# the objects specified in their *.a-objs target (if it contains a |
# subdirectory the latter is processed and the resulting obj.o object |
# is included,) and objects are compiled and incrementally linked |
# together in a obj.o file. |
subdirs:=$$(filter %/, $$(targets)) |
objs:=$$(filter %.o, $$(targets)) |
libs:=$$(filter %.a, $$(targets)) |
apps:=$$(filter-out $$(subdirs) $$(objs) $$(libs),$$(targets)) |
$$(eval $$(call all-prerequisites-templ, $$(subdirs))) |
subdir-targets:= $$(target-objs) |
# Recurse into all the subdirectories. |
curdir-targets+=$$(subst $(objtree)/,,$$(subdir-targets)) |
# Look for prerequisites to build obj.o for the current directory. |
$$(eval $$(call all-prerequisites-templ,\ |
$$(filter-out $$(exclude),$$(objs)))) |
target-objs+=$$(addsuffix /obj.o,$$(subdir-targets)) |
$$(foreach flag,$(flags),$$(eval $$(call flags-pre-templ,$$(flag)))) |
# Produce a target for obj.o, even if not needed (it will be empty in |
# this case.) |
ifneq ($$(strip $$(target-objs)),) |
$$(foreach flag,$(flags),$$(eval $$(call flags-per-target,$$(flag),obj.o))) |
$$(foreach obj,$$(target-objs),\ |
$$(eval $$(call flags-per-objects,$$(obj),obj.o))) |
$$(objdir)/obj.o: $$(target-objs) |
$(call cmd,ld-r) |
else |
$$(objdir)/obj.o: |
$(Q)touch $$@ |
endif |
curdir-targets+= $$(objdir)/obj.o |
# to-print+= [ [ $$(objdir)/obj.o ] $$(target-objs) ] |
# Produce the needed targets for each library. |
ifneq ($$(strip $$(libs)),) |
$$(foreach lib,$$(libs),$$(eval $$(call libapp-templ,$$(lib),false))) |
endif |
ifneq ($$(strip $$(apps)),) |
$$(foreach app,$$(apps),$$(eval $$(call libapp-templ,$$(app),true))) |
endif |
# Produce a target for each local object. Build the list of all the |
# targets specified by the current subdir. It is given by all the local |
# objects in $(targets) or in a library contained in it. Non-local |
# objects can be specified as dependencies but must be built from the |
# directory containing them (if needed their directory can specify that |
# they are not to be included in the local obj.o putting them into |
# $(exclude); this may not seem straightforward but is to support a |
# few corner cases.) |
# |
# First build a relative path for all the .o files in the targets (the |
# default one and the library ones,) taking care of not being confused |
# by relative directory specifications. |
#all-local-objs-paths:=$$(subst $$(curdir)/,,\ |
# $$(abspath $$(addprefix $$(curdir)/,\ |
# $$(objs) $$(install-objs)\ |
# $$(foreach lib,$$(libs),$$(filter %.o,$$($$(lib)-objs)))\ |
# $$(foreach app,$$(apps),$$(filter %.o,$$($$(app)-objs)))))) |
all-local-objs-paths:=$$(call to-local-path,$$(curdir),\ |
$$(objs)\ |
$$(foreach lib,$$(libs),$$(filter %.o,$$($$(lib)-objs)))\ |
$$(foreach app,$$(apps),$$(filter %.o,$$($$(app)-objs)))) |
all-local-install-objs-paths:=$$(call to-local-path,$$(curdir),\ |
$$(install-objs)) |
# Then keep only those with a dir equal to ./ A local object is not |
# allowed to be specified with a path specifying a directory different |
# from the current one. Objects to be installed are only taken into |
# account if they're local to the current directory. |
#all-local-objs:=$$(foreach obj, $$(all-local-objs-paths),\ |
# $$(if $$(subst ./,,$$(dir $$(obj))),,$$(obj))) |
all-local-install-objs:=$$(call keep-local,$$(all-local-install-objs-paths)) |
all-local-objs:=$$(call keep-local,$$(all-local-objs-paths))\ |
$$(all-local-install-objs) |
$$(eval $$(call all-prerequisites-templ,$$(all-local-install-objs))) |
$$(foreach flag,$(flags),\ |
$$(eval $$(call flags-per-target,$$(flag),install-objs))) |
$$(foreach obj,$$(target-objs),\ |
$$(eval $$(call flags-per-objects,$$(obj),install-objs))) |
# Produce one target per object, and the rules to build them along with |
# their dependencies. |
ifneq ($$(strip $$(all-local-objs)),) |
$$(foreach obj,$$(all-local-objs),$$(eval $$(call obj-templ,$$(obj)))) |
$$(objdir)/%.o: $$(curdir)/%.c |
$(call cmd,cc) |
$$(objdir)/%.o: $$(curdir)/%.s |
$(call cmd,as) |
$$(objdir)/.%.c.deps: $$(curdir)/%.c |
$(call cmd,dep) |
endif |
# Produce the user-friendly target for the source dir, depending |
# on its obj.o, libs and local objects (only if they can be built.) |
curdir-target:= $$(subst $$(srctree)/,,$$(curdir)) |
.PHONY: $$(curdir-target) |
$$(curdir-target): $$(curdir-targets) |
# Produce the clean and distclean targets for the current directory. |
.PHONY: clean-$$(curdir-target) distclean-$$(curdir-target) |
clean-$$(curdir-target): $$(curdir-clean-targets) |
distclean-$$(curdir-target): clean-$$(curdir-target) \ |
$$(curdir-distclean-targets) |
# to-print+=[ distclean-$$(curdir-target) ] |
clean-targets+= clean-$$(curdir-target) |
distclean-targets+= distclean-$$(curdir-target) |
# Produce the install target. This is very Shark specific... |
.PHONY: install-$$(curdir-target) |
$$(curdir-install-targets): $(installdir)/.build |
install-$$(curdir-target): $$(curdir-install-targets) |
install-targets+= install-$$(curdir-target) |
#to-print+=[ install-$$(curdir-target) = $$(curdir-install-targets) ] |
# Actually do the recursion, generating the code specified by |
# recurse-tmpl for every subdirectory needed from the one we are |
# leaving. |
ifneq ($$(strip $$(subdirs)),) |
$$(foreach dir,$$(subdirs),$$(eval $$(call recurse-templ,$(1)/$$(dir)))) |
curdir:=$$(call clean-path,$(1)) |
endif |
$$(foreach flag,$(flags),$$(eval $$(call flags-post-templ,$$(flag)))) |
endef |
.DEFAULT_GOAL:= all |
installdir:=$(objtree)/.lib |
# Include all the Shark specific configuration... |
include $(if $(S),$(S)/)Rules.mk |
# Let the good times roll... |
$(eval $(call recurse-templ,$(srctree))) |
all: $(srctree) |
.PHONY: clean distclean |
clean: $(clean-targets) |
distclean: $(distclean-targets) |
debug: |
@echo $(to-print) |
.PHONY: install $(install-targets) |
$(installdir)/.build: |
$(Q)if [ ! -d $(dir $@) ] ; then \ |
mkdir -p $(dir $@) ; touch $@ ; fi |
install: $(install-targets) |
/shark/trunk/drivers/makefile |
---|
File deleted |
/shark/trunk/drivers/serial/makefile |
---|
File deleted |
/shark/trunk/drivers/serial/Makefile |
---|
0,0 → 1,6 |
targets:= libserial.a |
libserial.a-objs:= scom.o scomirq.o |
cppflags+= -I$(srctree)/drivers/serial/include |
/shark/trunk/drivers/bttv/makefile |
---|
File deleted |
/shark/trunk/drivers/bttv/Makefile |
---|
0,0 → 1,13 |
targets:= libbttv.a |
libbttv.a-objs = \ |
bttv-if.o \ |
btcx-risc.o \ |
bttv-cards.o \ |
bttv-driver.o \ |
bttv-risc.o \ |
shark_bttv26.o |
cppflags+= -D__KERNEL__ -I$(srctree)/drivers/bttv/include \ |
-I$(srctree)/drivers/linuxc26/include -I$(curdir) |
/shark/trunk/drivers/cm7326/makefile |
---|
File deleted |
/shark/trunk/drivers/cm7326/Makefile |
---|
0,0 → 1,23 |
# CM7326 - Driver for pc104+ framegrabber |
ifndef BASE |
BASE=../.. |
endif |
include $(BASE)/config/config.mk |
LIBRARY = cm7326 |
OBJS_PATH = $(BASE)/drivers/cm7326 |
OBJS = cm7326.o saa7146_core.o saa7146_hlp.o saa7146_i2c.o saa7146_video.o saa7146_fops.o |
OTHERINCL += -I$(BASE)/drivers/cm7326/include -I$(BASE)/drivers/linuxc26/include -I$(BASE)/drivers/i2c/include |
C_OPT += -D__KERNEL__ |
include $(BASE)/config/lib.mk |
clean:: |
rm -f $(OBJS) |
/shark/trunk/drivers/oldsnd/makefile |
---|
File deleted |
/shark/trunk/drivers/oldsnd/blaster.h |
---|
16,7 → 16,7 |
* |
*/ |
#include "semaphore.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/oldsnd/sbio.h |
---|
16,7 → 16,7 |
* |
*/ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/oldsnd/include/drivers/dma.h |
---|
51,7 → 51,7 |
#ifndef __DRIVERS_DMA_H__ |
#define __DRIVERS_DMA_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/oldsnd/Makefile |
---|
0,0 → 1,10 |
targets:= libhsnd.a |
libhsnd.a-objs:= \ |
sbio.o \ |
blaster.o \ |
dma.o \ |
sound.o |
cppflags+= -I$(curdir)/include |
/shark/trunk/drivers/net/makefile |
---|
File deleted |
/shark/trunk/drivers/net/netbuff.h |
---|
56,7 → 56,7 |
#ifndef __NETBUFF_H__ |
#define __NETBUFF_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
#include <sem/sem/sem.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/linux/llpci.h |
---|
1,4 → 1,4 |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
extern int (*pcibios_read_config_byte) |
/shark/trunk/drivers/net/include/linux/netdevice.h |
---|
9,7 → 9,7 |
#include <linux/skbuff.h> |
#include <linux/notifier.h> |
#include <time.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/linux/stddef.h |
---|
1,7 → 1,7 |
#ifndef _LINUX_STDDEF_H |
#define _LINUX_STDDEF_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/linux/notifier.h |
---|
2,7 → 2,7 |
#define __NOTIFIER__ |
#include <linux/compatib.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/linux/kernel.h |
---|
2,7 → 2,7 |
#define __KERNEL__ |
#include <linux/compatib.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/linux/etherdevice.h |
---|
5,7 → 5,7 |
#include <linux/if_ether.h> |
#include <linux/socket.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/linux/linuxpci.h |
---|
964,7 → 964,7 |
#define PCI_DEVICE_ID_ARK_STINGARK 0xa099 |
#define PCI_DEVICE_ID_ARK_2000MT 0xa0a1 |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/* |
/shark/trunk/drivers/net/include/linux/interrupt.h |
---|
2,7 → 2,7 |
#define __INTERRUPT__ |
#include <linux/compatib.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/linux/compatib.h |
---|
1,6 → 1,6 |
#include <kernel/kern.h> |
#include <stdlib.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/linux/timer.h |
---|
52,7 → 52,7 |
#include <kernel/kern.h> |
#include <time.h> |
#include <linux/compatib.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/linux/skbuff.h |
---|
2,7 → 2,7 |
#define __SKBUFF__ |
#include <linux/compatib.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/linux/socket.h |
---|
1,7 → 1,7 |
#ifndef _LINUX_SOCKET_H |
#define _LINUX_SOCKET_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/asm/bitops.h |
---|
2,7 → 2,7 |
#define __BITOPS__ |
#include <linux/compatib.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/asm/io.h |
---|
2,7 → 2,7 |
#define __IO__ |
#include <linux/compatib.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/include/net/sock.h |
---|
56,7 → 56,7 |
#include <linux/netdevice.h> |
#include <linux/skbuff.h> /* struct sk_buff */ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/8390.h |
---|
11,7 → 11,7 |
#include <linux/if_ether.h> |
#include <linux/ioport.h> |
#include <linux/skbuff.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/eth_priv.h |
---|
57,7 → 57,7 |
#ifndef __ETH_H__ |
#define __ETH_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/arp.h |
---|
58,7 → 58,7 |
#ifndef __ARP_H__ |
#define __ARP_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/net/Makefile |
---|
0,0 → 1,20 |
targets:= libnet.a |
libnet.a-objs:= \ |
eth.o \ |
8390.o \ |
3c509.o \ |
3c59x.o \ |
eepro100.o \ |
ne.o \ |
rtl8139.o \ |
netbuff.o \ |
arp.o \ |
udpip.o \ |
net.o \ |
net_init.o \ |
skbuff.o \ |
misc.o |
cppflags+= -I$(curdir)/include -D__KERNEL__ |
/shark/trunk/drivers/cpu/makefile |
---|
File deleted |
/shark/trunk/drivers/cpu/cpufreq/Makefile |
---|
0,0 → 1,12 |
targets:= \ |
cpufreq.o \ |
freq_table.o \ |
gx-suspmod.o \ |
p4-clockmod.o \ |
powernow-k6.o \ |
powernow-k7.o \ |
powernow-k8.o \ |
speedstep-centrino.o \ |
speedstep-ich.o \ |
speedstep-lib.o |
/shark/trunk/drivers/cpu/shark/Makefile |
---|
0,0 → 1,2 |
targets:= shark_cpu.o |
/shark/trunk/drivers/cpu/Makefile |
---|
0,0 → 1,12 |
targets:= libcpu.a |
libcpu.a-objs:= \ |
common.o \ |
amd.o \ |
cyrix.o \ |
intel.o \ |
cpufreq/ \ |
shark/ \ |
exported-cppflags:= -I$(srctree)/drivers/linuxc26/include -D__KERNEL__ |
/shark/trunk/drivers/fb/makefile |
---|
File deleted |
/shark/trunk/drivers/fb/vesa.h |
---|
1,4 → 1,4 |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
typedef struct { /* Questa struttura ci serve per definire */ |
BYTE red, green, blue; /* la nostra palette. */ |
/shark/trunk/drivers/fb/gdvesa.c |
---|
1,6 → 1,6 |
#include <ll/i386/hw-data.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/string.h> |
#include <arch/i386/string.h> |
#include <ll/i386/x-dos.h> |
#include <ll/i386/x-dosmem.h> |
#include <ll/i386/cons.h> |
/shark/trunk/drivers/fb/riva/Makefile |
---|
0,0 → 1,5 |
targets:= \ |
fbdev.o \ |
nv_driver.o \ |
riva_hw.o |
/shark/trunk/drivers/fb/matrox/Makefile |
---|
0,0 → 1,11 |
targets:= \ |
g450_pll.o \ |
matroxfb_DAC1064.o \ |
matroxfb_Ti3026.o \ |
matroxfb_accel.o \ |
matroxfb_base.o \ |
matroxfb_crtc2.o \ |
matroxfb_g450.o \ |
matroxfb_maven.o \ |
matroxfb_misc.o |
/shark/trunk/drivers/fb/Makefile |
---|
0,0 → 1,27 |
targets:= libfb.a |
libfb.a-objs:= \ |
fbmem.o \ |
fbcmap.o \ |
cfbfillrect.o \ |
softcursor.o \ |
cfbcopyarea.o \ |
cfbimgblt.o \ |
modedb.o \ |
vga16fb.o \ |
vgastate.o \ |
vesafb.o \ |
radeonfb.o \ |
shark_fb26.o \ |
gdvesa.o \ |
logo.o \ |
logo_bmp.o \ |
riva/ \ |
fun16.o \ |
matrox/ |
exported-cppflags:= -I$(srctree)/drivers/linuxc26/include \ |
-I$(curdir)/include -I$(curdir) -D__KERNEL__ -D__i386__ |
exported-clfags:= $(CFG_VIDEO_OPT) |
/shark/trunk/drivers/parport/makefile |
---|
File deleted |
/shark/trunk/drivers/parport/include/drivers/parport.h |
---|
57,7 → 57,7 |
#include <kernel/types.h> |
#include <kernel/descr.h> |
#include <math.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/parport/Makefile |
---|
0,0 → 1,6 |
targets:= libpport.a |
libpport.a-objs:= ppdrv.o ppnrtdrv.o pppindrv.o |
cppflags+= -I$(srctree)/drivers/parport/include |
/shark/trunk/drivers/usb/makefile |
---|
File deleted |
/shark/trunk/drivers/usb/input/Makefile |
---|
0,0 → 1,2 |
targets:= usbmouse.o usbkbd.o |
/shark/trunk/drivers/usb/media/Makefile |
---|
0,0 → 1,6 |
targets:= \ |
pwc-if.o \ |
pwc-ctrl.o \ |
pwc-misc.o \ |
pwc-uncompress.o |
/shark/trunk/drivers/usb/serial/Makefile |
---|
0,0 → 1,6 |
targets:= \ |
generic.o \ |
usb-serial.o \ |
pl2303.o \ |
tty_io.o |
/shark/trunk/drivers/usb/shark_glue/Makefile |
---|
0,0 → 1,2 |
targets:= shark_usb.o |
/shark/trunk/drivers/usb/core/Makefile |
---|
0,0 → 1,12 |
targets:= \ |
config.o \ |
usb-debug.o \ |
hub.o \ |
hcd.o \ |
urb.o \ |
message.o \ |
file.o \ |
buffer.o \ |
driverfs.o \ |
hcd-pci.o |
/shark/trunk/drivers/usb/host/Makefile |
---|
0,0 → 1,5 |
targets:= \ |
ohci-hcd.o \ |
ehci-hcd.o \ |
uhci-hcd.o |
/shark/trunk/drivers/usb/Makefile |
---|
0,0 → 1,15 |
targets:= libusb.a |
libusb.a-objs:= \ |
core/ \ |
host/ \ |
shark_glue/ \ |
media/ \ |
input/ \ |
serial/ |
exported-cppflags:= -I$(srctree)/drivers/linuxc26/include \ |
-I$(curdir)/core -I$(curdir)/host -D__KERNEL__ \ |
-DCONFIG_USB_HIDINPUT -DCONFIG_USB_SERIAL_PL2303 \ |
-DCONFIG_USB_DEBUG |
/shark/trunk/drivers/block/makefile |
---|
File deleted |
/shark/trunk/drivers/block/sstf/sstf.h |
---|
42,7 → 42,7 |
#include "phdsk.h" |
#include "glue.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/sstf/Makefile |
---|
0,0 → 1,2 |
targets:= sstf.o |
/shark/trunk/drivers/block/fcfs/fcfs.h |
---|
42,7 → 42,7 |
#include "phdsk.h" |
#include "glue.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/fcfs/Makefile |
---|
0,0 → 1,2 |
targets:= fcfs.o |
/shark/trunk/drivers/block/glue.h |
---|
37,7 → 37,7 |
*/ |
#include <kernel/int_sem.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
136,7 → 136,7 |
/* timer functions */ |
#include <ll/time.h> |
#include <arch/time.h> |
/* all in usec */ |
/shark/trunk/drivers/block/ide.h |
---|
57,7 → 57,7 |
#include "glue.h" |
#include "bdev.h" |
#include "bqueue.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/edf/edf.h |
---|
42,7 → 42,7 |
#include "phdsk.h" |
#include "glue.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/edf/Makefile |
---|
0,0 → 1,2 |
targets:= edf.o |
/shark/trunk/drivers/block/phdsk.h |
---|
49,7 → 49,7 |
#define __PHDSK_H__ |
#include "glue.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/idereq.h |
---|
22,7 → 22,7 |
#include "bqueue.h" |
#include "glue.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/lodsk.h |
---|
50,7 → 50,7 |
#define __LODSK_H__ |
#include "glue.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/ideglue.h |
---|
18,7 → 18,7 |
#ifndef __IDEGLUE_H |
#define __IDEGLUE_H |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/look/look.h |
---|
42,7 → 42,7 |
#include "phdsk.h" |
#include "glue.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/look/Makefile |
---|
0,0 → 1,2 |
targets:= look.o |
/shark/trunk/drivers/block/pscan/pscan.h |
---|
42,7 → 42,7 |
#include "phdsk.h" |
#include "glue.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/pscan/Makefile |
---|
0,0 → 1,2 |
targets:= pscan.o |
/shark/trunk/drivers/block/bdev.h |
---|
52,7 → 52,7 |
#include "glue.h" |
#include <fs/bdevinit.h> |
#include <fs/bdev.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/clook/clook.h |
---|
43,7 → 43,7 |
#include "phdsk.h" |
#include "glue.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/clook/Makefile |
---|
0,0 → 1,2 |
targets:= clook.o |
/shark/trunk/drivers/block/debug.h |
---|
16,7 → 16,7 |
* |
*/ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/bqueue.h |
---|
74,7 → 74,7 |
#include "pscan/pscan.h" |
#endif |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/block/Makefile |
---|
0,0 → 1,35 |
_SCHED_FCFS=y |
cppflags-$(_SCHED_FCFS):= -D_SCHED_FCFS |
objs-$(_SCHED_FCFS):= fcfs/ |
cppflags-$(_SCHED_SSTF):= -D_SCHED_SSTF |
objs-$(_SCHED_SSTF):= sstf/ |
cppflags-$(_SCHED_LOOK):= -D_SCHED_LOOK |
objs-$(_SCHED_LOOK):= look/ |
cppflags-$(_SCHED_CLOOK):= -D_SCHED_CLOOK |
objs-$(_SCHED_CLOOK):= clook/ |
cppflags-$(_SCHED_EDF):= -D_SCHED_EDF |
objs-$(_SCHED_EDF):= edf/ |
cppflags-$(_SCHED_PSCAN):= -D_SCHED_PSCAN |
objs-$(_SCHED_PSCAN):= pscan/ |
targets:= libblk.a |
libblk.a-objs:= \ |
bdev.o \ |
lodsk.o \ |
phdsk.o \ |
glue.o \ |
ide.o \ |
idereq.o \ |
idelow.o \ |
$(objs-y) |
exported-cppflags:= $(cppflags-y) -DNDEBUG -I$(curdir) \ |
-imacros $(srctree)/include/fs/bdevconf.h |
/shark/trunk/drivers/pci6025e/makefile |
---|
File deleted |
/shark/trunk/drivers/pci6025e/dio_ppi/Makefile |
---|
0,0 → 1,2 |
targets:= dio_ppi.o |
/shark/trunk/drivers/pci6025e/include/drivers/pci6025e/pci6025e.h |
---|
37,7 → 37,7 |
#include "regconst.h" |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/pci6025e/include/drivers/pci6025e/timer.h |
---|
37,7 → 37,7 |
#include <drivers/pci6025e/pci6025e.h> |
#include <drivers/pci6025e/regconst.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/pci6025e/include/drivers/pci6025e/dio_ppi.h |
---|
34,7 → 34,7 |
#define _MY_DIO_H_ |
#include <drivers/pci6025e/pci6025e.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/pci6025e/include/drivers/pci6025e/adc.h |
---|
33,7 → 33,7 |
#include <drivers/pci6025e/pci6025e.h> |
#include <drivers/pci6025e/regconst.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/pci6025e/include/drivers/pci6025e/dac.h |
---|
33,7 → 33,7 |
#include <drivers/pci6025e/pci6025e.h> |
#include <drivers/pci6025e/regconst.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/pci6025e/adc/Makefile |
---|
0,0 → 1,2 |
targets:= adc.o |
/shark/trunk/drivers/pci6025e/dac/Makefile |
---|
0,0 → 1,2 |
targets:= dac.o |
/shark/trunk/drivers/pci6025e/tim/Makefile |
---|
0,0 → 1,2 |
targets:= timer.o |
/shark/trunk/drivers/pci6025e/Makefile |
---|
0,0 → 1,11 |
targets:= lib6025e.a |
lib6025e.a-objs:= \ |
pci6025e.o \ |
tim/ \ |
dac/ \ |
dio_ppi/ \ |
adc/ |
exported-cppflags:= -I$(srctree)/drivers/pci6025e/include |
/shark/trunk/drivers/input/makefile |
---|
File deleted |
/shark/trunk/drivers/input/joystick/Makefile |
---|
0,0 → 1,2 |
targets:= analog.o joydump.o |
/shark/trunk/drivers/input/keyboard/Makefile |
---|
0,0 → 1,2 |
targets:= atkbd.o |
/shark/trunk/drivers/input/serio/Makefile |
---|
0,0 → 1,2 |
targets:= serio.o i8042.o |
/shark/trunk/drivers/input/mouse/Makefile |
---|
0,0 → 1,5 |
targets:= \ |
psmouse-base.o \ |
logips2pp.o \ |
synaptics.o |
/shark/trunk/drivers/input/shark/Makefile |
---|
0,0 → 1,10 |
targets:= \ |
shark_input.o \ |
shark_keymap.o \ |
shark_mouse.o \ |
shark_keyb.o \ |
mcurtxt.o \ |
mcurgrx.o \ |
shark_spk.o \ |
shark_joy.o |
/shark/trunk/drivers/input/misc/Makefile |
---|
0,0 → 1,2 |
targets:= pcspkr.o |
/shark/trunk/drivers/input/handler/Makefile |
---|
0,0 → 1,7 |
targets:= \ |
mouse.o \ |
keyboard.o \ |
speaker.o \ |
evbug.o \ |
joystick.o |
/shark/trunk/drivers/input/Makefile |
---|
0,0 → 1,15 |
targets:= libinput.a |
libinput.a-objs:= \ |
input.o \ |
serio/ \ |
mouse/ \ |
keyboard/ \ |
misc/ \ |
gameport/ \ |
joystick/ \ |
handler/ \ |
shark/ |
exported-cppflags:= -I$(srctree)/drivers/linuxc26/include -D__KERNEL__ |
/shark/trunk/drivers/input/gameport/Makefile |
---|
0,0 → 1,2 |
targets:= gameport.o ns558.o |
/shark/trunk/drivers/grx/makefile |
---|
File deleted |
/shark/trunk/drivers/grx/include/drivers/gd.h |
---|
54,7 → 54,7 |
#include <ll/sys/types.h> |
/* Std 16 colors... are in cons.h !!!*/ |
#include <ll/i386/cons.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/grx/include/drivers/glib.h |
---|
54,7 → 54,7 |
#include <ll/sys/types.h> |
#include <drivers/gd.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/grx/drawfun/fun16.c |
---|
19,7 → 19,7 |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/mem.h> |
#include <ll/stdlib.h> |
#include <arch/stdlib.h> |
#include <drivers/gd.h> |
/shark/trunk/drivers/grx/drawfun/fun8.c |
---|
19,7 → 19,7 |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/mem.h> |
#include <ll/stdlib.h> |
#include <arch/stdlib.h> |
#include <drivers/gd.h> |
/shark/trunk/drivers/grx/drawfun/fun16.h |
---|
16,7 → 16,7 |
* |
*/ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
#define memsetw(addr, val, n) {LIN_ADDR i; for(i = addr; i < addr + n; i += 2) lmempokew(i, val);} |
/shark/trunk/drivers/grx/drawfun/fun8.h |
---|
16,7 → 16,7 |
* |
*/ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
void RdWin_256(WORD x1, WORD y1, WORD x2, WORD y2, BYTE *buf); |
/shark/trunk/drivers/grx/drawfun/Makefile |
---|
0,0 → 1,2 |
targets:= fun16.o fun8.o |
/shark/trunk/drivers/grx/Makefile |
---|
0,0 → 1,10 |
targets:= libgrx.a |
libgrx.a-objs:= \ |
gd.o glib.o \ |
palette.o \ |
drivers/ \ |
drawfun/ |
exported-cppflags:= -I$(curdir)/include/ |
/shark/trunk/drivers/grx/drivers/trident.h |
---|
16,7 → 16,7 |
* |
*/ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
int trident_test(void); |
/shark/trunk/drivers/grx/drivers/vesa.h |
---|
17,7 → 17,7 |
*/ |
#include <ll/i386/x-dos.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/grx/drivers/gdvesa.c |
---|
18,7 → 18,7 |
#include <ll/i386/hw-data.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/string.h> |
#include <arch/i386/string.h> |
#include <ll/i386/x-dos.h> |
#include <ll/i386/x-dosmem.h> |
#include <ll/i386/cons.h> |
/shark/trunk/drivers/grx/drivers/gdvesa1.c |
---|
18,7 → 18,7 |
#include <ll/i386/hw-data.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/string.h> |
#include <arch/i386/string.h> |
#include <ll/i386/x-dos.h> |
#include <ll/i386/x-dosmem.h> |
#include <ll/i386/cons.h> |
/shark/trunk/drivers/grx/drivers/s3.h |
---|
16,7 → 16,7 |
* |
*/ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
int s3_test(void); |
/shark/trunk/drivers/grx/drivers/Makefile |
---|
0,0 → 1,2 |
targets:= gdvesa.o gds3.o gdtrid.o |
/shark/trunk/drivers/grx/glib.c |
---|
18,7 → 18,7 |
#include <ll/i386/hw-data.h> |
#include <ll/i386/mem.h> |
#include <ll/i386/string.h> |
#include <arch/i386/string.h> |
#include <ll/i386/error.h> |
#include <ll/sys/ll/ll-func.h> |
/shark/trunk/drivers/cons/makefile |
---|
File deleted |
/shark/trunk/drivers/cons/cons1.c |
---|
25,10 → 25,10 |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/cons.h> |
/* #include <xsys.h>*/ |
#include <ll/i386/string.h> |
#include <ll/i386/stdlib.h> |
#include <ll/i386/stdio.h> |
#include <ll/stdarg.h> |
#include <arch/i386/string.h> |
#include <arch/i386/stdlib.h> |
#include <arch/i386/stdio.h> |
#include <arch/stdarg.h> |
FILE(Cons1); |
/* CGA compatible registers value */ |
/shark/trunk/drivers/cons/cons2.c |
---|
25,10 → 25,10 |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/cons.h> |
/* #include <xsys.h>*/ |
#include <ll/i386/string.h> |
#include <ll/i386/stdlib.h> |
#include <ll/i386/stdio.h> |
#include <ll/stdarg.h> |
#include <arch/i386/string.h> |
#include <arch/i386/stdlib.h> |
#include <arch/i386/stdio.h> |
#include <arch/stdarg.h> |
FILE(Cons2); |
/shark/trunk/drivers/cons/message.c |
---|
24,10 → 24,10 |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/string.h> |
#include <ll/i386/stdlib.h> |
#include <ll/i386/stdio.h> |
#include <ll/stdarg.h> |
#include <arch/i386/string.h> |
#include <arch/i386/stdlib.h> |
#include <arch/i386/stdio.h> |
#include <arch/stdarg.h> |
FILE(message); |
/shark/trunk/drivers/cons/cprintf.c |
---|
24,10 → 24,10 |
#include <ll/i386/hw-data.h> |
#include <ll/i386/hw-instr.h> |
#include <ll/i386/cons.h> |
#include <ll/i386/string.h> |
#include <ll/i386/stdlib.h> |
#include <ll/i386/stdio.h> |
#include <ll/stdarg.h> |
#include <arch/i386/string.h> |
#include <arch/i386/stdlib.h> |
#include <arch/i386/stdio.h> |
#include <arch/stdarg.h> |
FILE(cprintf); |
/shark/trunk/drivers/cons/crtwin.c |
---|
60,7 → 60,7 |
//#include <cons.h> |
#include <kernel/kern.h> |
#include <ll/string.h> |
#include <arch/string.h> |
#include <drivers/crtwin.h> |
#define CUPS1 201 /* Definizione caratteri per */ |
/shark/trunk/drivers/cons/Makefile |
---|
0,0 → 1,11 |
targets:= libcons.a |
libcons.a-objs:= \ |
cons1.o \ |
cons2.o \ |
message.o \ |
cprintf.o \ |
crtwin.o |
cppflags+= -I$(srctree)/drivers/cons/include |
/shark/trunk/drivers/pcl812/makefile |
---|
File deleted |
/shark/trunk/drivers/pcl812/include/drivers/pclab.h |
---|
3,7 → 3,7 |
/* le funzioni di aquisizione contenute in PCLAB.C */ |
/*--------------------------------------------------------------*/ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/pcl812/Makefile |
---|
0,0 → 1,4 |
targets:= libpclab.a |
libpclab.a-objs:= pclab.o |
/shark/trunk/drivers/linuxc26/makefile |
---|
File deleted |
/shark/trunk/drivers/linuxc26/kobject.c |
---|
12,7 → 12,7 |
#undef DEBUG |
#include <ll/stdarg.h> |
#include <arch/stdarg.h> |
#include <linuxcomp.h> |
/shark/trunk/drivers/linuxc26/Makefile |
---|
0,0 → 1,24 |
targets:= libcomp26.a |
libcomp26.a-objs:= \ |
bus.o \ |
linuxcomp.o \ |
core.o \ |
driver.o \ |
vsprintf.o \ |
interface.o \ |
kobject.o \ |
shark_linuxc26.o \ |
shark_glue.o \ |
class.o \ |
videodev.o \ |
linux_kthread.o \ |
waitqueue.o \ |
int.o \ |
timer.o \ |
cmdline.o \ |
video-buf.o \ |
shark_videodev.o |
cppflags+= -I$(srctree)/drivers/linuxc26/include -D__KERNEL__ |
/shark/trunk/drivers/pci/makefile |
---|
File deleted |
/shark/trunk/drivers/pci/Makefile |
---|
0,0 → 1,29 |
targets:= libpci.a |
libpci.a-objs:= \ |
access.o \ |
bus.o \ |
names.o \ |
pci.o \ |
pci-driver.o \ |
pool.o \ |
probe.o \ |
quirks.o \ |
remove.o \ |
search.o \ |
setup-res.o \ |
setup-irq.o \ |
setup-bus.o \ |
syscall.o \ |
i386.o \ |
common.o \ |
fixup.o \ |
irq.o \ |
legacy.o \ |
pcbios.o \ |
direct.o \ |
shark_pci26.o \ |
pci20to26.o |
cppflags+= -I$(srctree)/drivers/linuxc26/include -D__KERNEL__ |
/shark/trunk/drivers/oldchar/makefile |
---|
File deleted |
/shark/trunk/drivers/oldchar/8042.h |
---|
63,7 → 63,7 |
#ifndef __8042_H__ |
#define __8042_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/oldchar/include/drivers/mouse.h |
---|
76,7 → 76,7 |
#include <kernel/const.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/oldchar/ps2mouse.h |
---|
59,7 → 59,7 |
#define __PS2MOUSE_H__ |
#include <drivers/mouse.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/oldchar/sermouse.h |
---|
59,7 → 59,7 |
#define __SERMOUSE_H__ |
#include <drivers/mouse.h> |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/oldchar/_mouse.h |
---|
52,7 → 52,7 |
#ifndef ___MOUSE_H__ |
#define ___MOUSE_H__ |
#include "ll/sys/cdefs.h" |
#include <arch/sys/cdefs.h> |
__BEGIN_DECLS |
/shark/trunk/drivers/oldchar/Makefile |
---|
0,0 → 1,13 |
targets:= liboldch.a |
liboldch.a-objs:= \ |
keyb.o \ |
mouse.o \ |
ps2mouse.o \ |
8042.o \ |
mcurtxt.o \ |
mcurgrx.o |
cppflags+= -I$(srctree)/drivers/oldchar/include \ |
-I$(srctree)/drivers/grx/include |
/shark/trunk/drivers/pcl833/makefile |
---|
File deleted |
/shark/trunk/drivers/pcl833/Makefile |
---|
0,0 → 1,6 |
targets:= libpcl833.a |
libpcl833.a-objs:= pcl833.o |
cppflags+= -I$(curdir)/include |
/shark/trunk/drivers/i2c/makefile |
---|
File deleted |
/shark/trunk/drivers/i2c/algos/Makefile |
---|
0,0 → 1,2 |
targets:= i2c-algo-bit.o |
/shark/trunk/drivers/i2c/Makefile |
---|
0,0 → 1,10 |
targets:= libi2c.a |
libi2c.a-objs:= \ |
i2c-dev.o \ |
i2c-core.o \ |
shark_i2c26.o \ |
algos/ |
exported-cppflags:= -I$(srctree)/drivers/linuxc26/include -D__KERNEL__ |
/shark/trunk/drivers/Makefile |
---|
0,0 → 1,21 |
targets:= \ |
block/ \ |
bttv/ \ |
cons/ \ |
cpu/ \ |
fb/ \ |
grx/ \ |
i2c/ \ |
input/ \ |
linuxc26/ \ |
net/ \ |
oldchar/ \ |
oldsnd/ \ |
parport/ \ |
pci/ \ |
pci6025e/ \ |
pcl812/ \ |
pcl833/ \ |
serial/ \ |
usb/ |