Skip to content

Instantly share code, notes, and snippets.

View lucasdemarchi's full-sized avatar

Lucas De Marchi lucasdemarchi

View GitHub Profile
@lucasdemarchi
lucasdemarchi / downcast.cpp
Created September 13, 2015 21:39
downcast example
#include <type_traits>
#define DOWNCAST_METHOD(name_, Base_, Derived_) \
template <typename Base_> \
static Derived_ *from(Base_ *base_) { \
static_assert(std::is_base_of<Base_, Derived_>::value, \
"method from() requires base object as argument"); \
return static_cast<Derived_*>(base_); \
}
#include "perf.h"
int main(int argc, const char *argv[])
{
PerfElapsed elapsed;
elapsed.begin();
elapsed.end();
elapsed.print();
#include <inttypes.h>
#include <typeinfo>
#include <stdio.h>
#define XCONCATENATE(x, y) x ## y
#define CONCATENATE(x, y) XCONCATENATE(x, y)
#define __MIN(a, b, uniq_a, uniq_b) ({ \
const typeof(a) uniq_a = (a); \
const typeof(b) uniq_b = (b); \
diff --git a/Makefile.waf b/Makefile.waf
index f16c71a..d7db696 100644
--- a/Makefile.waf
+++ b/Makefile.waf
@@ -1,25 +1,24 @@
-ROOT = $(dir $(lastword $(MAKEFILE_LIST)))
+ROOT = $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
-WAF_BINARY = $(realpath $(ROOT)/modules/waf/waf-light)
+WAF_BINARY = $(ROOT)/modules/waf/waf-light
#include <stdio.h>
class Vector {
float x = 0, y = 0, z = 0;
public:
Vector() { }
void set_x(float x) { this->x = x; }
};
struct Vector_s {
diff --git a/libraries/AP_HAL/Scheduler.h b/libraries/AP_HAL/Scheduler.h
index a22a4c0..ecf3856 100644
--- a/libraries/AP_HAL/Scheduler.h
+++ b/libraries/AP_HAL/Scheduler.h
@@ -37,7 +37,10 @@ public:
// register a high priority timer task
virtual void register_timer_process(AP_HAL::MemberProc) = 0;
virtual bool register_timer_process(AP_HAL::MemberProc proc, uint8_t freq_div)
- {register_timer_process(proc); return false;}
+ {
0000000000400630 <foo(int)>:
400630: 89 f8 mov %edi,%eax
400632: 41 89 c0 mov %eax,%r8d
400635: 0f b6 f0 movzbl %al,%esi
400638: 0f b6 d4 movzbl %ah,%edx
40063b: c1 e8 10 shr $0x10,%eax
40063e: 41 c1 e8 18 shr $0x18,%r8d
400642: 0f b6 c8 movzbl %al,%ecx
400645: bf 90 07 40 00 mov $0x400790,%edi
40064a: 31 c0 xor %eax,%eax
#include <stdlib.h>
#include <inttypes.h>
union Bla {
int a;
char b;
inline uint8_t &operator[](size_t i) { return reinterpret_cast<uint8_t *>(this)[i]; }
inline uint8_t operator[](size_t i) const { return reinterpret_cast<const uint8_t *>(this)[i]; }
};
pkgname=ardupilot-git
_srcname=ardupilot
pkgver=3.4dev
pkgrel=1
pkgdesc="ArduPilot Autopilot Suite"
arch=('any')
url="http://ardupilot.org"
license=('GPL3')
source=("${_srcname}::git+https://github.com/lucasdemarchi/ardupilot.git#branch=next")
sha256sums=('SKIP')
diff --git a/Tools/ardupilotwaf/ardupilotwaf.py b/Tools/ardupilotwaf/ardupilotwaf.py
index b5dcd1e..27a9441 100644
--- a/Tools/ardupilotwaf/ardupilotwaf.py
+++ b/Tools/ardupilotwaf/ardupilotwaf.py
@@ -133,6 +133,7 @@ def ap_program(bld,
name=name,
program_name=program_name,
program_dir=program_dir,
+ uselib='LIBIIO LIBDL LTTNG-UST',
**kw