source: soft/giet_vm/applications/rosenfeld/nrc2/src/nrkernel.c @ 772

Last change on this file since 772 was 772, checked in by meunier, 8 years ago
  • Ajout de l'application rosenfeld
  • Changement du nom du flag O_CREATE en O_CREAT
File size: 4.0 KB
Line 
1// ------------------
2// --- nrkernel.c ---
3// ------------------
4
5/*
6 * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved
7 * Univ Paris Sud XI, CNRS
8 *
9 * Distributed under the Boost Software License, Version 1.0
10 * see accompanying file LICENSE.txt or copy it at
11 * http://www.boost.org/LICENSE_1_0.txt
12 */
13
14/*
15* 2002/06/11 ajout des fonctions endline
16*/
17#include <stdio.h>
18#include <stddef.h>
19#include <stdlib.h>
20#include <math.h> // fabs
21
22#include "nrc_os_config.h"
23#include "mypredef.h"
24#include "nrtype.h"
25#include "nrdef.h"
26#include "nrmacro.h"
27#include "nrkernel.h"
28
29/* ------------------------- */
30void nrerror0(char error_text[])
31/* ------------------------- */
32/* Numerical Recipes standard error handler */
33{
34    printf("Numerical Recipes run-time error...\n");
35    printf("%s\n",error_text);
36    giet_pthread_exit("...now exiting to system...\n");
37}
38/* ------------------------- */
39void nrerror1(char *format, ...)
40/* ------------------------- */
41/* global error handler */
42{
43        /*va_list pa;
44        int n;
45        char *s, c;
46        float f;
47
48    printf("NRC nrerror: ");
49        va_start(pa, format);
50
51        while (*format != '\0') {
52                if ( *format == '%' ) {
53                        switch (*++format) {
54                                case '%' : putchar('%'); break;
55                                case 'c' :
56                                        c = va_arg(pa, int); // 'char' is promoted to 'int' when passed through '...'
57                                        putchar(c);
58                                        break;
59                                case 'd' :
60                                        n = va_arg(pa, int);
61                                        printf("%d", n);
62                                        break;
63                                case 'f' : // affichage d'un float
64                                        f = (float) va_arg(pa, double);    // 'float' is promoted to 'double' when passed through '...'
65                                        printf("%f", f);
66                                        break;
67                                case 's' :
68                                        s = va_arg(pa, char*);
69                                        for ( ; *s != '\0'; s++ )
70                                                putchar(*s);
71                                        break;
72                        }
73                }
74                else
75                        putchar( *format);
76                format++;
77        }   
78        va_end(pa);
79        putchar('\n');
80        exit(-1);
81     */
82}
83/* ------------------------- */
84void nrerror(char error_text[])
85/* ------------------------- */
86/* Numerical Recipes standard error handler */
87{
88    nrerror0(error_text);
89}
90// --------------------------
91void Error(char *format, ...)
92// --------------------------
93{
94    giet_pthread_exit("NRC 'Error' with variable length args is currently unavailable\nuse nrerror until 'include <stdarg.h>' issue will be addressed\n");
95   
96        /*va_list pa;
97        int n;
98        char *s, c;
99        float f;
100
101    printf("NRC Error: ");
102        va_start(pa, format);
103
104        while (*format != '\0') {
105                if ( *format == '%' ) {
106                        switch (*++format) {
107                                case '%' : putchar('%'); break;
108                                case 'c' :
109                                        c = va_arg(pa, int); // 'char' is promoted to 'int' when passed through '...'
110                                        putchar(c);
111                                        break;
112                                case 'd' :
113                                        n = va_arg(pa, int);
114                                        printf("%d", n);
115                                        break;
116                                case 'f' : // affichage d'un float
117                                        f = (float) va_arg(pa, double);    // 'float' is promoted to 'double' when passed through '...'
118                                        printf("%f", f);
119                                        break;
120                                case 's' :
121                                        s = va_arg(pa, char*);
122                                        for ( ; *s != '\0'; s++ )
123                                                putchar(*s);
124                                        break;
125                        }
126                }
127                else
128                        putchar( *format);
129                format++;
130        }   
131        va_end(pa);
132        putchar('\n');
133        exit(-1);
134     */
135}
136// ----------------------------
137void Warning(char *format, ...)
138// ----------------------------
139{
140    giet_pthread_exit("NRC 'Warning' with variable length args is currently unavailable\nuse nrerror until 'include <stdarg.h>' issue will be addressed");
141   
142        /*
143     va_list pa;
144        int n;
145        char *s, c;
146        float f;
147
148        va_start(pa, format);
149
150        while (*format != '\0') {
151                if ( *format == '%' ) {
152                        switch (*++format) {
153                                case '%' : putchar('%'); break;
154                                case 'c' :
155                                        c = va_arg(pa, int); // 'char' is promoted to 'int' when passed through '...'
156                                        putchar(c);
157                                        break;
158                                case 'd' :
159                                        n = va_arg(pa, int);
160                                        printf("%d", n);
161                                        break;
162                                case 'f' : // affichage d'un float
163                                        f = (float) va_arg(pa, double);    // 'float' is promoted to 'double' when passed through '...'
164                                        printf("%f", f);
165                                        break;
166                                case 's' :
167                                        s = va_arg(pa, char*);
168                                        for ( ; *s != '\0'; s++ )
169                                                putchar(*s);
170                                        break;
171                        }
172                }
173                else
174                        putchar( *format);
175                format++;
176        }   
177        va_end(pa);
178        putchar('\n');
179        //exit(-1);
180     */
181}
Note: See TracBrowser for help on using the repository browser.