Most of the differences between 5.1 and 5.2 are made easier by the fact that 5.2 is usually compiled with LUA_COMPAT_ALL. So these things are already defined:
Which means (to anticipate the obvious) that you have to define LUA_COMPAT_ALL in your code or build.
Note that lua_cpcall is also defined as a macro with LUA_COMPAT_ALL. The absence of luaL_typerror can be a bitch, however, and watch out for lua_load and lua_resume's extra parameter...