mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.11.10
This commit is contained in:
@@ -36,13 +36,15 @@ Step 1: Do some background work
|
||||
anything in Steps 2 and beyond!
|
||||
|
||||
If you are not familiar with calc internals, we recommend that
|
||||
you look at some examples of custom functions. Check out
|
||||
you look at some examples of custom functions. Look at the
|
||||
the following source files:
|
||||
|
||||
custom.c
|
||||
custom.h
|
||||
custom/custom.h
|
||||
custom/custtbl.c
|
||||
custom/c_*.[ch]
|
||||
custom/*.cal
|
||||
help/custom (or run: calc help custom)
|
||||
|
||||
You would be well advised to look at a more recent calc source
|
||||
@@ -83,14 +85,15 @@ Step 3: Document your custom function
|
||||
|
||||
Take a look at one of the example custom help files:
|
||||
|
||||
devnull
|
||||
argv
|
||||
help
|
||||
sysinfo
|
||||
custom/devnull
|
||||
custom/argv
|
||||
custom/help
|
||||
custom/sysinfo
|
||||
|
||||
You can save time by using one of the custom help files
|
||||
as a template. Copy one of these files to your own help file:
|
||||
|
||||
cd custom
|
||||
cp sysinfo curds
|
||||
|
||||
and edit it accordingly.
|
||||
@@ -107,15 +110,16 @@ Step 4: Write your test code
|
||||
test code will be an import part of your submission. Your test
|
||||
code will also service as additional for your custom function.
|
||||
|
||||
Coops ... we said we would stop preaching, sorry about that ...
|
||||
Oops ... we said we would stop preaching, sorry about that ...
|
||||
|
||||
You can use one of the following as a template:
|
||||
|
||||
argv.cal
|
||||
halflen.cal
|
||||
custom/argv.cal
|
||||
custom/halflen.cal
|
||||
|
||||
Copy one of these to your own file:
|
||||
|
||||
cd custom
|
||||
cp halflen.cal curds.cal
|
||||
|
||||
and exit it accordingly. In particular you will want to:
|
||||
@@ -152,6 +156,7 @@ Step 5: Write your custom function
|
||||
We recommend that you use one of the c_*.c files as a template.
|
||||
Copy an appropriate file to your file:
|
||||
|
||||
cd custom
|
||||
cp c_argv.c u_curds.c
|
||||
|
||||
Before you edit it, you should note that there are several important
|
||||
@@ -179,9 +184,6 @@ Step 5: Write your custom function
|
||||
VALUE
|
||||
u_curds(char *name, int count, VALUE **vals)
|
||||
|
||||
The /*ARGSUSED*/ may be needed if you do not make use
|
||||
of all 3 function parameters.
|
||||
|
||||
The 3 args are passed in by the custom interface
|
||||
and have the following meaning:
|
||||
|
||||
@@ -222,6 +224,15 @@ Step 5: Write your custom function
|
||||
vals[1] points to b
|
||||
vals[2] points to c
|
||||
|
||||
NOTE: If you do not use any of the 3 function parameters,
|
||||
then you should declare that function parameter to be UNUSED.
|
||||
For example, if the count and vals parameters were not used
|
||||
in your custom function, then your declaraction should be:
|
||||
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
u_curds(char *name, int UNUSED count, VALUE UNUSED **vals)
|
||||
|
||||
c) The return value is the function must be a VALUE.
|
||||
|
||||
The typical way to form a VALUE to return is by declaring
|
||||
@@ -239,6 +250,8 @@ Step 5: Write your custom function
|
||||
#include "../value.h"
|
||||
#include "custom.h"
|
||||
|
||||
#include "../have_unused.h"
|
||||
|
||||
Typically these will be included just below any system
|
||||
includes and just below the #if defined(CUSTOM) line.
|
||||
|
||||
@@ -362,7 +375,7 @@ Step 6: Register the function in the custom interface table
|
||||
|
||||
To allow the custom() builtin to transfer control to your function,
|
||||
you need to add an entry into the CONST struct custom cust table
|
||||
found in custtbl.c:
|
||||
found in custom/custtbl.c:
|
||||
|
||||
/*
|
||||
* custom interface table
|
||||
@@ -482,10 +495,10 @@ Step 6: Register the function in the custom interface table
|
||||
extern VALUE u_curds(char*, int, VALUE**);
|
||||
|
||||
|
||||
Step 7: Add the required information to the Makefile
|
||||
Step 7: Add the required information to the custom/Makefile
|
||||
|
||||
The calc test script, curds.cal, should be added to the
|
||||
CUSTOM_CALC_FILES Makefile variable:
|
||||
CUSTOM_CALC_FILES Makefile variable found in custom/Makefile:
|
||||
|
||||
CUSTOM_CALC_FILES= argv.cal halflen.cal curds.cal
|
||||
|
||||
@@ -619,7 +632,7 @@ Step 12: Contribute
|
||||
and consider submitting your custom function for possible
|
||||
inclusion in later versions of calc.
|
||||
|
||||
## Copyright (C) 1999 Landon Curt Noll
|
||||
## Copyright (C) 1999-2004 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -635,8 +648,8 @@ Step 12: Contribute
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: HOW_TO_ADD,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: HOW_TO_ADD,v 29.4 2004/07/29 08:38:05 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/HOW_TO_ADD,v $
|
||||
##
|
||||
## Under source code control: 1997/03/10 03:03:21
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# custom - makefile for calc custom routines
|
||||
#
|
||||
# Copyright (C) 1999 Landon Curt Noll
|
||||
# Copyright (C) 1999,2004 Landon Curt Noll
|
||||
#
|
||||
# Calc is open software; you can redistribute it and/or modify it under
|
||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.21 $
|
||||
# @(#) $Id: Makefile,v 29.21 2004/02/23 09:23:08 chongo Exp $
|
||||
# @(#) $Revision: 29.24 $
|
||||
# @(#) $Id: Makefile,v 29.24 2004/07/29 08:38:18 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/03/09 02:28:54
|
||||
@@ -40,13 +40,13 @@
|
||||
#
|
||||
# Put your custom calc resource files here.
|
||||
#
|
||||
CUSTOM_CALC_FILES= argv.cal halflen.cal pzasusb8.cal
|
||||
CUSTOM_CALC_FILES= argv.cal halflen.cal pzasusb8.cal pmodm127.cal
|
||||
|
||||
# The custom help files to install
|
||||
#
|
||||
# Put your custom help files here.
|
||||
#
|
||||
CUSTOM_HELP= argv devnull help sysinfo pzasusb8
|
||||
CUSTOM_HELP= argv devnull help sysinfo pzasusb8 pmodm127
|
||||
|
||||
# Any .h files that are needed by programs that use libcustcalc.a
|
||||
#
|
||||
@@ -62,7 +62,7 @@ CUSTOM_H_SRC=
|
||||
#
|
||||
# Put your custom .c files here.
|
||||
#
|
||||
CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c c_pzasusb8.c
|
||||
CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c c_pzasusb8.c c_pmodm127.c
|
||||
|
||||
# Any .o files that are needed by program that use libcustcalc.a.
|
||||
# Don't put ${REQUIRED_OBJ} files in this list.
|
||||
@@ -71,7 +71,7 @@ CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c c_pzasusb8.c
|
||||
#
|
||||
# Put your custom .o files here.
|
||||
#
|
||||
CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o c_pzasusb8.o
|
||||
CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o c_pzasusb8.o c_pmodm127.o
|
||||
|
||||
##############################################################################
|
||||
#-=-=-=-=-=-=- Defaults in case you want to build from this dir -=-=-=-=-=-=-#
|
||||
@@ -831,6 +831,33 @@ c_help.o: ../value.h
|
||||
c_help.o: ../win32dll.h
|
||||
c_help.o: ../zmath.h
|
||||
c_help.o: c_help.c
|
||||
c_pmodm127.o: ../alloc.h
|
||||
c_pmodm127.o: ../block.h
|
||||
c_pmodm127.o: ../byteswap.h
|
||||
c_pmodm127.o: ../calcerr.h
|
||||
c_pmodm127.o: ../cmath.h
|
||||
c_pmodm127.o: ../config.h
|
||||
c_pmodm127.o: ../custom.h
|
||||
c_pmodm127.o: ../endian_calc.h
|
||||
c_pmodm127.o: ../hash.h
|
||||
c_pmodm127.o: ../have_const.h
|
||||
c_pmodm127.o: ../have_malloc.h
|
||||
c_pmodm127.o: ../have_memmv.h
|
||||
c_pmodm127.o: ../have_newstr.h
|
||||
c_pmodm127.o: ../have_stdlib.h
|
||||
c_pmodm127.o: ../have_string.h
|
||||
c_pmodm127.o: ../have_unused.h
|
||||
c_pmodm127.o: ../longbits.h
|
||||
c_pmodm127.o: ../md5.h
|
||||
c_pmodm127.o: ../nametype.h
|
||||
c_pmodm127.o: ../qmath.h
|
||||
c_pmodm127.o: ../shs.h
|
||||
c_pmodm127.o: ../shs1.h
|
||||
c_pmodm127.o: ../string.h
|
||||
c_pmodm127.o: ../value.h
|
||||
c_pmodm127.o: ../win32dll.h
|
||||
c_pmodm127.o: ../zmath.h
|
||||
c_pmodm127.o: c_pmodm127.c
|
||||
c_pzasusb8.o: ../alloc.h
|
||||
c_pzasusb8.o: ../block.h
|
||||
c_pzasusb8.o: ../byteswap.h
|
||||
@@ -879,7 +906,6 @@ c_sysinfo.o: ../have_string.h
|
||||
c_sysinfo.o: ../have_unused.h
|
||||
c_sysinfo.o: ../hist.h
|
||||
c_sysinfo.o: ../longbits.h
|
||||
c_sysinfo.o: ../longlong.h
|
||||
c_sysinfo.o: ../md5.h
|
||||
c_sysinfo.o: ../nametype.h
|
||||
c_sysinfo.o: ../prime.h
|
||||
|
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: argv.cal,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: argv.cal,v 29.3 2004/03/31 05:03:02 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/argv.cal,v $
|
||||
*
|
||||
* Under source code control: 1997/03/10 00:27:17
|
||||
@@ -34,9 +34,14 @@
|
||||
* NOTE: You must use a calc that was compiled with ALLOW_CUSTOM= -DCUSTOM
|
||||
* and run with a -C arg.
|
||||
*/
|
||||
if (config("compile_custom") == 0) {
|
||||
quit "calc compiled without -DCUSTOM";
|
||||
} else if (config("allow_custom") == 0) {
|
||||
quit "calc was run without the -D command line option";
|
||||
}
|
||||
|
||||
|
||||
define argv()
|
||||
define argv_test()
|
||||
{
|
||||
local i; /* arg number */
|
||||
local junk; /* throw away value */
|
||||
@@ -54,7 +59,3 @@ define argv()
|
||||
}
|
||||
return i-1;
|
||||
}
|
||||
|
||||
if (config("resource_debug") >= 0) {
|
||||
print "argv(var, ...) defined";
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_argv - a custom function display info about its args
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2004 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: c_argv.c,v 29.3 2004/02/23 09:19:18 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: c_argv.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_argv.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 20:27:37
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_devnull - a custom function that does nothing
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2004 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: c_devnull.c,v 29.3 2004/02/23 09:19:18 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: c_devnull.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_devnull.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 17:49:12
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_help - custom help function
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999-2004 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: c_help.c,v 29.3 2004/02/23 09:19:18 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: c_help.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_help.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 05:25:41
|
||||
|
272
custom/c_pmodm127.c
Normal file
272
custom/c_pmodm127.c
Normal file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* c_pmodm127 - calculate q mod 2^(2^127-1)
|
||||
*
|
||||
* Copyright (C) 2004 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: c_pmodm127.c,v 29.3 2004/07/29 09:48:31 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_pmodm127.c,v $
|
||||
*
|
||||
* Under source code control: 2004/07/28 22:12:25
|
||||
* File existed as early as: 2004
|
||||
*
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CUSTOM)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../have_const.h"
|
||||
#include "../value.h"
|
||||
#include "../custom.h"
|
||||
#include "../zmath.h"
|
||||
|
||||
#include "../have_unused.h"
|
||||
|
||||
/* 2^255 */
|
||||
static HALF h255[] = {
|
||||
#if BASEB == 32
|
||||
(HALF)0x00000000, (HALF)0x00000000, (HALF)0x00000000, (HALF)0x00000000,
|
||||
(HALF)0x00000000, (HALF)0x00000000, (HALF)0x00000000, (HALF)0x80000000
|
||||
#else /* BASEB == 32 */
|
||||
(HALF)0x0000, (HALF)0x0000, (HALF)0x0000, (HALF)0x0000,
|
||||
(HALF)0x0000, (HALF)0x0000, (HALF)0x0000, (HALF)0x0000,
|
||||
(HALF)0x0000, (HALF)0x0000, (HALF)0x0000, (HALF)0x0000,
|
||||
(HALF)0x0000, (HALF)0x0000, (HALF)0x0000, (HALF)0x8000
|
||||
#endif /* BASEB == 32 */
|
||||
};
|
||||
ZVALUE p255 = {
|
||||
h255, 8, 0
|
||||
};
|
||||
|
||||
|
||||
/* static declarations */
|
||||
static void zmod5_or_zmod(ZVALUE *zp);
|
||||
static BOOL havelastmod = FALSE;
|
||||
static ZVALUE lastmod[1];
|
||||
static ZVALUE lastmodinv[1];
|
||||
|
||||
|
||||
/*
|
||||
* c_pmodm127 - calculate q mod 2^(2^127-1)
|
||||
*
|
||||
* given:
|
||||
* count = 1;
|
||||
* vals[0] real number; (q - potential factor)
|
||||
*
|
||||
* returns:
|
||||
* result real number; (q mod 2^(2^127-1))
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
VALUE
|
||||
c_pmodm127(char UNUSED *name, int UNUSED count, VALUE **vals)
|
||||
{
|
||||
VALUE result; /* what we will return */
|
||||
ZVALUE q; /* test factor */
|
||||
ZVALUE temp; /* temp calculation value */
|
||||
int i; /* exponent value */
|
||||
|
||||
/*
|
||||
* arg check
|
||||
*/
|
||||
result.v_type = V_NULL;
|
||||
if (vals[0]->v_type != V_NUM) {
|
||||
math_error("Non-numeric argument for pmodm127");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (qisfrac(vals[0]->v_num)) {
|
||||
math_error("Non-integer argument for pmodm127");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
if (qisneg(vals[0]->v_num) || qiszero(vals[0]->v_num)) {
|
||||
math_error("argument for pmodm127 <= 0");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
/*
|
||||
* look at the numerator
|
||||
*/
|
||||
q = vals[0]->v_num->num;
|
||||
|
||||
/*
|
||||
* setup lastmod with q
|
||||
*/
|
||||
if (havelastmod && zcmp(q, *lastmod)) {
|
||||
zfree(*lastmod);
|
||||
zfree(*lastmodinv);
|
||||
havelastmod = FALSE;
|
||||
}
|
||||
if (!havelastmod) {
|
||||
zcopy(q, lastmod);
|
||||
zbitvalue(2 * q.len * BASEB, &temp);
|
||||
zquo(temp, q, lastmodinv, 0);
|
||||
zfree(temp);
|
||||
havelastmod = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* start with 2^255
|
||||
*/
|
||||
result.v_num = qalloc();
|
||||
zcopy(p255, &result.v_num->num);
|
||||
result.v_type = V_NUM;
|
||||
|
||||
/*
|
||||
* compute 2^(2^127-1) mod q by modular exponentation
|
||||
*
|
||||
* We implement the following calc code in C:
|
||||
*
|
||||
* (* given q, our test factor, as the arg to this function *)
|
||||
* result = 2^255;
|
||||
* for (i=8; i < 127; ++i) {
|
||||
* result %= q; (* mod *)
|
||||
* result *= result; (* square *)
|
||||
* result <<= 1; (* times 2 *)
|
||||
* }
|
||||
* result %= q; (* result is now 2^(2^127-1) % q *)
|
||||
*/
|
||||
for (i=8; i<127; ++i) {
|
||||
#if 0
|
||||
/* use of zmod is a bit slower than zmod5_or_zmod */
|
||||
(void) zmod(result.v_num->num, *lastmod, &temp, 0);
|
||||
zfree(result.v_num->num);
|
||||
result.v_num->num = temp;
|
||||
#else
|
||||
zmod5_or_zmod(&result.v_num->num); /* mod */
|
||||
#endif
|
||||
#if 0
|
||||
/* use of zmul is slightly slower than zsquare */
|
||||
zmul(result.v_num->num, result.v_num->num, &temp); /* square */
|
||||
#else
|
||||
zsquare(result.v_num->num, &temp); /* square */
|
||||
#endif
|
||||
/* XXX - we could manually shift to speed up a tiny bit */
|
||||
zfree(result.v_num->num);
|
||||
zshift(temp, 1, &result.v_num->num); /* times 2 */
|
||||
zfree(temp);
|
||||
}
|
||||
zmod5_or_zmod(&result.v_num->num); /* result = 2^(2^127-1) % q */
|
||||
|
||||
/*
|
||||
* cleanup and return result
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* zmod5_or_zmod - fast integer modulo the modulus computation
|
||||
*
|
||||
* "borrowed" from ../zmod.c
|
||||
*
|
||||
* Given the address of a positive integer whose word count does not
|
||||
* exceed twice that of the modulus stored at lastmod, to evaluate and store
|
||||
* at that address the value of the integer modulo the modulus.
|
||||
*
|
||||
* Unlike the static routine in ../zmod.c, we will call the zmod and return
|
||||
* the result of the zmod5_or_zmod conditions do not apply to the argument
|
||||
* and saved mod.
|
||||
*/
|
||||
static void
|
||||
zmod5_or_zmod(ZVALUE *zp)
|
||||
{
|
||||
LEN len, modlen, j;
|
||||
ZVALUE tmp1, tmp2;
|
||||
ZVALUE z1, z2, z3;
|
||||
HALF *a, *b;
|
||||
FULL f;
|
||||
HALF u;
|
||||
|
||||
int subcount = 0;
|
||||
|
||||
if (zrel(*zp, *lastmod) < 0)
|
||||
return;
|
||||
modlen = lastmod->len;
|
||||
len = zp->len;
|
||||
z1.v = zp->v + modlen - 1;
|
||||
z1.len = len - modlen + 1;
|
||||
z1.sign = z2.sign = z3.sign = 0;
|
||||
if (z1.len > modlen + 1) {
|
||||
/* in ../zmod.c we did a math_error("Bad call to zmod5!!!"); */
|
||||
/* here we just call the slower zmod and return the result */
|
||||
(void) zmod(*zp, *lastmod, &tmp1, 0);
|
||||
/* replace zp with tmp1 mod result */
|
||||
zfree(*zp);
|
||||
*zp = tmp1;
|
||||
return;
|
||||
}
|
||||
z2.v = lastmodinv->v + modlen + 1 - z1.len;
|
||||
z2.len = lastmodinv->len - modlen - 1 + z1.len;
|
||||
zmul(z1, z2, &tmp1);
|
||||
z3.v = tmp1.v + z1.len;
|
||||
z3.len = tmp1.len - z1.len;
|
||||
if (z3.len > 0) {
|
||||
zmul(z3, *lastmod, &tmp2);
|
||||
j = modlen;
|
||||
a = zp->v;
|
||||
b = tmp2.v;
|
||||
u = 0;
|
||||
len = modlen;
|
||||
while (j-- > 0) {
|
||||
f = (FULL) *a - (FULL) *b++ - (FULL) u;
|
||||
*a++ = (HALF) f;
|
||||
u = - (HALF) (f >> BASEB);
|
||||
}
|
||||
if (z1.len > 1) {
|
||||
len++;
|
||||
if (tmp2.len > modlen)
|
||||
f = (FULL) *a - (FULL) *b - (FULL) u;
|
||||
else
|
||||
f = (FULL) *a - (FULL) u;
|
||||
*a++ = (HALF) f;
|
||||
}
|
||||
while (len > 0 && *--a == 0)
|
||||
len--;
|
||||
zp->len = len;
|
||||
zfree(tmp2);
|
||||
}
|
||||
zfree(tmp1);
|
||||
while (len > 0 && zrel(*zp, *lastmod) >= 0) {
|
||||
subcount++;
|
||||
if (subcount > 2) {
|
||||
math_error("Too many subtractions in zmod5_or_zmod");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
j = modlen;
|
||||
a = zp->v;
|
||||
b = lastmod->v;
|
||||
u = 0;
|
||||
while (j-- > 0) {
|
||||
f = (FULL) *a - (FULL) *b++ - (FULL) u;
|
||||
*a++ = (HALF) f;
|
||||
u = - (HALF) (f >> BASEB);
|
||||
}
|
||||
if (len > modlen) {
|
||||
f = (FULL) *a - (FULL) u;
|
||||
*a++ = (HALF) f;
|
||||
}
|
||||
while (len > 0 && *--a == 0)
|
||||
len--;
|
||||
zp->len = len;
|
||||
}
|
||||
if (len == 0)
|
||||
zp->len = 1;
|
||||
}
|
||||
|
||||
#endif /* CUSTOM */
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_pzasusb8 - print numereator as a string of USB8s
|
||||
*
|
||||
* Copyright (C) 1999 Ernest Bowen
|
||||
* Copyright (C) 1999-2004 Ernest Bowen
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: c_pzasusb8.c,v 29.3 2004/02/23 09:19:18 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: c_pzasusb8.c,v 29.4 2004/02/23 14:04:01 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_pzasusb8.c,v $
|
||||
*
|
||||
* Under source code control: 1999/10/06 03:12:25
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* c_sysinfo - names and values of selected #defines
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2004 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.7 $
|
||||
* @(#) $Id: c_sysinfo.c,v 29.7 2004/02/23 09:19:18 chongo Exp $
|
||||
* @(#) $Revision: 29.10 $
|
||||
* @(#) $Id: c_sysinfo.c,v 29.10 2004/03/31 05:02:10 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/c_sysinfo.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 23:14:40
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "../calc.h"
|
||||
#include "../longbits.h"
|
||||
#define CHECK_L_FORMAT
|
||||
#include "../longlong.h"
|
||||
#include "../block.h"
|
||||
#include "../calcerr.h"
|
||||
#include "../conf.h"
|
||||
@@ -104,7 +103,6 @@ static struct infoname sys_info[] = {
|
||||
{"INIT_K", "initial 2nd walking a55 table index", NULL, (FULL)INIT_K},
|
||||
{"INODE_BITS", "inode number size in bits", NULL, (FULL)INODE_BITS},
|
||||
{"LITTLE_ENDIAN", "Least Significant Byte first symbol", NULL, (FULL)LITTLE_ENDIAN},
|
||||
{"LONGLONG_BITS", "length of a long long, or 0", NULL, (FULL)LONGLONG_BITS},
|
||||
{"LONG_BITS", "bit length of a long", NULL, (FULL)LONG_BITS},
|
||||
{"MAP_POPCNT", "number of odd primes in pr_map", NULL, (FULL)MAP_POPCNT},
|
||||
{"MAX_CALCRC", "maximum allowed length of $CALCRC", NULL, (FULL)MAX_CALCRC},
|
||||
@@ -317,30 +315,16 @@ dump_name_value(void)
|
||||
/* dump the entire table */
|
||||
for (p = sys_info; p->name != NULL; ++p) {
|
||||
if (p->str == NULL) {
|
||||
#if LONG_BITS == FULL_BITS || FULL_BITS == 32 || !defined(HAVE_LONGLONG)
|
||||
#if LONG_BITS == FULL_BITS || FULL_BITS == 32
|
||||
printf("%s%-23s\t%-8lu\t(0x%lx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->name,
|
||||
(unsigned long)p->nmbr,
|
||||
(unsigned long)p->nmbr);
|
||||
#else
|
||||
/*
|
||||
* Determine of %ld can print a 64 bit long long.
|
||||
*
|
||||
* Some systems that can make use of %ld to print a
|
||||
* a 64 bit value do not support the %lld type.
|
||||
* So we will only try %lld if %ld does not work.
|
||||
*/
|
||||
# if defined(L64_FORMAT)
|
||||
printf("%s%-23s\t%-8lu\t(0x%lx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->name,
|
||||
(unsigned long long)p->nmbr,
|
||||
(unsigned long long)p->nmbr);
|
||||
# else /* L64_FORMAT */
|
||||
printf("%s%-23s\t%-8llu\t(0x%llx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->name,
|
||||
(unsigned long long)p->nmbr,
|
||||
(unsigned long long)p->nmbr);
|
||||
# endif /* L64_FORMAT */
|
||||
#endif
|
||||
} else {
|
||||
printf("%s%-23s\t\"%s\"\n",
|
||||
@@ -362,25 +346,16 @@ dump_mening_value(void)
|
||||
/* dump the entire table */
|
||||
for (p = sys_info; p->name != NULL; ++p) {
|
||||
if (p->str == NULL) {
|
||||
#if LONG_BITS == FULL_BITS || FULL_BITS == 32 || !defined(HAVE_LONGLONG)
|
||||
#if LONG_BITS == FULL_BITS || FULL_BITS == 32
|
||||
printf("%s%-36.36s\t%-8lu\t(0x%lx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->meaning,
|
||||
(unsigned long)p->nmbr,
|
||||
(unsigned long)p->nmbr);
|
||||
#else
|
||||
# if defined(L64_FORMAT)
|
||||
/* %ld prints all 64 bits, use %ld */
|
||||
printf("%s%-36.36s\t%-8lu\t(0x%lx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->meaning,
|
||||
(unsigned long long)p->nmbr,
|
||||
(unsigned long long)p->nmbr);
|
||||
# else /* L64_FORMAT */
|
||||
/* %ld prints lower 32 bits only, use %lld */
|
||||
printf("%s%-36.36s\t%-8llu\t(0x%llx)\n",
|
||||
(conf->tab_ok ? "\t" : ""), p->meaning,
|
||||
(unsigned long long)p->nmbr,
|
||||
(unsigned long long)p->nmbr);
|
||||
# endif /* L64_FORMAT */
|
||||
#endif
|
||||
} else {
|
||||
printf("%s%-36.36s\t\"%s\"\n",
|
||||
|
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: custtbl.c,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: custtbl.c,v 29.3 2004/07/29 08:37:53 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/custtbl.c,v $
|
||||
*
|
||||
* Under source code control: 1997/03/09 02:28:54
|
||||
@@ -56,6 +56,7 @@ extern VALUE c_devnull(char*, int, VALUE**);
|
||||
extern VALUE c_help(char*, int, VALUE**);
|
||||
extern VALUE c_sysinfo(char*, int, VALUE**);
|
||||
extern VALUE c_pzasusb8(char*, int, VALUE**);
|
||||
extern VALUE c_pmodm127(char*, int, VALUE**);
|
||||
|
||||
|
||||
#endif /* CUSTOM */
|
||||
@@ -108,6 +109,9 @@ CONST struct custom cust[] = {
|
||||
{ "pzasusb8", "print ZCALUE as USB8",
|
||||
0, 1, c_pzasusb8 },
|
||||
|
||||
{ "pmodm127", "calculate q mod 2^(2^127-1)",
|
||||
1, 1, c_pmodm127 },
|
||||
|
||||
|
||||
#endif /* CUSTOM */
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* halflen - determine the length of numeric value in HALFs
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2004 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: halflen.cal,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: halflen.cal,v 29.3 2004/03/31 05:03:02 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/halflen.cal,v $
|
||||
*
|
||||
* Under source code control: 1997/03/08 20:51:32
|
||||
@@ -34,11 +34,16 @@
|
||||
* NOTE: You must use a calc that was compiled with ALLOW_CUSTOM= -DCUSTOM
|
||||
* and run with a -C arg.
|
||||
*/
|
||||
if (config("compile_custom") == 0) {
|
||||
quit "calc compiled without -DCUSTOM";
|
||||
} else if (config("allow_custom") == 0) {
|
||||
quit "calc was run without the -D command line option";
|
||||
}
|
||||
|
||||
|
||||
define halflen(num)
|
||||
{
|
||||
local baseb = custom("sysinfo","BASEB"); /* bit len of a HALF */
|
||||
local baseb; /* bit len of a HALF */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -47,6 +52,11 @@ define halflen(num)
|
||||
return newerror("halflen only works on numeric values");
|
||||
}
|
||||
|
||||
/*
|
||||
* determine baseb
|
||||
*/
|
||||
baseb = custom("sysinfo","BASEB");
|
||||
|
||||
/*
|
||||
* determine the HALF length of a numeric value
|
||||
*/
|
||||
@@ -63,7 +73,3 @@ define halflen(num)
|
||||
return newerror("halflen only works on numeric values");
|
||||
}
|
||||
}
|
||||
|
||||
if (config("resource_debug") >= 0) {
|
||||
print "halflen(num) defined";
|
||||
}
|
||||
|
78
custom/pmodm127
Normal file
78
custom/pmodm127
Normal file
@@ -0,0 +1,78 @@
|
||||
NAME
|
||||
pmodm127 - calculate q mod 2^(2^127-1)
|
||||
|
||||
SYNOPSIS
|
||||
custom("pmodm127", q)
|
||||
|
||||
TYPES
|
||||
q int > 0
|
||||
|
||||
return int
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This custom function will return the value:
|
||||
|
||||
q mod 2^(2^127-1)
|
||||
|
||||
This custom function serves as a demonstration of how to write
|
||||
a custom function. It performs the equivalent of:
|
||||
|
||||
pmod(2, 2^127-1, q)
|
||||
|
||||
The return value is integer in the half open range: [0, q).
|
||||
|
||||
SPECIAL NOTE:
|
||||
|
||||
Can you find a value, q, for which this custom function returns 1?
|
||||
If you do, send the value of q to chongo using the EMail address
|
||||
found at:
|
||||
|
||||
http://www.isthe.com/chongo/address.html
|
||||
|
||||
EXAMPLE
|
||||
> custom("pmodm127", 65537)
|
||||
32769
|
||||
|
||||
> custom("pmodm127", 2^31-1)
|
||||
8
|
||||
|
||||
> custom("pmodm127", 7^51+2)
|
||||
11228202966269457258557496419097462731193173
|
||||
|
||||
LIMITS
|
||||
calc must be built with ALLOW_CUSTOM= -DCUSTOM
|
||||
calc must be executed with a -C arg.
|
||||
q must be an integer > 0
|
||||
|
||||
LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
custom
|
||||
|
||||
## Copyright (C) 2004 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: pmodm127,v 29.2 2004/07/29 09:28:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/pmodm127,v $
|
||||
##
|
||||
## Under source code control: 2004/02/25 07:13:15
|
||||
## File existed as early as: 2004
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
137
custom/pmodm127.cal
Normal file
137
custom/pmodm127.cal
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* pmodm127 - test pmodm127's ability to calculate q mod 2^(2^127-1)
|
||||
*
|
||||
* Copyright (C) 2004 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: pmodm127.cal,v 29.2 2004/07/29 08:35:36 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/pmodm127.cal,v $
|
||||
*
|
||||
* Under source code control: 2004/02/25 14:25:32
|
||||
* File existed as early as: 2004
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is part of the custom sample calc files.
|
||||
*
|
||||
* NOTE: You must use a calc that was compiled with ALLOW_CUSTOM= -DCUSTOM
|
||||
* and run with a -C arg.
|
||||
*/
|
||||
if (config("compile_custom") == 0) {
|
||||
quit "calc compiled without -DCUSTOM";
|
||||
} else if (config("allow_custom") == 0) {
|
||||
quit "calc was run without the -D command line option";
|
||||
}
|
||||
|
||||
|
||||
define pmodm127_test1(testcnt)
|
||||
{
|
||||
local q; /* test factor */
|
||||
local m127; /* 2^127-1 */
|
||||
local i;
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (!isint(testcnt) || testcnt <= 0) {
|
||||
return newerror("pmodm127_test1 must have an integer count>0");
|
||||
}
|
||||
|
||||
/*
|
||||
* perform testcnt divisor tests for primes of form 2*k*(2^127-1)+1
|
||||
*
|
||||
* NOTE: Since this is just a test, we do not need to be optimal.
|
||||
*/
|
||||
m127 = 2^127 - 1;
|
||||
q = 2*4949132165849*m127+1;
|
||||
for (i=0; i < testcnt; ++i) {
|
||||
|
||||
/*
|
||||
* determine next prime divisor
|
||||
*/
|
||||
q = nextcand(q, -1, 0, 1, 2*m127);
|
||||
|
||||
/* compare custom function with its pmod() equivalent */
|
||||
if (config("resource_debug") & 8) {
|
||||
print "testing", q;
|
||||
}
|
||||
if (pmod(2, m127, q) != custom("pmodm127", q)) {
|
||||
print "ERROR: pmodm127 failed for ", str(q);
|
||||
return newerror("pmodm127 failed for " + str(q));
|
||||
}
|
||||
}
|
||||
|
||||
/* return success count */
|
||||
if (config("resource_debug") & 8) {
|
||||
print "passed", testcnt, "tests";
|
||||
}
|
||||
return testcnt;
|
||||
}
|
||||
|
||||
define pmodm127_test2(testcnt, seed)
|
||||
{
|
||||
local q; /* test factor */
|
||||
local m127; /* 2^127-1 */
|
||||
local i;
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (!isint(testcnt) || testcnt <= 0) {
|
||||
return newerror("pmodm127_test2 must have an integer count>0");
|
||||
}
|
||||
if (!isint(seed)) {
|
||||
return newerror("pmodm127_test2 must an integer seed");
|
||||
}
|
||||
|
||||
/*
|
||||
* perform testcnt divisor tests random integers over [1e51, 1e52)
|
||||
*
|
||||
* NOTE: Since this is just a test, we do not need to be optimal.
|
||||
*/
|
||||
m127 = 2^127 - 1;
|
||||
for (i=0; i < testcnt; ++i) {
|
||||
|
||||
/*
|
||||
* determine next prime divisor
|
||||
*/
|
||||
q = rand(1e51, 1e52) | 0x1;
|
||||
if (config("resource_debug") & 8) {
|
||||
print "testing", q;
|
||||
}
|
||||
|
||||
/* compare custom function with its pmod() equivalent */
|
||||
if (pmod(2, m127, q) != custom("pmodm127", q)) {
|
||||
print "ERROR: pmodm127 failed for ", str(q);
|
||||
print "ERROR: ", pmod(2,m127,q), " != ", custom("pmodm127", q);
|
||||
return newerror("pmodm127 failed for " + str(q));
|
||||
}
|
||||
}
|
||||
|
||||
/* return success count */
|
||||
if (config("resource_debug") & 8) {
|
||||
print "passed", testcnt, "tests";
|
||||
}
|
||||
return testcnt;
|
||||
}
|
||||
|
||||
if ((config("resource_debug") & 3) && !(config("resource_debug") & 8)) {
|
||||
print "DEBUG: use config('resource_debug',", config("resource_debug")|8:") to enable more debugging";
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* pzasusb8 - print numereator as a string of USB8s
|
||||
*
|
||||
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
|
||||
* Copyright (C) 1999,2004 Ernest Bowen and Landon Curt Noll
|
||||
*
|
||||
* Primary author: Ernest Bowen
|
||||
*
|
||||
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: pzasusb8.cal,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: pzasusb8.cal,v 29.3 2004/03/31 05:03:02 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/pzasusb8.cal,v $
|
||||
*
|
||||
* Under source code control: 1999/10/06 03:11:12
|
||||
@@ -31,6 +31,15 @@
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (config("compile_custom") == 0) {
|
||||
quit "calc compiled without -DCUSTOM";
|
||||
} else if (config("allow_custom") == 0) {
|
||||
quit "calc was run without the -D command line option";
|
||||
}
|
||||
|
||||
print "p(n) prints array in which numerator of n is stored as a";
|
||||
print "sequence of 2-hex-digits representing unsigned characters.";
|
||||
print "h(n) printx n in hex notation. This should be the same as";
|
||||
@@ -52,6 +61,5 @@ print "CALC_BYTE_ORDER: ", custom("sysinfo", "CALC_BYTE_ORDER");
|
||||
print "BIG_ENDIAN: ", custom("sysinfo", "BIG_ENDIAN");
|
||||
print "LITTLE_ENDIAN: ", custom("sysinfo", "LITTLE_ENDIAN");
|
||||
print "LONG_BITS: ", custom("sysinfo", "LONG_BITS");
|
||||
print "LONGLONG_BITS: ", custom("sysinfo", "LONGLONG_BITS");
|
||||
print "Calc sizes:";
|
||||
show sizes;
|
||||
|
Reference in New Issue
Block a user