summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/my_atomic.h10
-rw-r--r--storage/maria/ma_loghandler.c7
-rw-r--r--storage/maria/unittest/ma_pagecache_consist.c33
3 files changed, 30 insertions, 20 deletions
diff --git a/include/my_atomic.h b/include/my_atomic.h
index 5579a98b510..40d762f8ff0 100644
--- a/include/my_atomic.h
+++ b/include/my_atomic.h
@@ -184,19 +184,19 @@ STATIC_INLINE void my_atomic_store ## S( \
#else /* no inline functions */
#define make_atomic_add(S) \
-extern int ## S my_atomic_add ## S(Uv_ ## S, U_ ## S);
+extern int ## S my_atomic_add ## S(Uv_ ## S U_a, U_ ## S U_v);
#define make_atomic_fas(S) \
-extern int ## S my_atomic_fas ## S(Uv_ ## S, U_ ## S);
+extern int ## S my_atomic_fas ## S(Uv_ ## S U_a, U_ ## S U_v);
#define make_atomic_cas(S) \
-extern int my_atomic_cas ## S(Uv_ ## S, Uv_ ## S, U_ ## S);
+extern int my_atomic_cas ## S(Uv_ ## S U_a, Uv_ ## S U_cmp, U_ ## S U_set);
#define make_atomic_load(S) \
-extern int ## S my_atomic_load ## S(Uv_ ## S);
+extern int ## S my_atomic_load ## S(Uv_ ## S U_a);
#define make_atomic_store(S) \
-extern void my_atomic_store ## S(Uv_ ## S, U_ ## S);
+extern void my_atomic_store ## S(Uv_ ## S U_a, U_ ## S U_v);
#endif
diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
index f2675aef91f..599aa4395aa 100644
--- a/storage/maria/ma_loghandler.c
+++ b/storage/maria/ma_loghandler.c
@@ -84,6 +84,11 @@ typedef struct st_translog_file
/* log write buffer descriptor */
struct st_translog_buffer
{
+ /*
+ Cache for current log. Comes first to be aligned for bmove512() in
+ pagecache_inject()
+ */
+ uchar buffer[TRANSLOG_WRITE_BUFFER];
LSN last_lsn;
/* This buffer offset in the file */
TRANSLOG_ADDRESS offset;
@@ -148,8 +153,6 @@ struct st_translog_buffer
With file and offset it allow detect buffer changes
*/
uint8 ver;
- /* Cache for current log. */
- uchar buffer[TRANSLOG_WRITE_BUFFER];
};
diff --git a/storage/maria/unittest/ma_pagecache_consist.c b/storage/maria/unittest/ma_pagecache_consist.c
index 63be8be93ce..3b726b3daea 100644
--- a/storage/maria/unittest/ma_pagecache_consist.c
+++ b/storage/maria/unittest/ma_pagecache_consist.c
@@ -102,20 +102,26 @@ static uint get_len(uint limit)
}
-/* check page consistency */
+/*
+ Check page's consistency: layout is
+ 4 bytes: number 'num' of records in this page, then num occurences of
+ { 4 bytes: record's length 'len'; then 4 bytes unchecked ('tag') then
+ 'len' bytes each equal to the record's sequential number in this page,
+ modulo 256 }, then zeroes.
+ */
uint check_page(uchar *buff, ulong offset, int page_locked, int page_no,
int tag)
{
uint end= sizeof(uint);
- uint num= *((uint *)buff);
+ uint num= uint4korr(buff);
uint i;
DBUG_ENTER("check_page");
for (i= 0; i < num; i++)
{
- uint len= *((uint *)(buff + end));
+ uint len= uint4korr(buff + end);
uint j;
- end+= sizeof(uint) + sizeof(uint);
+ end+= 4 + 4;
if (len + end > TEST_PAGE_SIZE)
{
diag("incorrect field header #%u by offset %lu\n", i, offset + end);
@@ -169,17 +175,18 @@ err:
void put_rec(uchar *buff, uint end, uint len, uint tag)
{
uint i;
- uint num= *((uint *)buff);
+ uint num;
+ num= uint4korr(buff);
if (!len)
len= 1;
- if (end + sizeof(uint)*2 + len > TEST_PAGE_SIZE)
+ if (end + 4*2 + len > TEST_PAGE_SIZE)
return;
- *((uint *)(buff + end))= len;
- end+= sizeof(uint);
- *((uint *)(buff + end))= tag;
- end+= sizeof(uint);
+ int4store(buff + end, len);
+ end+= 4;
+ int4store(buff + end, tag);
+ end+= 4;
num++;
- *((uint *)buff)= num;
+ int4store(buff, num);
for (i= end; i < (len + end); i++)
{
buff[i]= (uchar) num % 256;
@@ -276,7 +283,7 @@ static void *test_thread_reader(void *arg)
DBUG_PRINT("info", ("Thread %s ended\n", my_thread_name()));
pthread_mutex_lock(&LOCK_thread_count);
- ok(1, "reader%d: done\n", param);
+ ok(1, "reader%d: done", param);
thread_count--;
VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */
pthread_mutex_unlock(&LOCK_thread_count);
@@ -297,7 +304,7 @@ static void *test_thread_writer(void *arg)
DBUG_PRINT("info", ("Thread %s ended\n", my_thread_name()));
pthread_mutex_lock(&LOCK_thread_count);
- ok(1, "writer%d: done\n", param);
+ ok(1, "writer%d: done", param);
thread_count--;
VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */
pthread_mutex_unlock(&LOCK_thread_count);