a stab at turning on rudimentary logging for telefiretwo
[fw/altos] / src / kernel / ao_int64.h
1 /*
2  * Copyright © 2013 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #ifndef _AO_INT64_H_
20 #define _AO_INT64_H_
21
22 #include <stdint.h>
23
24 typedef struct {
25         uint32_t        high;
26         uint32_t        low;
27 } ao_int64_t;
28
29 #define __FATTR
30 #define __ARG __pdata
31 #define __LOCAL static __pdata
32
33 void ao_plus64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, __pdata ao_int64_t *ao_64b) __FATTR;
34 void ao_minus64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, __pdata ao_int64_t *ao_64b) __FATTR;
35 void ao_neg64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a) __FATTR;
36 void ao_rshift64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, uint8_t d) __FATTR;
37 void ao_lshift64(__pdata ao_int64_t *ao_64r, __pdata ao_int64_t *ao_64a, uint8_t d) __FATTR;
38 void ao_mul64_32_32(__ARG ao_int64_t *r, __ARG int32_t a, __ARG int32_t b) __FATTR;
39 void ao_mul64_64_16(__ARG ao_int64_t *r, __ARG ao_int64_t *a, __ARG uint16_t b) __FATTR;
40 void ao_mul64(__ARG ao_int64_t * __ARG r, __ARG ao_int64_t * __ARG a, __ARG ao_int64_t *__ARG b) __FATTR;
41
42 #define ao_int64_init32(r, a) (((r)->high = 0), (r)->low = (a))
43 #define ao_int64_init64(r, a, b) (((r)->high = (a)), (r)->low = (b))
44
45 #define ao_cast64(a) (((int64_t) (a)->high << 32) | (a)->low)
46
47 #define ao_int64_negativep(a)   (((int32_t) (a)->high) < 0)
48
49 #endif /* _AO_INT64_H_ */