Merge lp:~cern-kicad/kicad/arm_fixes into lp:kicad/product

Proposed by Maciej Suminski
Status: Merged
Merged at revision: 4515
Proposed branch: lp:~cern-kicad/kicad/arm_fixes
Merge into: lp:kicad/product
Diff against target: 571 lines (+187/-232)
8 files modified
common/gal/opengl/gpu_manager.cpp (+2/-3)
common/profile.h (+0/-147)
common/system/fcontext.s (+4/-0)
common/system/jump_arm_aapcs_elf_gas.S (+76/-0)
common/system/make_arm_aapcs_elf_gas.S (+79/-0)
common/view/view.cpp (+2/-2)
include/profile.h (+16/-72)
pcbnew/router/pns_shove.cpp (+8/-8)
To merge this branch: bzr merge lp:~cern-kicad/kicad/arm_fixes
Reviewer Review Type Date Requested Status
Wayne Stambaugh Approve
Review via email: mp+196836@code.launchpad.net

Description of the change

Changes recently proposed by Robert Yates to fix builds on ARM platform.

To post a comment you must log in.
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

I don't have an ARM system to validate this merge request so I'm assuming it works. I doesn't bread any of the existing stuff. If I don't hear any negative feedback over the next day or so, I will commit this merge.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common/gal/opengl/gpu_manager.cpp'
2--- common/gal/opengl/gpu_manager.cpp 2013-11-11 09:48:49 +0000
3+++ common/gal/opengl/gpu_manager.cpp 2013-11-27 09:28:16 +0000
4@@ -189,7 +189,7 @@
5 {
6 #ifdef __WXDEBUG__
7 prof_counter totalTime;
8- prof_start( &totalTime, false );
9+ prof_start( &totalTime );
10 #endif /* __WXDEBUG__ */
11
12 if( !m_buffersInitialized )
13@@ -214,8 +214,7 @@
14 #ifdef __WXDEBUG__
15 prof_end( &totalTime );
16
17- wxLogDebug( wxT( "Uploading %d vertices to GPU / %.1f ms" ),
18- bufferSize, (double) totalTime.value / 1000.0 );
19+ wxLogDebug( wxT( "Uploading %d vertices to GPU / %.1f ms" ), bufferSize, totalTime.msecs() );
20 #endif /* __WXDEBUG__ */
21 }
22
23
24=== removed file 'common/profile.h'
25--- common/profile.h 2013-09-13 13:28:51 +0000
26+++ common/profile.h 1970-01-01 00:00:00 +0000
27@@ -1,147 +0,0 @@
28-/*
29- * This program source code file is part of KiCad, a free EDA CAD application.
30- *
31- * Copyright (C) 2013 CERN
32- * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
33- *
34- * This program is free software; you can redistribute it and/or
35- * modify it under the terms of the GNU General Public License
36- * as published by the Free Software Foundation; either version 2
37- * of the License, or (at your option) any later version.
38- *
39- * This program is distributed in the hope that it will be useful,
40- * but WITHOUT ANY WARRANTY; without even the implied warranty of
41- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42- * GNU General Public License for more details.
43- *
44- * You should have received a copy of the GNU General Public License
45- * along with this program; if not, you may find one here:
46- * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
47- * or you may search the http://www.gnu.org website for the version 2 license,
48- * or you may write to the Free Software Foundation, Inc.,
49- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
50- */
51-
52-/**
53- * @file profile.h:
54- * @brief Simple profiling functions for measuring code execution time.
55- */
56-
57-#ifndef __TPROFILE_H
58-#define __TPROFILE_H
59-
60-#include <sys/time.h>
61-#include <stdint.h>
62-
63-/**
64- * Function rdtsc
65- * Returns processor's time-stamp counter. Main purpose is precise time measuring of code
66- * execution time.
67- * @return unsigned long long - Value of time-stamp counter.
68- */
69-#if defined(__i386__)
70-static __inline__ unsigned long long rdtsc()
71-{
72- unsigned long long int x;
73- __asm__ volatile ( ".byte 0x0f, 0x31" : "=A" ( x ) );
74-
75- return x;
76-}
77-
78-
79-#elif defined(__x86_64__)
80-static __inline__ unsigned long long rdtsc()
81-{
82- unsigned hi, lo;
83- __asm__ __volatile__ ( "rdtsc" : "=a" ( lo ), "=d" ( hi ) );
84-
85- return ( (unsigned long long) lo ) | ( ( (unsigned long long) hi ) << 32 );
86-}
87-
88-
89-#elif defined(__powerpc__)
90-static __inline__ unsigned long long rdtsc()
91-{
92- unsigned long long int result = 0;
93- unsigned long int upper, lower, tmp;
94- __asm__ volatile (
95- "0: \n"
96- "\tmftbu %0 \n"
97- "\tmftb %1 \n"
98- "\tmftbu %2 \n"
99- "\tcmpw %2,%0 \n"
100- "\tbne 0b \n"
101- : "=r" ( upper ), "=r" ( lower ), "=r" ( tmp )
102- );
103-
104- result = upper;
105- result = result << 32;
106- result = result | lower;
107-
108- return result;
109-}
110-
111-
112-#endif /* __powerpc__ */
113-
114-// Fixme: OS X version
115-/**
116- * Function get_tics
117- * Returns the number of microseconds that have elapsed since the system was started.
118- * @return uint64_t Number of microseconds.
119- */
120-static inline uint64_t get_tics()
121-{
122- struct timeval tv;
123- gettimeofday( &tv, NULL );
124-
125- return (uint64_t) tv.tv_sec * 1000000ULL + (uint64_t) tv.tv_usec;
126-}
127-
128-
129-/**
130- * Structure for storing data related to profiling counters.
131- */
132-struct prof_counter
133-{
134- uint64_t value; /// Stored timer value
135- bool use_rdtsc; /// Method of time measuring (rdtsc or tics)
136-};
137-
138-/**
139- * Function prof_start
140- * Begins code execution time counting for a given profiling counter.
141- * @param cnt is the counter which should be started.
142- * @param use_rdtsc tells if processor's time-stamp counter should be used for time counting.
143- * Otherwise is system tics method will be used. IMPORTANT: time-stamp counter should not
144- * be used on multicore machines executing threaded code.
145- */
146-static inline void prof_start( prof_counter* cnt, bool use_rdtsc )
147-{
148- cnt->use_rdtsc = use_rdtsc;
149-
150- if( use_rdtsc )
151- {
152- cnt->value = rdtsc();
153- }
154- else
155- {
156- cnt->value = get_tics();
157- }
158-}
159-
160-
161-/**
162- * Function prof_stop
163- * Ends code execution time counting for a given profiling counter.
164- * @param cnt is the counter which should be stopped.
165- */
166-static inline void prof_end( prof_counter* cnt )
167-{
168- if( cnt->use_rdtsc )
169- cnt->value = rdtsc() - cnt->value;
170- else
171- cnt->value = get_tics() - cnt->value;
172-}
173-
174-#endif
175
176=== modified file 'common/system/fcontext.s'
177--- common/system/fcontext.s 2013-10-14 11:43:57 +0000
178+++ common/system/fcontext.s 2013-11-27 09:28:16 +0000
179@@ -33,6 +33,10 @@
180 #include "jump_x86_64_sysv_elf_gas.S"
181 #include "make_x86_64_sysv_elf_gas.S"
182
183+ #elif __arm__
184+ #include "jump_arm_aapcs_elf_gas.S"
185+ #include "make_arm_aapcs_elf_gas.S"
186+
187 #else
188 #error "Missing make_fcontext & jump_fcontext routines for this architecture"
189 #endif
190
191=== added file 'common/system/jump_arm_aapcs_elf_gas.S'
192--- common/system/jump_arm_aapcs_elf_gas.S 1970-01-01 00:00:00 +0000
193+++ common/system/jump_arm_aapcs_elf_gas.S 2013-11-27 09:28:16 +0000
194@@ -0,0 +1,76 @@
195+/*
196+ Copyright Oliver Kowalke 2009.
197+ Distributed under the Boost Software License, Version 1.0.
198+ (See accompanying file LICENSE_1_0.txt or copy at
199+ http://www.boost.org/LICENSE_1_0.txt)
200+*/
201+
202+/*******************************************************************
203+ * *
204+ * ------------------------------------------------------------- *
205+ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | *
206+ * ------------------------------------------------------------- *
207+ * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| 0x20| 0x24| *
208+ * ------------------------------------------------------------- *
209+ * | v1 | v2 | v3 | v4 | v5 | v6 | v7 | v8 | sp | lr | *
210+ * ------------------------------------------------------------- *
211+ * ------------------------------------------------------------- *
212+ * | 10 | | *
213+ * ------------------------------------------------------------- *
214+ * | 0x28| | *
215+ * ------------------------------------------------------------- *
216+ * | pc | | *
217+ * ------------------------------------------------------------- *
218+ * ------------------------------------------------------------- *
219+ * | 11 | 12 | | *
220+ * ------------------------------------------------------------- *
221+ * | 0x2c| 0x30| | *
222+ * ------------------------------------------------------------- *
223+ * | sp | size| | *
224+ * ------------------------------------------------------------- *
225+ * ------------------------------------------------------------- *
226+ * | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | *
227+ * ------------------------------------------------------------- *
228+ * | 0x34| 0x38|0x3c| 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58 | *
229+ * ------------------------------------------------------------- *
230+ * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | s24 | s25 | *
231+ * ------------------------------------------------------------- *
232+ * ------------------------------------------------------------- *
233+ * | 23 | 24 | 25 | 26 | 27 | 28 | | *
234+ * ------------------------------------------------------------- *
235+ * | 0x5c| 0x60| 0x64| 0x68| 0x6c| 0x70| | *
236+ * ------------------------------------------------------------- *
237+ * | s26 | s27 | s28 | s29 | s30 | s31 | | *
238+ * ------------------------------------------------------------- *
239+ * *
240+ * *****************************************************************/
241+
242+.text
243+.globl jump_fcontext
244+.align 2
245+.type jump_fcontext,%function
246+jump_fcontext:
247+ stmia a1, {v1-v8,sp-lr} @ save V1-V8,SP-LR
248+ str lr, [a1,#40] @ save LR as PC
249+
250+#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
251+ cmp a4, #0 @ test if fpu env should be preserved
252+ beq 1f
253+
254+ mov a4, a1
255+ add a4, #52
256+ vstmia a4, {d8-d15} @ save S16-S31
257+
258+ mov a4, a2
259+ add a4, #52
260+ vldmia a4, {d8-d15} @ restore S16-S31
261+1:
262+#endif
263+
264+ mov a1, a3 @ use third arg as return value after jump
265+ @ and as first arg in context function
266+ ldmia a2, {v1-v8,sp-pc} @ restore v1-V8,SP-PC
267+.size jump_fcontext,.-jump_fcontext
268+
269+/* Mark that we don't need executable stack. */
270+.section .note.GNU-stack,"",%progbits
271
272=== added file 'common/system/make_arm_aapcs_elf_gas.S'
273--- common/system/make_arm_aapcs_elf_gas.S 1970-01-01 00:00:00 +0000
274+++ common/system/make_arm_aapcs_elf_gas.S 2013-11-27 09:28:16 +0000
275@@ -0,0 +1,79 @@
276+/*
277+ Copyright Oliver Kowalke 2009.
278+ Distributed under the Boost Software License, Version 1.0.
279+ (See accompanying file LICENSE_1_0.txt or copy at
280+ http://www.boost.org/LICENSE_1_0.txt)
281+*/
282+
283+/*******************************************************************
284+ * *
285+ * ------------------------------------------------------------- *
286+ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | *
287+ * ------------------------------------------------------------- *
288+ * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| 0x20| 0x24| *
289+ * ------------------------------------------------------------- *
290+ * | v1 | v2 | v3 | v4 | v5 | v6 | v7 | v8 | sp | lr | *
291+ * ------------------------------------------------------------- *
292+ * ------------------------------------------------------------- *
293+ * | 10 | | *
294+ * ------------------------------------------------------------- *
295+ * | 0x28| | *
296+ * ------------------------------------------------------------- *
297+ * | pc | | *
298+ * ------------------------------------------------------------- *
299+ * ------------------------------------------------------------- *
300+ * | 11 | 12 | | *
301+ * ------------------------------------------------------------- *
302+ * | 0x2c| 0x30| | *
303+ * ------------------------------------------------------------- *
304+ * | sp | size| | *
305+ * ------------------------------------------------------------- *
306+ * ------------------------------------------------------------- *
307+ * | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | *
308+ * ------------------------------------------------------------- *
309+ * | 0x34| 0x38|0x3c| 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58 | *
310+ * ------------------------------------------------------------- *
311+ * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | s24 | s25 | *
312+ * ------------------------------------------------------------- *
313+ * ------------------------------------------------------------- *
314+ * | 23 | 24 | 25 | 26 | 27 | 28 | | *
315+ * ------------------------------------------------------------- *
316+ * | 0x5c| 0x60| 0x64| 0x68| 0x6c| 0x70| | *
317+ * ------------------------------------------------------------- *
318+ * | s26 | s27 | s28 | s29 | s30 | s31 | | *
319+ * ------------------------------------------------------------- *
320+ * *
321+ * *****************************************************************/
322+
323+.text
324+.globl make_fcontext
325+.align 2
326+.type make_fcontext,%function
327+make_fcontext:
328+ mov a4, a1 @ save address of context stack (base) A4
329+ sub a1, a1, #116 @ reserve space for fcontext_t at top of context stack
330+
331+ @ shift address in A1 to lower 16 byte boundary
332+ @ == pointer to fcontext_t and address of context stack
333+ bic a1, a1, #15
334+
335+ str a4, [a1,#44] @ save address of context stack (base) in fcontext_t
336+ str a2, [a1,#48] @ save context stack size in fcontext_t
337+ str a3, [a1,#40] @ save address of context function in fcontext_t
338+
339+ str a1, [a1,#32] @ save address in A4 as stack pointer for context function
340+
341+ adr a2, finish @ compute abs address of label finish
342+ str a2, [a1,#36] @ save address of finish as return address for context function
343+ @ entered after context function returns
344+
345+ bx lr
346+
347+finish:
348+ @ SP points to same addras SP on entry of context function
349+ mov a1, #0 @ exit code is zero
350+ bl _exit@PLT @ exit application
351+.size make_fcontext,.-make_fcontext
352+
353+/* Mark that we don't need executable stack. */
354+.section .note.GNU-stack,"",%progbits
355
356=== modified file 'common/view/view.cpp'
357--- common/view/view.cpp 2013-11-06 17:17:42 +0000
358+++ common/view/view.cpp 2013-11-27 09:28:16 +0000
359@@ -971,7 +971,7 @@
360
361 #ifdef __WXDEBUG__
362 prof_counter totalRealTime;
363- prof_start( &totalRealTime, false );
364+ prof_start( &totalRealTime );
365 #endif /* __WXDEBUG__ */
366
367 for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
368@@ -992,7 +992,7 @@
369 prof_end( &totalRealTime );
370
371 wxLogDebug( wxT( "RecacheAllItems::immediately: %u %.1f ms" ),
372- aImmediately, (double) totalRealTime.value / 1000.0 );
373+ aImmediately, totalRealTime.msecs() );
374 #endif /* __WXDEBUG__ */
375 }
376
377
378=== modified file 'include/profile.h'
379--- include/profile.h 2013-09-18 17:56:37 +0000
380+++ include/profile.h 2013-11-27 09:28:16 +0000
381@@ -31,61 +31,10 @@
382 #define __TPROFILE_H
383
384 #include <sys/time.h>
385+#include <string>
386 #include <stdint.h>
387
388 /**
389- * Function rdtsc
390- * Returns processor's time-stamp counter. Main purpose is precise time measuring of code
391- * execution time.
392- * @return unsigned long long - Value of time-stamp counter.
393- */
394-#if defined(__i386__)
395-static __inline__ unsigned long long rdtsc()
396-{
397- unsigned long long int x;
398- __asm__ volatile ( ".byte 0x0f, 0x31" : "=A" ( x ) );
399-
400- return x;
401-}
402-
403-
404-#elif defined(__x86_64__)
405-static __inline__ unsigned long long rdtsc()
406-{
407- unsigned hi, lo;
408- __asm__ __volatile__ ( "rdtsc" : "=a" ( lo ), "=d" ( hi ) );
409-
410- return ( (unsigned long long) lo ) | ( ( (unsigned long long) hi ) << 32 );
411-}
412-
413-
414-#elif defined(__powerpc__)
415-static __inline__ unsigned long long rdtsc()
416-{
417- unsigned long long int result = 0;
418- unsigned long int upper, lower, tmp;
419- __asm__ volatile (
420- "0: \n"
421- "\tmftbu %0 \n"
422- "\tmftb %1 \n"
423- "\tmftbu %2 \n"
424- "\tcmpw %2,%0 \n"
425- "\tbne 0b \n"
426- : "=r" ( upper ), "=r" ( lower ), "=r" ( tmp )
427- );
428-
429- result = upper;
430- result = result << 32;
431- result = result | lower;
432-
433- return result;
434-}
435-
436-
437-#endif /* __powerpc__ */
438-
439-// Fixme: OS X version
440-/**
441 * Function get_tics
442 * Returns the number of microseconds that have elapsed since the system was started.
443 * @return uint64_t Number of microseconds.
444@@ -98,14 +47,22 @@
445 return (uint64_t) tv.tv_sec * 1000000ULL + (uint64_t) tv.tv_usec;
446 }
447
448-
449 /**
450 * Structure for storing data related to profiling counters.
451 */
452 struct prof_counter
453 {
454- uint64_t value; /// Stored timer value
455- bool use_rdtsc; /// Method of time measuring (rdtsc or tics)
456+ uint64_t start, end; // Stored timer value
457+
458+ uint64_t usecs() const
459+ {
460+ return end - start;
461+ }
462+
463+ float msecs() const
464+ {
465+ return ( end - start ) / 1000.0;
466+ }
467 };
468
469 /**
470@@ -116,32 +73,19 @@
471 * Otherwise is system tics method will be used. IMPORTANT: time-stamp counter should not
472 * be used on multicore machines executing threaded code.
473 */
474-static inline void prof_start( prof_counter* cnt, bool use_rdtsc )
475+static inline void prof_start( prof_counter* aCnt )
476 {
477- cnt->use_rdtsc = use_rdtsc;
478-
479- if( use_rdtsc )
480- {
481- cnt->value = rdtsc();
482- }
483- else
484- {
485- cnt->value = get_tics();
486- }
487+ aCnt->start = get_tics();
488 }
489
490-
491 /**
492 * Function prof_stop
493 * Ends code execution time counting for a given profiling counter.
494 * @param cnt is the counter which should be stopped.
495 */
496-static inline void prof_end( prof_counter* cnt )
497+static inline void prof_end( prof_counter* aCnt )
498 {
499- if( cnt->use_rdtsc )
500- cnt->value = rdtsc() - cnt->value;
501- else
502- cnt->value = get_tics() - cnt->value;
503+ aCnt->end = get_tics();
504 }
505
506 #endif
507
508=== modified file 'pcbnew/router/pns_shove.cpp'
509--- pcbnew/router/pns_shove.cpp 2013-10-14 18:40:36 +0000
510+++ pcbnew/router/pns_shove.cpp 2013-11-27 09:28:16 +0000
511@@ -343,11 +343,11 @@
512
513 PNS_LINE* currentLine = lineStack.top();
514
515- prof_start( &totalRealTime, false );
516+ prof_start( &totalRealTime );
517 nearest = node->NearestObstacle( currentLine, PNS_ITEM::ANY );
518 prof_end( &totalRealTime );
519
520- TRACE( 2, "t-nearestObstacle %lld us", (totalRealTime.value ) );
521+ TRACE( 2, "t-nearestObstacle %lld us", totalRealTime.usecs() );
522
523 if( !nearest )
524 {
525@@ -362,7 +362,7 @@
526 TRACE( 1, "Iter %d optimize-line [range %d-%d, total %d]",
527 iter % r_start % r_end % original->GetCLine().PointCount() );
528 // lastWalkSolid = NULL;
529- prof_start( &totalRealTime, false );
530+ prof_start( &totalRealTime );
531
532 if( optimizer.Optimize( original, &optimized ) )
533 {
534@@ -376,7 +376,7 @@
535
536 prof_end( &totalRealTime );
537
538- TRACE( 2, "t-optimizeObstacle %lld us", (totalRealTime.value ) );
539+ TRACE( 2, "t-optimizeObstacle %lld us", totalRealTime.usecs() );
540 }
541
542 lineStack.pop();
543@@ -393,12 +393,12 @@
544 PNS_LINE* collidingLine = node->AssembleLine( pseg );
545 PNS_LINE* shovedLine = collidingLine->CloneProperties();
546
547- prof_start( &totalRealTime, false );
548+ prof_start( &totalRealTime );
549 ShoveStatus st = shoveSingleLine( node, currentLine, collidingLine,
550 *pseg, shovedLine );
551 prof_end( &totalRealTime );
552
553- TRACE( 2, "t-shoveSingle %lld us", (totalRealTime.value ) );
554+ TRACE( 2, "t-shoveSingle %lld us", totalRealTime.usecs() );
555
556 if( st == SH_OK )
557 {
558@@ -441,11 +441,11 @@
559 walkaround.SetSolidsOnly( true );
560 walkaround.SetSingleDirection( true );
561
562- prof_start( &totalRealTime, false );
563+ prof_start( &totalRealTime );
564 walkaround.Route( *currentLine, *walkaroundLine, false );
565 prof_end( &totalRealTime );
566
567- TRACE( 2, "t-walkSolid %lld us", (totalRealTime.value ) );
568+ TRACE( 2, "t-walkSolid %lld us", totalRealTime.usecs() );
569
570
571 node->Replace( currentLine, walkaroundLine );