Open lingdf opened 10 years ago
Ah, OK. That's always a potential problem with C - a function name clash with another library. I suggest that you edit ALL of the miracl library files and replace instr(..) everywhere with (for example) mr_instr(..) That should fix it. Mike …
Hello Mike, I meet a new problem and I spent the whole day trying to solve it,but i failed. Will you do me a favour? When i use epoint_set() funcition ,first time it runs normally, then runs some other code , then when I call this function for the second time, the error appears: " MIRACL error from routine nres called from epoint_set called from your program No modulus defined" I looked it up in the manual, and it said so: " Message: No modulus defined Diagnosis: No modulus has been specified, yet a function which needs it has been called. Response: Set a modulus for use internally " I don't know how to set this function right,because first time this function can work normally. I would appreciate it very much if you could help me
Hello,
Not really enough details, but I suspect the problem arises because of the "runs some other code".
MIRACL is not natively multi-threaded, and by default curve constants such as the modulus are stored as elements of the single global instance of the miracl structure defined in miracl.h. The single instance of this structure is pointed to be mr_mip.
Basically when you "run some other code" I suspect that the value of mr_mip has been forgotten, or gone out of scope.
Maybe you could copy it and restore it after running the "other code"? Or maybe you could just re-initialise the miracl code after the "other code"?
Mike
On Fri, Dec 21, 2018 at 12:45 PM Atbnsanw notifications@github.com wrote:
Ah, OK. That's always a potential problem with C - a function name clash with another library. I suggest that you edit ALL of the miracl library files and replace instr(..) everywhere with (for example) mr_instr(..) That should fix it. Mike … <#m6414416131447797624>
Hello Mike, I meet a new problem and I spent the whole day trying to solve it,but i failed. Will you do me a favour? When i use epoint_set() funcition ,first time it runs normally, then runs some other code , then when I call this function for the second time, the error appears: " MIRACL error from routine nres called from epoint_set called from your program No modulus defined" I looked it up in the manual, and it said so: " Message: No modulus defined Diagnosis: No modulus has been specified, yet a function which needs it has been called. Response: Set a modulus for use internally " I don't know how to set this function right,because first time this function can work normally. I would appreciate it very much if you could help me
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/miracl/MIRACL/issues/4#issuecomment-449379548, or mute the thread https://github.com/notifications/unsubscribe-auth/ACm8jtTejzRu8gg1ZOSXp9iVKRxka6Arks5u7NfRgaJpZM4Bw147 .
Hello, Not really enough details, but I suspect the problem arises because of the "runs some other code". MIRACL is not natively multi-threaded, and by default curve constants such as the modulus are stored as elements of the single global instance of the miracl structure defined in miracl.h. The single instance of this structure is pointed to be mr_mip. Basically when you "run some other code" I suspect that the value of mr_mip has been forgotten, or gone out of scope. Maybe you could copy it and restore it after running the "other code"? Or maybe you could just re-initialise the miracl code after the "other code"? Mike …
Thank you very much for taking the time to help me.I add extra mirsys() functions to solve the problem. I use mirsys() in a separate function ,and perhaps this is the cause of the problem.My understanding is when i use mirsys in a separate function, it will overwrite the original settings, and after the separate function ended, all miracl setting and memory space are also released? So i have to add extra mirsys() functions every time after using mirsys() in a separate function.
Hello,dear friends. I also did the same steps but I met a lot of mistakes in step 6.Any idea why I am getting this error?? Mac OS X 10.15.
mrarth1.c:56:10: fatal error: 'ieeefp.h' file not found
^~~~~~~~~~
1 error generated.
mrecn2.c:2114:6: error: conflicting types for 'ecn2_setxyz'
void ecn2_setxyz(zzn2 x,zzn2 y,zzn2 z,ecn2 e)
^
./include/miracl.h:1311:13: note: previous declaration is here
extern void ecn2_setxyz(MIPT zzn2 ,zzn2 ,zzn2 ,ecn2 );
^
1 error generated.
mrkcm.c:150:3: error: use of undeclared identifier 'extra'
extra=0;
^
mrkcm.c:151:3: error: use of undeclared identifier 'sum'
sum=0;
^
mrkcm.c:152:3: error: use of undeclared identifier 'pp1'
pp1=(mr_large)a[0]b[0];
^
mrkcm.c:153:3: error: use of undeclared identifier 'sum'
sum+=pp1;
^
mrkcm.c:153:8: error: use of undeclared identifier 'pp1'
sum+=pp1;
^
mrkcm.c:154:3: error: use of undeclared identifier 'extra'
extra+=(sum<pp1);
^
mrkcm.c:154:11: error: use of undeclared identifier 'sum'
extra+=(sum<pp1);
^
mrkcm.c:154:15: error: use of undeclared identifier 'pp1'
extra+=(sum<pp1);
^
mrkcm.c:155:18: error: use of undeclared identifier 'sum'
c[0]=(mr_small)sum;
^
mrkcm.c:156:3: error: use of undeclared identifier 'sum'
sum=(sum>>MIRACL)|((mr_large)extra<<MIRACL);
^
mrkcm.c:156:8: error: use of undeclared identifier 'sum'
sum=(sum>>MIRACL)|((mr_large)extra<<MIRACL);
^
mrkcm.c:156:32: error: use of undeclared identifier 'extra'; did you mean
'extern'?
sum=(sum>>MIRACL)|((mr_large)extra<<MIRACL);
^~~~~
extern
mrkcm.c:156:32: error: expected expression
mrkcm.c:157:3: error: use of undeclared identifier 'extra'
extra=0;
^
mrkcm.c:158:3: error: use of undeclared identifier 'pp1'
pp1=(mr_large)a[0]b[1];
^
mrkcm.c:159:3: error: use of undeclared identifier 'pp2'
pp2=(mr_large)a[1]*b[0];
^
mrkcm.c:160:3: error: use of undeclared identifier 'sum'
sum+=pp1;
^
mrkcm.c:160:8: error: use of undeclared identifier 'pp1'
sum+=pp1;
^
mrkcm.c:161:3: error: use of undeclared identifier 'extra'
extra+=(sum<pp1);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
mrmonty.c:145:20: error: invalid operands to binary expression ('mr_small'
(aka 'double') and 'int')
if (n->w[n->len-1]>>M4 < 5) mr_mip->NO_CARRY=TRUE;
1 error generated.
mrmuldv.c:12:9: error: use of undeclared identifier '_asm'
ASM mov eax,DWORD PTR a
^
mrmuldv.c:7:13: note: expanded from macro 'ASM'
#define ASM _asm
^
mrmuldv.c:24:9: error: use of undeclared identifier '_asm'
ASM mov edx,DWORD PTR a
^
mrmuldv.c:7:13: note: expanded from macro 'ASM'
#define ASM _asm
^
mrmuldv.c:34:9: error: use of undeclared identifier '_asm'
ASM mov eax,DWORD PTR a
^
mrmuldv.c:7:13: note: expanded from macro 'ASM'
#define ASM _asm
^
mrmuldv.c:46:9: error: use of undeclared identifier '_asm'
ASM mov eax,DWORD PTR a
^
mrmuldv.c:7:13: note: expanded from macro 'ASM'
#define ASM _asm
^
4 errors generated.
mrstrong.c:164:11: error: invalid operands to binary expression ('mr_small'
(aka 'double') and 'int')
r = (r << 8) ^ ran;
~ ^ ~
mrstrong.c:167:49: error: implicitly declaring library function 'modf' with type
'double (double, double *)' [-Werror,-Wimplicit-function-declaration]
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:27: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
mrstrong.c:167:49: note: include the header <math.h> or explicitly provide a
declaration for 'modf'
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:27: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
mrstrong.c:167:49: error: use of undeclared identifier 'dres'; did you mean
'nres'?
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:41: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
./include/miracl.h:1029:14: note: 'nres' declared here
extern void nres(_MIPT_ big,big);
^
mrstrong.c:167:49: error: use of undeclared identifier 'dres'; did you mean
'nres'?
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:47: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
./include/miracl.h:1029:14: note: 'nres' declared here
extern void nres(_MIPT_ big,big);
^
mrstrong.c:167:49: error: invalid operands to binary expression ('mr_small'
(aka 'double') and 'void (*)(miracl *, big, big)' (aka 'void (*)(miracl *,
struct bigtype *, struct bigtype *)'))
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^~~~~~~~~~~~~~~~~~~~~~~~~
./include/miracl.h:275:34: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
~~~^~~~~~~~~~~~~~~~
5 errors generated.
yujiarui@yujiaruideMacBook-Air miracl_list % gcc -I ./include -c -O2 mr*.c
mrarth1.c:56:10: fatal error: 'ieeefp.h' file not found
#include <ieeefp.h>
^~~~~~~~~~
1 error generated.
mrecn2.c:2114:6: error: conflicting types for 'ecn2_setxyz'
void ecn2_setxyz(zzn2 *x,zzn2 *y,zzn2 *z,ecn2 *e)
^
./include/miracl.h:1311:13: note: previous declaration is here
extern void ecn2_setxyz(_MIPT_ zzn2 *,zzn2 *,zzn2 *,ecn2 *);
^
1 error generated.
mrkcm.c:150:3: error: use of undeclared identifier 'extra'
extra=0;
^
mrkcm.c:151:3: error: use of undeclared identifier 'sum'
sum=0;
^
mrkcm.c:152:3: error: use of undeclared identifier 'pp1'
pp1=(mr_large)a[0]*b[0];
^
mrkcm.c:153:3: error: use of undeclared identifier 'sum'
sum+=pp1;
^
mrkcm.c:153:8: error: use of undeclared identifier 'pp1'
sum+=pp1;
^
mrkcm.c:154:3: error: use of undeclared identifier 'extra'
extra+=(sum<pp1);
^
mrkcm.c:154:11: error: use of undeclared identifier 'sum'
extra+=(sum<pp1);
^
mrkcm.c:154:15: error: use of undeclared identifier 'pp1'
extra+=(sum<pp1);
^
mrkcm.c:155:18: error: use of undeclared identifier 'sum'
c[0]=(mr_small)sum;
^
mrkcm.c:156:3: error: use of undeclared identifier 'sum'
sum=(sum>>MIRACL)|((mr_large)extra<<MIRACL);
^
mrkcm.c:156:8: error: use of undeclared identifier 'sum'
sum=(sum>>MIRACL)|((mr_large)extra<<MIRACL);
^
mrkcm.c:156:32: error: use of undeclared identifier 'extra'; did you mean
'extern'?
sum=(sum>>MIRACL)|((mr_large)extra<<MIRACL);
^~~~~
extern
mrkcm.c:156:32: error: expected expression
mrkcm.c:157:3: error: use of undeclared identifier 'extra'
extra=0;
^
mrkcm.c:158:3: error: use of undeclared identifier 'pp1'
pp1=(mr_large)a[0]*b[1];
^
mrkcm.c:159:3: error: use of undeclared identifier 'pp2'
pp2=(mr_large)a[1]*b[0];
^
mrkcm.c:160:3: error: use of undeclared identifier 'sum'
sum+=pp1;
^
mrkcm.c:160:8: error: use of undeclared identifier 'pp1'
sum+=pp1;
^
mrkcm.c:161:3: error: use of undeclared identifier 'extra'
extra+=(sum<pp1);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
mrmonty.c:145:20: error: invalid operands to binary expression ('mr_small'
(aka 'double') and 'int')
if (n->w[n->len-1]>>M4 < 5) mr_mip->NO_CARRY=TRUE;
~~~~~~~~~~~~~~^ ~~
1 error generated.
mrstrong.c:164:11: error: invalid operands to binary expression ('mr_small'
(aka 'double') and 'int')
r = (r << 8) ^ ran;
~ ^ ~
mrstrong.c:167:49: error: implicitly declaring library function 'modf' with type
'double (double, double *)' [-Werror,-Wimplicit-function-declaration]
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:27: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
mrstrong.c:167:49: note: include the header <math.h> or explicitly provide a
declaration for 'modf'
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:27: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
mrstrong.c:167:49: error: use of undeclared identifier 'dres'; did you mean
'nres'?
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:41: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
./include/miracl.h:1029:14: note: 'nres' declared here
extern void nres(_MIPT_ big,big);
^
mrstrong.c:167:49: error: use of undeclared identifier 'dres'; did you mean
'nres'?
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:47: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
./include/miracl.h:1029:14: note: 'nres' declared here
extern void nres(_MIPT_ big,big);
^
mrstrong.c:167:49: error: invalid operands to binary expression ('mr_small'
(aka 'double') and 'void (*)(miracl *, big, big)' (aka 'void (*)(miracl *,
struct bigtype *, struct bigtype *)'))
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^~~~~~~~~~~~~~~~~~~~~~~~~
./include/miracl.h:275:34: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
~~~^~~~~~~~~~~~~~~~
5 errors generated.
yujiarui@yujiaruideMacBook-Air miracl_list % gcc -I ./include -c -O2 mr*.c
mrarth1.c:56:10: fatal error: 'ieeefp.h' file not found
#include <ieeefp.h>
^~~~~~~~~~
1 error generated.
mrecn2.c:2114:6: error: conflicting types for 'ecn2_setxyz'
void ecn2_setxyz(zzn2 *x,zzn2 *y,zzn2 *z,ecn2 *e)
^
./include/miracl.h:1311:13: note: previous declaration is here
extern void ecn2_setxyz(_MIPT_ zzn2 *,zzn2 *,zzn2 *,ecn2 *);
^
1 error generated.
mrkcm.c:150:3: error: use of undeclared identifier 'extra'
extra=0;
^
mrkcm.c:151:3: error: use of undeclared identifier 'sum'
sum=0;
^
mrkcm.c:152:3: error: use of undeclared identifier 'pp1'
pp1=(mr_large)a[0]*b[0];
^
mrkcm.c:153:3: error: use of undeclared identifier 'sum'
sum+=pp1;
^
mrkcm.c:153:8: error: use of undeclared identifier 'pp1'
sum+=pp1;
^
mrkcm.c:154:3: error: use of undeclared identifier 'extra'
extra+=(sum<pp1);
^
mrkcm.c:154:11: error: use of undeclared identifier 'sum'
extra+=(sum<pp1);
^
mrkcm.c:154:15: error: use of undeclared identifier 'pp1'
extra+=(sum<pp1);
^
mrkcm.c:155:18: error: use of undeclared identifier 'sum'
c[0]=(mr_small)sum;
^
mrkcm.c:156:3: error: use of undeclared identifier 'sum'
sum=(sum>>MIRACL)|((mr_large)extra<<MIRACL);
^
mrkcm.c:156:8: error: use of undeclared identifier 'sum'
sum=(sum>>MIRACL)|((mr_large)extra<<MIRACL);
^
mrkcm.c:156:32: error: use of undeclared identifier 'extra'; did you mean
'extern'?
sum=(sum>>MIRACL)|((mr_large)extra<<MIRACL);
^~~~~
extern
mrkcm.c:156:32: error: expected expression
mrkcm.c:157:3: error: use of undeclared identifier 'extra'
extra=0;
^
mrkcm.c:158:3: error: use of undeclared identifier 'pp1'
pp1=(mr_large)a[0]*b[1];
^
mrkcm.c:159:3: error: use of undeclared identifier 'pp2'
pp2=(mr_large)a[1]*b[0];
^
mrkcm.c:160:3: error: use of undeclared identifier 'sum'
sum+=pp1;
^
mrkcm.c:160:8: error: use of undeclared identifier 'pp1'
sum+=pp1;
^
mrkcm.c:161:3: error: use of undeclared identifier 'extra'
extra+=(sum<pp1);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
mrmonty.c:145:20: error: invalid operands to binary expression ('mr_small'
(aka 'double') and 'int')
if (n->w[n->len-1]>>M4 < 5) mr_mip->NO_CARRY=TRUE;
~~~~~~~~~~~~~~^ ~~
1 error generated.
mrmuldv.c:12:9: error: use of undeclared identifier '_asm'
ASM mov eax,DWORD PTR a
^
mrmuldv.c:7:13: note: expanded from macro 'ASM'
#define ASM _asm
^
mrmuldv.c:24:9: error: use of undeclared identifier '_asm'
ASM mov edx,DWORD PTR a
^
mrmuldv.c:7:13: note: expanded from macro 'ASM'
#define ASM _asm
^
mrmuldv.c:34:9: error: use of undeclared identifier '_asm'
ASM mov eax,DWORD PTR a
^
mrmuldv.c:7:13: note: expanded from macro 'ASM'
#define ASM _asm
^
mrmuldv.c:46:9: error: use of undeclared identifier '_asm'
ASM mov eax,DWORD PTR a
^
mrmuldv.c:7:13: note: expanded from macro 'ASM'
#define ASM _asm
^
4 errors generated.
mrstrong.c:164:11: error: invalid operands to binary expression ('mr_small'
(aka 'double') and 'int')
r = (r << 8) ^ ran;
~ ^ ~
mrstrong.c:167:49: error: implicitly declaring library function 'modf' with type
'double (double, double *)' [-Werror,-Wimplicit-function-declaration]
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:27: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
mrstrong.c:167:49: note: include the header <math.h> or explicitly provide a
declaration for 'modf'
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:27: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
mrstrong.c:167:49: error: use of undeclared identifier 'dres'; did you mean
'nres'?
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:41: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
./include/miracl.h:1029:14: note: 'nres' declared here
extern void nres(_MIPT_ big,big);
^
mrstrong.c:167:49: error: use of undeclared identifier 'dres'; did you mean
'nres'?
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^
./include/miracl.h:275:35: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
^
./include/miracl.h:264:47: note: expanded from macro 'MR_DIV'
#define MR_DIV(a,b) (modf((a)/(b),&dres),dres)
^
./include/miracl.h:1029:14: note: 'nres' declared here
extern void nres(_MIPT_ big,big);
^
mrstrong.c:167:49: error: invalid operands to binary expression ('mr_small'
(aka 'double') and 'void (*)(miracl *, big, big)' (aka 'void (*)(miracl *,
struct bigtype *, struct bigtype *)'))
else mr_mip->w1->w[m-1]=MR_REMAIN(r,mr_mip->base);
^~~~~~~~~~~~~~~~~~~~~~~~~
./include/miracl.h:275:34: note: expanded from macro 'MR_REMAIN'
#define MR_REMAIN(a,b) ((a)-(b)*MR_DIV((a),(b)))
~~~^~~~~~~~~~~~~~~~
5 errors generated.
Could you please tell me why I am getting those error?Or could you please let me use your miracl library that you have compiled?Nowadays I have an assignment that required the miracl library. Thank you very much.
How can I compile in mac os .a library and Which is what I need the source files