ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/devel.h
Revision: 1.11
Committed: Sat Nov 17 23:40:00 2018 UTC (5 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +1 -0 lines
Log Message:
copyright update 2018

File Contents

# User Rev Content
1 root 1.1 /*
2     * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 root 1.9 *
4 root 1.11 * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
5 root 1.10 * Copyright (©) 2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
6 root 1.9 *
7 root 1.4 * Deliantra is free software: you can redistribute it and/or modify it under
8     * the terms of the Affero GNU General Public License as published by the
9     * Free Software Foundation, either version 3 of the License, or (at your
10     * option) any later version.
11 root 1.9 *
12 root 1.1 * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16 root 1.9 *
17 root 1.4 * You should have received a copy of the Affero GNU General Public License
18     * and the GNU General Public License along with this program. If not, see
19     * <http://www.gnu.org/licenses/>.
20 root 1.9 *
21 root 1.1 * The authors can be reached via e-mail to <support@deliantra.net>
22     */
23    
24     // This file is only included with -DDEVEL, and is only part
25     // of the distributon for completeness, it is not supposed to
26     // be useful outside the developers machines.
27    
28     #ifndef DEVEL_H
29     #define DEVEL_H
30    
31     // used for benchmarking (x86/amd64-specific)
32 root 1.3 #ifdef DEVEL64
33     typedef uint64_t cstamp;
34     #else
35     typedef uint32_t cstamp;
36     #endif
37    
38     #if defined(__i386__) || defined(__x86_64__)
39 root 1.1
40     static inline cstamp
41 root 1.5 stamp ()
42 root 1.1 {
43 root 1.3 uint32_t l, h;
44    
45     asm volatile ("rdtsc" : "=a" (l), "=d" (h));
46    
47     #ifdef DEVEL64
48     return ((cstamp)h << 32) | l;
49     #else
50     return l;
51     #endif
52 root 1.1 }
53    
54 root 1.3 #elif defined(__powerpc__)
55     static inline cstamp
56 root 1.5 stamp ()
57 root 1.3 {
58     unsigned uint32_t u, l, tmp;
59    
60     asm volatile (
61     "0: \n"
62     "\tmftbu %0 \n"
63     "\tmftb %1 \n"
64     "\tmftbu %2 \n"
65     "\tcmpw %2,%0\n"
66     "\tbne 0b \n"
67     : "=r" (h), "=r" (l), "=r" (tmp)
68     );
69    
70     #ifdef DEVEL64
71     return ((cstamp)h << 32) | l;
72     #else
73     return l;
74     #endif
75     }
76    
77     #endif
78    
79 root 1.1 static inline cstamp
80     measure (cstamp t)
81     {
82 root 1.2 return stamp () - t;
83 root 1.1 }
84    
85     // cstamp s = stamp ();
86     // s = measure (s);
87    
88     #endif
89