diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2013-04-23 07:06:42 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2013-04-23 07:06:42 -0700 |
commit | 08bf064a8ab85d2985c75194e973eb2208b489b2 (patch) | |
tree | 2194bdef51df606ac3d77c1e1c2a5fa4c5f7b386 | |
parent | 6cff3293d08092b40a7f8c946d4ebf1403730a79 (diff) | |
parent | 7ee286aa12b5c3aac48718f26dc226e9ceb9997a (diff) | |
download | lk-08bf064a8ab85d2985c75194e973eb2208b489b2.tar.gz |
Merge "include: stdlib: add macro for cache align buffer"
-rw-r--r-- | include/stdlib.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/stdlib.h b/include/stdlib.h index 7fe5b3d8..5c5145a9 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -1,6 +1,8 @@ /* * Copyright (c) 2008 Travis Geiselbrecht * + * Copyright (c) 2013, The Linux Foundation. All rights reserved. + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files * (the "Software"), to deal in the Software without restriction, @@ -48,4 +50,12 @@ int itoa(int num, unsigned char* str, int len, int base); #define STACKBUF_DMA_ALIGN(var, size) \ uint8_t __##var[(size) + CACHE_LINE]; uint8_t *var = (uint8_t *)(ROUNDUP((addr_t)__##var, CACHE_LINE)) +/* Macro to allocate buffer in both local & global space, the STACKBUF_DMA_ALIGN cannot + * be used for global space. + * If we use STACKBUF_DMA_ALIGN 'C' compiler throws the error "Initializer element + * is not constant", since global variable need to be initialized with a constant value. + */ +#define BUF_DMA_ALIGN(var, size) \ + static uint8_t var[ROUNDUP(size, CACHE_LINE)] __attribute__((aligned(CACHE_LINE))); + #endif |