lkml.org 
[lkml]   [2009]   [May]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 12/27] asm-generic: add a NOMMU uaccess.h
    Arnd Bergmann wrote:
    > On Friday 01 May 2009, Michal Simek wrote:
    >>> +#ifndef __put_user
    >>> +#define __put_user(x, ptr) \
    >>> +({ \
    >>> + int __pu_err = 0; \
    >>> + typeof(*(ptr)) __pu_val = (x); \
    >>> + switch (sizeof (*(ptr))) { \
    >>> + case 1: \
    >>> + case 2: \
    >>> + case 4: \
    >>> + *(ptr) = (__pu_val); \
    >>> + break; \
    >>> + case 8: \
    >>> + memcpy(ptr, &__pu_val, sizeof (*(ptr)));\
    >>
    >> potential cast problem
    >
    > Yes, I'm looking into this already, probably will do something
    > based on the s390 code, which seems to do this correctly.
    >
    >>> +#define put_user(x, ptr) ( \
    >>> + access_ok(VERIFY_WRITE, ptr, sizeof (*ptr)) ? \
    >>> + __put_user(x, ptr) : \
    >>> + -EFAULT)
    >>
    >> IMHO write it as inline function with type checking.
    >
    > Unfortunately, this doesn't work because of the callin
    > conventions: __put_user needs to know the type of ptr,
    > so it has to be a macro.

    yes, I am looking on it too.

    Michal

    >
    > Arnd <><


    --
    Michal Simek, Ing. (M.Eng)
    w: www.monstr.eu p: +42-0-721842854


    \
     
     \ /
      Last update: 2009-05-01 14:41    [W:0.022 / U:122.304 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site