Rev 2131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2131 | Rev 2174 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | * Copyright (c) 2005 Ondrej Palkovsky |
2 | * Copyright (c) 2007 Michal Kebrt |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
Line 51... | Line 51... | ||
51 | * |
51 | * |
52 | * @return Value after addition. |
52 | * @return Value after addition. |
53 | */ |
53 | */ |
54 | static inline long atomic_add(atomic_t *val, int i) |
54 | static inline long atomic_add(atomic_t *val, int i) |
55 | { |
55 | { |
- | 56 | int ret; |
|
- | 57 | volatile long * mem = &(val->count); |
|
- | 58 | ||
- | 59 | asm volatile ( |
|
- | 60 | "1: \n" |
|
- | 61 | "ldr r2, [%1] \n" |
|
- | 62 | "add r3, r2, %2 \n" |
|
- | 63 | "str r3, %0 \n" |
|
- | 64 | "swp r3, r3, [%1] \n" |
|
- | 65 | "cmp r3, r2 \n" |
|
- | 66 | "bne 1b \n" |
|
- | 67 | ||
56 | /* TODO */ |
68 | : "=m" (ret) |
57 | return (val->count += i); |
69 | : "r" (mem), "r" (i) |
- | 70 | : "r3", "r2" |
|
- | 71 | ); |
|
- | 72 | ||
- | 73 | return ret; |
|
58 | } |
74 | } |
59 | 75 | ||
60 | #endif |
76 | #endif |
61 | 77 | ||
62 | /** @} |
78 | /** @} |